Skip to content

✨ feat(desktop): execute tunneled stdio MCP calls from the gateway#15470

Merged
arvinxx merged 1 commit into
feat/gateway-tunnel-type-discriminatorfrom
feat/gateway-stdio-mcp-desktop
Jun 4, 2026
Merged

✨ feat(desktop): execute tunneled stdio MCP calls from the gateway#15470
arvinxx merged 1 commit into
feat/gateway-tunnel-type-discriminatorfrom
feat/gateway-stdio-mcp-desktop

Conversation

@arvinxx

@arvinxx arvinxx commented Jun 4, 2026

Copy link
Copy Markdown
Member

πŸ’» Change Type

  • ✨ feat

πŸ”— Related Issue

Stacked on #15469 (server side). Base is feat/gateway-stdio-mcp-server, not canary β€” retarget to canary after #15469 merges.

πŸ”€ Description of Change

The receiving half of gateway stdio-MCP support. #15469 makes the cloud server tunnel a stdio MCP tool call to a connected device (a tool_call_request carrying mcpParams); this PR makes the desktop run it.

Previously the device's tool-call handler only knew the builtin local-system switch (keyed on apiName), so any tunneled MCP call hit the "tool not available on this device, skip" fallback. Now:

  • gatewayConnectionSrv: dedicated mcpCallHandler + setMcpCallHandler. handleToolCallRequest routes on the presence of toolCall.mcpParams (otherwise unchanged), sharing the same response-envelope path.
  • GatewayConnectionCtr: wires setMcpCallHandler β†’ executeMcpCall, which maps the wire payload (command/args/env/name) to McpCtr.runStdioMcpTool.
  • McpCtr: extracts runStdioMcpTool core from the callTool IPC method, so the renderer path and the gateway tunnel share one stdio execution path β€” no SuperJSON round-trip for the in-process caller.

The desktop already had full stdio-MCP spawn capability (used by renderer chat); this just connects it to the gateway tunnel.

πŸ§ͺ How to Test

  • Tested locally
  • Added/updated tests

Desktop type-check clean (no new errors in touched files). GatewayConnectionCtr.test.ts extended to 59 tests: routing on mcpParams, success envelope, and error envelope. End-to-end: with the server PR deployed, configure a local stdio MCP, run a Task that calls it from a connected device β€” the call now spawns the MCP locally and returns results.

πŸ“ Additional Information

Follow-ups (not in this PR): CLI device (lh connect) parity for mcp_call, and optional tool-visibility gating (hide stdio MCP from the model when no device is online). Both are non-blocking β€” without them, an offline-device call degrades gracefully (server-side spawn error / graceful skip).

πŸ€– Generated with Claude Code

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 4, 2026
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Jun 4, 2026 12:45pm

Request Review

@dosubot dosubot Bot added feature:mcp MCP relative issue feature:tool Tool calling and function execution platform:desktop Desktop client trigger:build-desktop Trigger Desktop build labels Jun 4, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 70.84%. Comparing base (50360df) to head (ca724ac).

Additional details and impacted files
@@                             Coverage Diff                             @@
##           feat/gateway-tunnel-type-discriminator   #15470       +/-   ##
===========================================================================
- Coverage                                   89.21%   70.84%   -18.37%     
===========================================================================
  Files                                         892     3255     +2363     
  Lines                                      108158   321102   +212944     
  Branches                                    10605    28385    +17780     
===========================================================================
+ Hits                                        96495   227499   +131004     
- Misses                                      11481    93421    +81940     
  Partials                                      182      182               
