Skip to content

feat: MCP client — stdio servers into the tool registry - #77

Merged
ajianaz merged 3 commits into
developfrom
feat/mcp-client2
Sep 12, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/mcp-client2

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

Direction A of #74: --mcp-server name=command [args...] (repeatable, global, behind the mcp feature) connects external MCP servers over stdio via rmcp 3.3 and registers their tools into the normal ToolRegistry. 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)

  • 4 unit tests (config parsing/rejections, Risk::Write contract); full workspace suite green in BOTH profiles; fmt/clippy clean.
  • Live E2E with the release binary: fs server (npx @modelcontextprotocol/server-filesystem) handshake + tools/list (14 tools, ~1s) + a real list_directory call; the model answered MCP-OK 2328 with the correct entry count.
  • CodeCora loop on this diff: 8 rounds, 10 majors raised — all real, all fixed (reactor-wedge timeouts, isError bookkeeping, approved-blind args, sync/reactor budget race, dead-connection eviction, orphaned children, missing size caps, honest scope notes).

Closes #74

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
@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

🔍 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(),
@ajianaz
ajianaz merged commit 0c424bf into develop Sep 12, 2026
14 checks passed
@ajianaz
ajianaz deleted the feat/mcp-client2 branch September 12, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP support: expose tole tools via Model Context Protocol + consume MCP servers

2 participants