feat(mcp-bridge): bridge external MCP tools onto the mesh#42
Open
Lanzelot1 wants to merge 2 commits into
Open
Conversation
A standalone endpoint that connects to an MCP server once and serves its tools to the whole space over the control plane (list/call on the "mcp" service). Coding agents opt in via COTAL_MCP_BRIDGE=1 to get cotal_tools / cotal_tool. Verified by pnpm smoke:mcp-bridge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge remote MCP servers, not just stdio: Streamable HTTP / SSE with static bearer/header auth or full interactive OAuth (cotal mcp-bridge login caches tokens to ~/.cotal/mcp-auth; the daemon refreshes them). Adds a hermetic remote smoke (HTTP+bearer + a fake OAuth/DCR/PKCE server). Also wires the package into the changeset fixed group, README, CLAUDE.md, and release docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
16d9cef to
a4e8543
Compare
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
A new standalone endpoint (
implementations/mcp-bridge) that connects to an MCP server once and offers its tools to the whole mesh as a callable service — instead of each agent wiring up its own MCP servers. The MCP server becomes a lateral peer whose service is "run this tool"; Cotal's existing control plane is the call mechanism. No core-protocol changes.Works with any MCP-compatible server: local stdio, or remote HTTP / SSE, with static bearer/header auth or full interactive OAuth.
How it works
Provider —
McpBridge(src/bridge.ts,src/transport.ts)src/transport.ts):StdioClientTransport,StreamableHTTPClientTransport, orSSEClientTransport.listTools()populates the catalog (multiple servers namespace as<server>.<tool>).manager(CotalEndpoint,consume:false,role: mcp-bridge) andserveControl("mcp", …)with two ops:list(catalog) andcall({tool, arguments}→client.callTool→ result; MCPisError→{ok:false}).OAuth —
src/oauth.tscotal mcp-bridge login --url <server>runs the interactive flow: anode:httploopback callback + browser open; the SDK does discovery (RFC 9728/8414), dynamic client registration, PKCE, and code exchange. Tokens cache to~/.cotal/mcp-auth/<service>/(0600).--oauth) loads cached tokens (SDK auto-refreshes); if none, it throws an actionable error pointing atlogin— no interactive auth from a daemon.Wire path — the control plane (
serveControl/requestControl)req.from.id— the seam a per-caller ACL hooks into). Consumer calls with a 60s timeout.Consumer — coding agents (
connector-core, off by default)COTAL_MCP_BRIDGE=1.cotalToolSpecs()appendscotal_tools(list) +cotal_tool(call) via thinMeshAgenthelpers — two generic tools, no per-tool JSON-Schema→Zod conversion, no renderer changes.CLI
Verification
pnpm typecheck— clean across all projects.pnpm smoke:mcp-bridge(stdio) — discover → list over mesh → call round-trips → unknown rejected. 4/4.pnpm smoke:mcp-bridge:remote(hermetic, no network):logincaches a token, then the daemon runs with--oauthoff it and callsecho. 4/4.Conventions
Added
@cotal-ai/mcp-bridgeto the changesetfixedgroup + a changeset file, and to the README package table, CLAUDE.md Layout, anddocs/release.md.Follow-ups (deferred)
callop (gate by the verifiedreq.from.id).docs/architecture.md+ SPEC.🤖 Generated with Claude Code