Skip to content

binding-mcp: implement mcp · client binding #1670

Closed

Description

@jfallows

Summary

Implement the mcp · client binding (in the same binding-mcp module). Accepts mcp streams and produces http, ws, or sse streams to upstream MCP servers.

Stream type

  • Accepts: mcp
  • Produces: http / ws / sse

Responsibilities

  • Maintains persistent connection to upstream MCP servers
  • Forwards tools/list, resources/list, and prompts/list upstream; refreshes on change notification
  • Handles upstream MCP wire protocol (HTTP, WebSocket, or SSE)
  • authorization options declare how to inject exchanged credentials as headers — consistent with the mqtt · client pattern
  • Route with block sets :scheme, :authority, and :path headers on the produced http stream
  • No toolkit awareness — toolkit handling is fully owned by mcp · proxy upstream

Configuration

mcp_client_github0:
  type: mcp
  kind: client
  options:
    authorization:
      oauth_github0:
        credentials:
          headers:
            authorization: Bearer {credentials}
  routes:
    - exit: sys:http_client
      with:
        headers:
          ":scheme": https
          ":authority": mcp.github.com
          ":path": /mcp

Callback stream handling

When a callback mcp stream arrives (OAuth authorization code callback from the browser):

  1. Validates the nonce from the OAuth state parameter using store.getAndDelete — atomic, prevents replay, multi-replica safe
  2. Signals the referenced guard to exchange the authorization code for an access token
  3. Guard writes the token to the store keyed by (user, audience, scope)
  4. Returns an HTTP success page to the user's browser

Notes

  • The destination host and port are not statically configured — they are derived from :authority in the HttpBeginEx produced by this binding (see binding-http: derive ProxyBeginEx from :authority)
  • A single sys:http_client instance can serve all mcp_client exits; each stream is independently routed to its correct upstream

Additional Context

MCP Specification
MCP URL Elicitation Required

Metadata

Metadata

Assignees

Labels

enhancement

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions