feat(mcp): per-agent MCP gateway endpoint (VS-22) #30
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/mcp-gateway-vs-22"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements the per-agent MCP gateway endpoint (VS-22).
POST /agents/{agent_id}/mcp- authenticates the operator session (same cookie as/control.ashx), gates on a newMeshRights::MCP_ACCESSbit, opens aTunnelMode::Mcptunnel to the connected agent viamsg/tunnel, and round-trips a JSON-RPC request over the tunnel as MCP Streamable HTTP. GET / DELETE return 405 (stable shape for future SSE + session teardown)./mcptunnel.ashxagent-side rendezvous - separate from/meshrelay.ashxso MCP framing flows without the legacy'c'rendezvous byte or per-tunnel protocol byte. Stashes use a dedicatedmcp_relaysregistry on AppState.tunnel_mode::MCP = 7lives inmeshcentral-agent-protoso the companion agent-side issue lands against a shared value. The relevant lockstep note is intunnel_mode.rs.mcpsessionopen+ onemcpsessioncloseevent per request via the existingevent_log::recordpath. Outcome string (ok,timeout,agent-closed,agent-disconnected) lands in the message field so admins can grep.v1 scope decisions
Mcp-Session-Idheader is returned but not yet used to correlate calls. Persistent sessions + SSE + per-call audit + consent broker all ride VS-23.TunnelMode::Mcphandler is pending. The integration test stubs it by dialing/mcptunnel.ashxdirectly with a mock agent so the bridge is exercised end-to-end.Test plan
cargo build --workspacecargo clippy --workspace --all-targetscleancargo test --workspaceall pass (incl. the 5 new gateway tests)tools/list, agent's canned response lands back asapplication/json,Mcp-Session-Idheader set, audit log carries open + close events,mcp_relays.len() == 0on completionMCP_ACCESSTunnelMode::McpissueAdds `/agents/{agent_id}/mcp` which authenticates the operator against the existing session store, gates on a new `MeshRights::MCP_ACCESS` bit, asks the connected agent to open a `TunnelMode::Mcp` tunnel via `msg/tunnel`, and bridges Streamable-HTTP JSON-RPC frames over a dedicated `/mcptunnel.ashx` rendezvous. v1 is stateless (one tunnel per POST) and audits open + close via the existing event log. The companion agent-side `TunnelMode::Mcp` handler is still pending; the integration test stubs it by dialing the rendezvous endpoint directly with a mock agent so the bridge is exercised end-to-end. Consent broker, persistent Mcp-Session-Id, server-to-client SSE notifications, and per-call audit ride the VS-23 follow-up. #VS-22 State Done Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>