Repository navigation
feat: MCP client — stdio servers into the tool registry - #77
Merged
Merged
Conversation
Direction A of #74: tole connects to external MCP servers over stdio and registers their tools into the normal registry. - `mcp` feature gate (off in mobile/embedder profiles); rmcp 3.3 client + child-process transport; dedicated background tokio reactor thread with serialized request handling. - Trust model: every MCP tool registers as Risk::Write regardless of server metadata — the approval gate fires on every call, and the approval prompt now includes the model-controlled arguments (marked when truncated). Server env is scrubbed like every other spawn point (ENV-1); kill_on_drop prevents orphaned server processes. - Wire hygiene: tool results are fenced + scrubbed like native results, capped at 256 KiB with a marked suffix; tool registrations capped at 64/server. - Robustness: reactor-side timeouts on handshake/list/call so one hung server cannot wedge the shared loop; connections evicted on transport failure and on timeout; sync-side budget kept strictly larger than the reactor budget so the reactor's verdict always wins (no abandoned in-flight effects); tool-reported errors (isError) settle as failures without evicting healthy connections. Live E2E (release binary, mcp feature): fs server handshake + 14 tools listed + list_directory call + answer MCP-OK 2328 (matched ls -A /tmp count). Threat model and CHANGELOG updated. Closes #74
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
| let mcp_name = format!("mcp_{}_{}", cfg.name, server_tool); | ||
| if reg | ||
| .register(Box::new(McpTool::new( | ||
| cfg.name.clone(), |
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.
What (description of the change)
Direction A of #74:
--mcp-server name=command [args...](repeatable, global, behind themcpfeature) connects external MCP servers over stdio via rmcp 3.3 and registers their tools into the normalToolRegistry. Trust model baked in: every MCP tool is Risk::Write regardless of server metadata (approval gate always fires; describe() surfaces the model-controlled arguments with marked truncation); server env passes through the same scrub (ENV-1); kill_on_drop prevents orphaned processes; results capped at 256 KiB (marked); tool registrations capped at 64/server; reactor-side timeouts + evict-on-transport-failure + sync-budget strictly greater than reactor budget (no abandoned in-flight effects); isError settles as failure without evicting healthy connections.Why (the problem you're solving)
MCP is the de-facto tool-integration standard and #74's top-priority direction. The trust model is designed in from day one rather than retrofitted.
Testing (how you verified this works)
Closes #74