β¨ feat(gateway): add explicit type discriminator to tunneled tool calls#15473
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The device-gateway relays builtin local-system calls and tunneled stdio MCP calls over one `tool-call` channel. The device was meant to tell them apart by sniffing whether `toolCall.params` exists β fragile: any future builtin tool that grows a `params` field would be misrouted to the MCP client. Add an explicit `toolCall.type` discriminator (`'builtin' | 'mcp'`). The HTTP client stamps it: `executeToolCall` β `'builtin'`, `executeMcpCall` β `'mcp'`. The device routes on `type`, never on payload shape. Optional + back-compatible: an older server that omits it is treated as `'builtin'`. The desktop receiver switches to this discriminator in a follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2e2b657 to
50360df
Compare
β¦15470) Receiving half of the gateway stdio-MCP work. When the cloud server tunnels a stdio MCP tool call to this device (a `tool_call_request` carrying `mcpParams`), run it locally instead of falling through to the builtin local-system tool switch (which keys on apiName and has no MCP context, so it rejected these as "not available on this device"). - `gatewayConnectionSrv`: add a dedicated `mcpCallHandler` + `setMcpCallHandler`; `handleToolCallRequest` routes on the presence of `toolCall.mcpParams`, sharing the existing response-envelope path. - `GatewayConnectionCtr`: wire `setMcpCallHandler` β `executeMcpCall`, which maps the wire payload to `McpCtr.runStdioMcpTool`. - `McpCtr`: extract `runStdioMcpTool` core from the `callTool` IPC method so both the renderer and the gateway tunnel share one stdio execution path (no SuperJSON round-trip for the in-process caller). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 9, 2026
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.
π» Change Type
π Related Issue
Follow-up to #15469 (stdio MCP tunnel). Hardens the device routing before the desktop receiver (#15470) lands.
π Description of Change
The device-gateway relays both builtin local-system calls and tunneled stdio MCP calls over one
tool-callchannel. The device was meant to distinguish them by sniffing whethertoolCall.paramsexists β fragile: any future builtin tool that grows aparamsfield would be misrouted to the MCP client.This adds an explicit
toolCall.typediscriminator ('builtin' | 'mcp'):GatewayHttpClient.executeToolCallstampstype: 'builtin';executeMcpCallstampstype: 'mcp'.type, never on payload shape.typeis treated as'builtin'.paramsremains the MCP payload, but is no longer the routing signal.π§ͺ How to Test
bun run type-checkclean;device-gateway-client25 tests pass (assertstoolCall.type === 'mcp'for MCP calls and'builtin'for builtin calls).π Additional Information
Layering: this is the shared-package/server-contract change and should merge & deploy first. The desktop receiver (#15470) is rebased on top of this branch and switches its routing from
toolCall.paramspresence totoolCall.type === 'mcp'.π€ Generated with Claude Code