Flag Coverage Ξ”
app 61.51% <ΓΈ> (?)
database 92.54% <ΓΈ> (ΓΈ)
packages/agent-manager-runtime 49.69% <ΓΈ> (ΓΈ)
packages/agent-runtime 80.48% <ΓΈ> (ΓΈ)
packages/builtin-tool-lobe-agent 18.52% <ΓΈ> (ΓΈ)
packages/context-engine 84.19% <ΓΈ> (ΓΈ)
packages/conversation-flow 91.29% <ΓΈ> (ΓΈ)
packages/device-gateway-client 90.51% <ΓΈ> (ΓΈ)
packages/eval-dataset-parser 95.15% <ΓΈ> (ΓΈ)
packages/eval-rubric 76.11% <ΓΈ> (ΓΈ)
packages/fetch-sse 87.28% <ΓΈ> (+1.71%) ⬆️
packages/file-loaders 87.89% <ΓΈ> (ΓΈ)
packages/memory-user-memory 74.99% <ΓΈ> (ΓΈ)
packages/model-bank 99.99% <ΓΈ> (ΓΈ)
packages/model-runtime 84.51% <ΓΈ> (ΓΈ)
packages/prompts 72.51% <ΓΈ> (ΓΈ)
packages/python-interpreter 92.90% <ΓΈ> (ΓΈ)
packages/ssrf-safe-fetch 0.00% <ΓΈ> (ΓΈ)
packages/types 35.34% <ΓΈ> (ΓΈ)
packages/utils 84.98% <ΓΈ> (ΓΈ)
packages/web-crawler 88.08% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Ξ”
Store 68.53% <ΓΈ> (βˆ…)
Services 54.75% <ΓΈ> (βˆ…)
Server 71.81% <ΓΈ> (βˆ…)
Libs 57.01% <ΓΈ> (βˆ…)
Utils 81.48% <ΓΈ> (-18.52%) ⬇️
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-server branch from 8bffb3c to da7f909 Compare June 4, 2026 10:04
@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-desktop branch from fd027b0 to af4389f Compare June 4, 2026 10:06
@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-server branch from da7f909 to 6af0271 Compare June 4, 2026 10:18
@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-desktop branch from af4389f to 258fa57 Compare June 4, 2026 10:19
@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-server branch from 6af0271 to f944d42 Compare June 4, 2026 10:36
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

πŸš€ Desktop App Build Completed!

Version: 0.0.0-nightly.pr15470.15048
Build Time: 2026-06-04T13:14:05.381Z

πŸ“¦ Release Download Β· πŸ“₯ Actions Artifacts

Build Artifacts

Platform File Size
macOS (Apple Silicon) LobeHub-Nightly-0.0.0-nightly.pr15470.15048-arm64-mac.zip 147.56 MB
macOS (Apple Silicon) LobeHub-Nightly-0.0.0-nightly.pr15470.15048-arm64.dmg 140.39 MB
macOS (Intel) LobeHub-Nightly-0.0.0-nightly.pr15470.15048-mac.zip 156.17 MB
macOS (Intel) LobeHub-Nightly-0.0.0-nightly.pr15470.15048-x64.dmg 147.45 MB
Windows LobeHub-Nightly-0.0.0-nightly.pr15470.15048-setup.exe 134.68 MB
Linux LobeHub-Nightly-0.0.0-nightly.pr15470.15048.AppImage 165.19 MB

Warning

Note: This is a temporary build for testing purposes only.

Base automatically changed from feat/gateway-stdio-mcp-server to canary June 4, 2026 11:02
@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-desktop branch 2 times, most recently from e09d95d to 138f5fc Compare June 4, 2026 11:55
@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-desktop branch from 138f5fc to a421583 Compare June 4, 2026 12:34
@arvinxx arvinxx changed the base branch from canary to feat/gateway-tunnel-type-discriminator June 4, 2026 12:34
@arvinxx arvinxx force-pushed the feat/gateway-tunnel-type-discriminator branch from 2e2b657 to 50360df Compare June 4, 2026 12:37
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>
@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-desktop branch from a421583 to ca724ac Compare June 4, 2026 12:38
@arvinxx arvinxx merged commit e85d011 into feat/gateway-tunnel-type-discriminator Jun 4, 2026
31 of 32 checks passed
@arvinxx arvinxx deleted the feat/gateway-stdio-mcp-desktop branch June 4, 2026 12:57
arvinxx added a commit that referenced this pull request Jun 4, 2026
…ls (#15473)

* ✨ feat(gateway): add explicit type discriminator to tunneled tool calls

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>

* ✨ feat(desktop): execute tunneled stdio MCP calls from the gateway (#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>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:mcp MCP relative issue feature:tool Tool calling and function execution platform:desktop Desktop client size:L This PR changes 100-499 lines, ignoring generated files. trigger:build-desktop Trigger Desktop build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant