Skip to content

feat(server): add client MCP websocket endpoint (experimental) - #57505

Merged
jlongster merged 5 commits into
devfrom
client-mcp-endpoint
Oct 22, 2026
Merged

jlongster merged 5 commits into
devfrom
client-mcp-endpoint

Conversation

@jlongster

@jlongster jlongster commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Stack 4/5, based on client-mcp-helper. Merge in order.

Part of the client MCP stack (experimental): a client (TUI/desktop/web) opens a WebSocket to the server, and the server treats that incoming socket as an internal MCP server scoped to a location. Tool calls carry _meta["ai.opencode/sessionID"] so the client acts on the calling session. MCP has no official WebSocket transport, so this is a custom transport, which the spec allows.

This PR

Adds GET /api/experimental/client-mcp (WebSocket, location-scoped, name validated) and POST /api/experimental/client-mcp/token (single-use browser tickets).

  • Socket → McpSocketClient → Mcp.attach inside the request's location; the attachment lives as long as the socket
  • Header auth or single-use tickets (60s, bound to name/directory/workspace); generalizes the PTY ticket store with pty:/mcp: keys
  • An attach failure closes with 1011
  • Regenerated client

Tests: real routes on a real port (tool appears, calls carry the session ID, a same-name client stacks on top while the earlier socket stays open and calls fall back to it once the newer one closes, removal on close, tickets, bad name, 1011, shutdown with an open socket).

Stack

  1. feat(core): add MCP transport over incoming client sockets #57502 feat(core): add MCP transport over incoming client sockets
  2. feat(core): attach client-hosted MCP servers #57503 feat(core): attach client-hosted MCP servers
  3. feat(client): add connectClientMcp helper for client-hosted MCP tools #57504 feat(client): add connectClientMcp helper for client-hosted MCP tools
    → 4. feat(server): add client MCP websocket endpoint (experimental) #57505 feat(server): add client MCP websocket endpoint (experimental)
  4. feat(tui): expose open_terminal over client MCP (experimental) #57506 feat(tui): expose open_terminal over client MCP (experimental)

@jlongster
jlongster force-pushed the client-mcp-endpoint branch from 999909b to 5c13f0f Compare October 22, 2026 19:39
@jlongster
jlongster force-pushed the client-mcp-endpoint branch from 5c13f0f to 2ed5e8b Compare October 22, 2026 19:39
@jlongster
jlongster merged commit 4a6dace into dev Oct 22, 2026
17 of 19 checks passed
@jlongster
jlongster deleted the client-mcp-endpoint branch October 22, 2026 19:56
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.

1 participant