Repository navigation
feat(agent): tool-mcp runner (stdio + streamable HTTP) (#4291) - #4314
Merged
Merged
Conversation
Contributor
Author
|
Merge queue: #4314 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing |
Calls the one tool bound in the node; tools/list is never used. No client capabilities, server requests refused, messages bounded, results as data. Process and network rules are shared with the cli and rest runners (process.rs, net_policy.rs). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ntial lookup, count empty events, redact structured content (#4291) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4291-mcp-runner
branch
from
November 19, 2026 19:13
5c85528 to
2ef3503
Compare
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #4291: the
tool-mcprunner. It runs after the executor/host (#4310), thetool-clirunner (#4312) and thetool-restrunner (#4313).Agent lane. This touches
packages/agent, which is Michael's lane. The user has explicitly approved this build, and the user's sign-off stands in for Michael's.What it does
McpRunnercalls ONE tool, named in the node (remote_tool_name), on an MCP server over stdio or streamable HTTP.tools/listis never requested. The description and schema the model sees come from the node and are covered by the approval tag. The arguments are checked against the node's closedparameter_schemabefore anything is started or sent.initializesendscapabilities: {}. A server-initiated request (sampling/createMessage,roots/list,elicitation/create, anything) is answered with JSON-RPC error -32601.pingis answered with{}.application/jsonortext/event-streamreply,Mcp-Session-IdandMCP-Protocol-Versioncarried after initialize, and a best-effortDELETEof the session at the end. Versions accepted: 2025-06-18 and 2025-03-26 on both transports, 2024-11-05 on stdio only (its HTTP form was a different transport and is not implemented).timeout_seconds.textcontent is returned (the host fences it as external). image/audio/resource content is replaced by a size note.isErroris a failure.structuredContentis used only when there is no text. Credential values are removed from results AND from error text.notifications/cancelled, then the server is killed (stdio: whole process group; HTTP: session deleted).Reuse (factored, not copied)
Moved out of the two runners without changing behaviour (all their existing tests pass unchanged apart from import paths):
process.rs: the process group guard, private scratch dir, stop/reap, base environment,spawn_isolated, env credential resolution, confirmation notes. Used bytool-cliand the stdio transport.net_policy.rs: address blocklist, resolver, destination rules, pinned client,send_following(per-hop checks, same-origin redirects, no proxy/cookies/compression), HTTP credential resolution/header, credential note. Used bytool-restand the HTTP transport.test_http.rs: the loopback test server shared by the REST and MCP tests.nodespace-run-(wasnodespace-cli-); the cli test was updated.Offering
Every MCP call needs confirmation (no read-only exemption), so like
tool-cli, nothing is offered to the model until confirmation wiring lands. The runner is installed in the daemon's host; a test pinsneeds_confirmation()for MCP, and the host's existing "dispatched or not offered, never inert" test covers the Mcp kind.Tests
38+ new tests with a scripted stdio fake server (python3, unix only) and a loopback HTTP fake. Hostile cases: server-initiated sampling/roots/elicitation request, huge unsolicited tools/list-style message, 10 MB tool result, never-ending notifications, id mismatch (bounded and ignored), non-JSON noise (bounded), 100- and 200-level nested JSON, credential echoed in a result / an error / stderr, server dying mid-call, server ignoring initialize, batch answer, unsupported version, bad session id, redirect to another origin, private address, non-text content type, never-answering HTTP stream.
Mutation batch (26 mutants, each failing at least one test): capabilities advertised, server request answered with a result, ping, unrelated-message bound, id match, version check, noise bound, per-message cap (stdio and HTTP), total cap, isError, result redaction, error scrubbing, cancel, session header, version header, session delete, HTTP version list, SSE event type, auth header, argument cut, bound tool name, argument validation, media note, batch refusal, structured-content rule, session id validation. One survived at first (session id validation) and got its own test; it is killed now.
Review round 1 fixes
error.messageis no longer cut before the credential is removed;scrubsanitizes the whole text and then shortens it. Test: the token at every offset across the cut.tool-clirunner; what is left of the limit bounds the run. Tests with a slow backend for all three, and one that the lookup time counts against the same limit.structuredContentis redacted on its string leaves and keys before it is serialised. Test: a credential containing"and\.validate_argumentsis top-level only: the closed schema is checked at the top level, nested shape is NOT validated, and the MCP server is not trusted with it (stated in the runner header).needs_confirmation()is what gates offering); the host's existing dispatched-or-not-offered test covers the Mcp kind.Content-Typedoes not duplicate the JSON one (the REST credential/Content-Type headers areinserted, so a same-named declared header gives one line; a declared header named like the credential header is refused by the binding).307/308same-origin redirects of the MCP POST are intended (as fortool-rest); the credential goes only to that origin.Mutation checks for the fixes: each killed (error cut, scrub, three credential-timeout moves, flood count, structured redaction, key redaction, argv room, stderr drain, Content-Type append). One timeout-budget mutant hangs the test (it was stopped by the harness timeout rather than failing an assertion).
Known limits
python3, so those tests arecfg(unix).Last-Event-ID) and does not open the optional server-to-client GET stream.max_output_bytesfield).Remaining for #4291: the confirmation wiring, the enable-and-approve command, the tool_whitelist decision, agent fixtures.
🤖 Generated with Claude Code