Repository navigation
Description
What problem would it solve? · 想解決什麼問題?
Harness Relay's own tools (browser, mail, calendar, through the gateway's relay MCP server, #84) reach Grok and the five open agents (OpenCode, Goose, Cline, OpenHands, Pi) in full access only (GATEWAY_FULL_ACCESS_ONLY, PR #87).
Each turn's program (gatewayShim.ts) and its one-turn token are written to data/tmp. Below full access that folder is a protected path: the commands an agent runs (a repository's script, something a page talked it into) must not read the token. Otherwise a command could drive the user's mail or browser without the agent's call ever showing in the chat; read-tier calls run without asking.
Claude Code, Codex and Copilot start their MCP servers outside the sandbox that holds their commands, so the program can read the token and the commands cannot. Grok's own sandbox, and Harness Relay's own sandbox around the open agents, hold the MCP servers they start together with their commands. Opening data/tmp to the program would open it to every command too, and the relay sandbox does not open the gateway's socket either.
Grok 與開源 agent 只有在完全存取時才拿得到 Harness Relay 自己的工具。原因是它們的沙箱把指令和 MCP server 裝在一起:讓工具程式讀得到每一回合的權杖,指令也就讀得到。
What would you like it to do? · 希望它怎麼做?
Give the gateway a second transport: a streamable-HTTP MCP endpoint on 127.0.0.1. The CLI gets the per-turn token only in memory, as a header of the MCP server it is given, never in a file or an environment variable that a command could read.
- Grok: the connection would come from Grok's own process, not from inside its sandbox, so no sandbox opening is needed, if Grok advertises
mcpCapabilities.http(its adapter already checks for it). - The open agents: the whole process runs in the relay sandbox, so that run would need an opening to the gateway's port alone (asked for by each adapter for its own CLI, as
connectPortsis). The token must stay out of the config files an adapter writes:- OpenCode, Goose and OpenHands report
mcpCapabilities.httpin their recorded messages; - Cline reports none, and Pi does not use ACP, so each needs a way of its own or stays full-access only.
- OpenCode, Goose and OpenHands report
- What stays the same:
- the tiers: read runs; act is asked about below full access; send waits in the outbox;
- the token per turn, revoked when the turn ends;
- the connection limits;
- loopback only;
- the same checks as the socket.
Scope, in two steps · 範圍:分兩步
Not every CLI should move. The question for each one is where the token would live once it uses HTTP:
| CLI | How it is given its MCP servers now | Where the token would live over HTTP | Plan |
|---|---|---|---|
| Grok, OpenCode, Goose, OpenHands | ACP session params | Memory only | Step 1 (this issue): today they get no tools below full access |
| Copilot, Cursor, Antigravity, Muse Code | ACP session params | Memory only | Step 2, once step 1 is proven with the real CLIs |
| Codex | app-server thread config (over stdin) | Memory only | Step 2 |
| Claude Code | --mcp-config file |
A file | Stays on the stdio program |
| Cline, Pi | No usable HTTP MCP (none recorded for Cline; Pi's would put the token in an environment variable) | — | Stays full-access only |
Why step 2 is worth it
- No Node.js needed: today every turn starts the program with Node.js. Without one (the desktop app, and on Windows Settings cannot install one), the tools are unavailable (
no-node,no-node-path). A CLI that connects over HTTP needs no program and no Node.js. - Safer on Windows: Windows has no protected paths, so the token sits in a file until the program claims it, and a CLI that restarts its MCP server mid-turn loses the tools (
claimOnce). A token held in memory has neither problem. - One process fewer per turn.
Why Claude Code stays
- Its MCP config is a file, so the token would sit in that file.
- On macOS and Linux the file could live in the protected
data/tmp, which is as safe as today. - On Windows the file would be readable for the whole turn, which is worse than today's token that serves one connection and is deleted at once.
Alternatives you considered · 考慮過的其他做法
- Opening
data/tmpto those sandboxes: this lets every command an agent runs take the token and use the tools unseen. Rejected. - The token in the MCP server's environment: other processes of the same user can read it (
/proc/<pid>/environon Linux), and AGENTS.md rules it out. - Leaving it as it is: full access only, as now.
Checks needed
- Each CLI must be tried for real (live tests): this cannot be checked with the e2e fakes alone.
- Check that a command inside the sandbox cannot reach the token from the CLI's process.
- The endpoint checks Host and Origin like the HTTP API (a web page in the user's own browser can reach 127.0.0.1), and Harness Relay's own browser tool refuses its port, as it refuses the server's.
- Check Windows: the open agents run in full access only there, and Grok has no sandbox.
Area: Tools / skills / memory · 工具/skill/記憶; Agent CLIs.
Activity
Give the open agents Harness Relay's own tools in full access, as Gro…
Give OpenCode and Codex Harness Relay's tools over loopback HTTP, the…
Keep the mail accounts' note on one spacing in Chinese, and add the T…
cyyeh commentedon Nov 17, 2026
Implemented in #87 (e9d21c8, b5a360e), for the CLIs that passed a check with the real CLI · 已在 #87 實作(e9d21c8、b5a360e),只給用真的 CLI 檢查通過的
What is in · 做了什麼
http://127.0.0.1:<port>/mcp, with JSON (initialize,ping,tools/list,tools/call, batches).Authorization: Bearerheader of the MCP server the CLI is given over its stdin (ACP session params, Codex's thread config). No program, no file, no Node.js.POSTof at most 4 MiB, withHost127.0.0.1:<port>orlocalhost:<port>, noOrigin, and a token granted for HTTP. A socket token is unknown on HTTP, and the reverse.tool_timeout_sec), not its 5 minutes.relay_<tool>; its own question about one is answered for the user, as the others' are. So no library server may be namedrelayorrelay_….npx tsx scripts/mcp-headers-check.ts <cli>.GATEWAY_OVER_HTTPonly once it passes.scripts/sandbox-check.tsnow checks that a command in Harness Relay's own sandbox cannot read its agent's memory. On Linux,/proc/<pid>/memis refused in the sandbox, though the same read succeeds outside it (checked on a kernel without Yama; the check reportsptrace_scope; CI's Ubuntu job runs it). Not checked on macOS.Which CLIs · 哪些 CLI
session/newandsession/loadconnectPorts)session/newrefused: "Authentication required"mcp.jsonwhen it resumesTo move another CLI: run the check with it signed in. If it passes, add it to
GATEWAY_OVER_HTTPinsrc/server/gateway.ts. For Grok, the fallback rule already keeps it from getting the stdio program below full access.Tests · 測試
relay_<tool>and the reserved names;Still open · 仍待完成
Generated by Claude Code