Skip to content

Investigate @orpc/mcp McpRegistrar (or Hono MCP adapter) in every-plugin to replace the hand-rolled MCP bridge #673

Open

Description

@elliotBraem

Context

host/src/services/mcp.ts hand-rolls MCP tool generation today:

Proposed direction

@orpc/mcp ships McpRegistrar, which registers every router procedure directly as an MCP tool through the same standard handler as the RPC/OpenAPI handlers:

  • Schema-derived tool inputs (no manual $ref/$defs surgery — the Host /api/mcp silently fails to mount when any operation input has a $ref (e.g. z.json()) #670 bug class disappears), with per-tool overrides via mcp.tool metadata and procedure filter.
  • Proper error mapping: ORPCError → MCP tool execution errors (model-readable JSON).
  • Structured content outputs; Smart Coercion plugin for Date/BigInt inputs.
  • Per-request context via register(server, { context: async ctx => ... }) — likely replaces the AsyncLocalStorage bridge.
  • Interceptors/plugin reuse (timeout, logging; CORS-compression-style HTTP plugins are no-ops, Rethrow unsupported).

Alternative to evaluate: a Hono MCP adapter for the transport side (transport mounting is currently the SDK's WebStandardStreamableHTTPServerTransport wired by hand).

Spike questions

  1. Placement — should this live in every-plugin (plugin runtime consumes/hosts it) instead of host-internal code, so plugin RPC surfaces become MCP tools generically?
  2. Which plugin surfaces — per-plugin MCP (/api/rpc/{plugin}/... → plugin MCP) vs. the composed base API router as today.
  3. SSE/streaming procedures — currently forcibly skipped; does McpRegistrar AsyncIteratorObject progress mapping give us these for free?
  4. Auth flow — map the current buildPluginContext + x-api-key/session middleware into the registrar's context function-of-request; confirm per-request context is evaluated per tool call, not per server.
  5. Version/gate — @orpc/mcp@beta, MCP TS SDK v2 (@modelcontextprotocol/server); check compatibility with the current @orpc pin and the Effect dev toolchain additions.
  6. Teardown — closeMcpServer() / mcpTransport lifecycle must survive the swap (host reload paths call it).

Notes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions