Skip to content

Commit f09fe37

Browse files
aidandaly24claude
andcommitted
docs: add HTTP mode section to TUI harness guide
Document the sandbox limitation with stdio transport and how HTTP mode solves it. Include quick start, Claude Code configuration, custom port options, and backward compatibility notes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6132a92 commit f09fe37

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

docs/tui-harness.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,77 @@
33
The TUI harness provides MCP tools for programmatically driving the AgentCore CLI terminal UI. The MCP server lives at
44
`src/mcp-harness/` and the underlying library is at `src/test-utils/tui-harness/`.
55

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+
677
## Getting Started
778

879
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

Comments
 (0)