|
3 | 3 | The TUI harness provides MCP tools for programmatically driving the AgentCore CLI terminal UI. The MCP server lives at |
4 | 4 | `src/mcp-harness/` and the underlying library is at `src/test-utils/tui-harness/`. |
5 | 5 |
|
| 6 | +## Running in HTTP Mode (Recommended) |
| 7 | + |
| 8 | +The TUI harness supports two transport modes: **HTTP** and **stdio**. HTTP mode is the recommended way to run the server |
| 9 | +when using it from Claude Code. |
| 10 | + |
| 11 | +**Why HTTP mode?** In stdio mode, the MCP server runs inside Claude Code's sandbox, which blocks `posix_spawnp` -- the |
| 12 | +system call that `node-pty` needs to spawn PTY processes. This means `tui_launch` will fail when the server is connected |
| 13 | +via stdio. HTTP mode runs the server as an independent process outside the sandbox, so PTY spawning works normally. |
| 14 | + |
| 15 | +### Quick Start |
| 16 | + |
| 17 | +```bash |
| 18 | +# Build the harness |
| 19 | +npm run build:harness |
| 20 | + |
| 21 | +# Start the MCP server in HTTP mode (runs on port 24100) |
| 22 | +node dist/mcp-harness/index.mjs --http |
| 23 | + |
| 24 | +# Or use the convenience script |
| 25 | +./scripts/start-tui-harness.sh |
| 26 | +``` |
| 27 | + |
| 28 | +### Configure Claude Code |
| 29 | + |
| 30 | +Add the HTTP server as an MCP source in Claude Code: |
| 31 | + |
| 32 | +```bash |
| 33 | +# Add via CLI |
| 34 | +claude mcp add --transport http -s project tui-harness http://127.0.0.1:24100/mcp |
| 35 | +``` |
| 36 | + |
| 37 | +Or add directly to `.mcp.json`: |
| 38 | + |
| 39 | +```json |
| 40 | +{ |
| 41 | + "mcpServers": { |
| 42 | + "tui-harness": { |
| 43 | + "type": "http", |
| 44 | + "url": "http://127.0.0.1:24100/mcp" |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +### Custom Port |
| 51 | + |
| 52 | +The default port is `24100`. Override it with the `--port` flag or the `MCP_HARNESS_PORT` environment variable: |
| 53 | + |
| 54 | +```bash |
| 55 | +node dist/mcp-harness/index.mjs --http --port 3456 |
| 56 | + |
| 57 | +# Or via environment variable |
| 58 | +MCP_HARNESS_PORT=3456 node dist/mcp-harness/index.mjs --http |
| 59 | +``` |
| 60 | + |
| 61 | +### Verifying the Connection |
| 62 | + |
| 63 | +After starting the server and configuring Claude Code, verify the connection: |
| 64 | + |
| 65 | +```bash |
| 66 | +claude mcp list |
| 67 | +``` |
| 68 | + |
| 69 | +The output should show `tui-harness` with a connected status. |
| 70 | + |
| 71 | +### Note on Stdio Mode |
| 72 | + |
| 73 | +Stdio transport is still supported for backward compatibility. However, PTY process spawning will not work inside Claude |
| 74 | +Code's sandbox -- `tui_launch` calls will fail with a spawn error. Stdio mode is useful for automated test pipelines |
| 75 | +where the test runner directly communicates with the server and no sandbox restrictions apply. |
| 76 | + |
6 | 77 | ## Getting Started |
7 | 78 |
|
8 | 79 | 1. Run `npm run build:harness` to compile both the CLI and the MCP harness binary. The harness is dev-only tooling and |
|
0 commit comments