Skip to content

✨ feat(gateway): tunnel stdio MCP tool calls to the device#15469

Merged
arvinxx merged 1 commit into
canaryfrom
feat/gateway-stdio-mcp-server
Jun 4, 2026
Merged

✨ feat(gateway): tunnel stdio MCP tool calls to the device#15469
arvinxx merged 1 commit into
canaryfrom
feat/gateway-stdio-mcp-server

Conversation

@arvinxx

@arvinxx arvinxx commented Jun 4, 2026

Copy link
Copy Markdown
Member

πŸ’» Change Type

  • ✨ feat

πŸ”— Related Issue

πŸ”€ Description of Change

Stdio MCP servers live on the user's machine, but in gateway (cloud) mode the agent runs server-side. executeMCPTool treated stdio the same as http and called mcpService.callTool, which tries to spawn the stdio binary on the cloud server β€” which has neither the binary nor access to the user's machine. So local MCP tools (e.g. a task calling a local kimi-datasource MCP) always failed.

This adds a dedicated executeMcpCall path that forwards the stdio connection params (command / args / env) to a connected device, which spawns the MCP server and runs the call locally β€” mirroring how local-system tools already tunnel through deviceProxy.

Key points:

  • No device-gateway worker change. It rides the existing /api/device/tool-call relay β€” the gateway forwards toolCall opaquely. The device routes on the presence of toolCall.mcpParams.
  • Server-side only / no regression. When no device is connected the branch is skipped and behavior is unchanged; standalone Electron (no gateway) still spawns in-process.
  • The desktop-side receiver that actually runs the forwarded call lands in a stacked follow-up PR. Until it ships, an online device hits the existing "tool not available on this device, skip" fallback β€” graceful, not a crash.

Changes:

  • device-gateway-client: GatewayMcpStdioParams type; optional toolCall.mcpParams; GatewayHttpClient.executeMcpCall (shares postToolCall with executeToolCall).
  • server/toolExecution: deviceProxy.executeMcpCall; executeMCPTool routes stdio β†’ executeMcpViaDevice when gateway configured + activeDeviceId + userId.

πŸ§ͺ How to Test

  • Tested locally
  • Added/updated tests

bun run type-check clean. New unit tests in device-gateway-client/src/http.test.ts (25 pass) and toolExecution/__tests__/deviceProxy.test.ts (29 pass) cover the new executeMcpCall transport + wrapper.

πŸ“ Additional Information

Stacked PR plan: this is the server (lower) layer. The desktop receiver (gatewayConnectionSrv passthrough of mcpParams + GatewayConnectionCtr β†’ McpCtr.callTool), CLI device parity, and optional tool-visibility gating (hide stdio MCP when no device online) follow in a client-layer PR based on this branch.

πŸ€– 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 Canceled Canceled Jun 4, 2026 10:46am

Request Review

@dosubot dosubot Bot added feature:mcp MCP relative issue feature:tool Tool calling and function execution 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.

Sorry @arvinxx, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.47826% with 52 lines in your changes missing coverage. Please review.
βœ… Project coverage is 70.84%. Comparing base (bab3ff4) to head (f944d42).
⚠️ Report is 2 commits behind head on canary.

Additional details and impacted files
@@             Coverage Diff             @@
##           canary   #15469       +/-   ##
===========================================
- Coverage   89.22%   70.84%   -18.38%     
===========================================
  Files         892     3255     +2363     
  Lines      108146   321101   +212955     
  Branches    10604    28384    +17780     
===========================================
+ Hits        96490   227498   +131008     
- Misses      11474    93421    +81947     
  Partials      182      182               
Flag Coverage Ξ”
app 61.51% <35.80%> (?)
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% <100.00%> (+0.82%) ⬆️
packages/eval-dataset-parser 95.15% <ΓΈ> (ΓΈ)
packages/eval-rubric 76.11% <ΓΈ> (ΓΈ)
packages/fetch-sse 87.28% <ΓΈ> (ΓΈ)
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% <49.58%> (βˆ…)
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-server branch from da7f909 to 6af0271 Compare June 4, 2026 10:18
Stdio MCP servers live on the user's machine, but in gateway (cloud) mode
the agent runs server-side and `executeMCPTool` tried to spawn the stdio
binary on the cloud server β€” which has neither the binary nor access to the
user's machine, so local MCP tools (e.g. tasks calling a local kimi-datasource
MCP) always failed.

Add a dedicated `executeMcpCall` path that forwards the stdio connection
params (command/args/env) to a connected device, which spawns the MCP server
and runs the call locally. It rides the existing `/api/device/tool-call`
relay β€” the gateway forwards `toolCall` opaquely β€” so the device-gateway
worker needs no changes; the device routes on the presence of
`toolCall.mcpParams`.

Server-side only: when no device is connected, behavior is unchanged
(standalone Electron still spawns in-process). The desktop-side receiver that
runs the forwarded call lands in a follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@arvinxx arvinxx force-pushed the feat/gateway-stdio-mcp-server branch from 6af0271 to f944d42 Compare June 4, 2026 10:36
@arvinxx arvinxx merged commit f35f984 into canary Jun 4, 2026
34 of 35 checks passed
@arvinxx arvinxx deleted the feat/gateway-stdio-mcp-server branch June 4, 2026 11:02
arvinxx added a commit that referenced this pull request Jun 10, 2026
# πŸš€ LobeHub Release (20260610)

**Release Date:** June 10, 2026  
**Since v2.2.2:** 131 merged PRs Β· 13 contributors

> This weekly release strengthens agent collaboration across cloud,
desktop, CLI, and workspace flows, with steadier runtime behavior and a
broader foundation for workspace-scoped data.

---

## ✨ Highlights

- **Agent execution across devices** β€” Unifies per-device working
directories, project skill discovery, and sub-agent suspend/resume
behavior across server, QStash, and device RPC flows. (#15543, #15566,
#15481, #15620, #15591)
- **Connector and sandbox platform** β€” Expands connector permissions,
custom OAuth MCP connector onboarding, sandbox provider support, and
user-uploaded file sync into cloud sandbox runs. (#15463, #15546,
#15184, #15550)
- **Desktop and CLI reliability** β€” Fixes desktop cold-start,
auto-update, Windows build, CLI skill discovery, and `lh connect` agent
dispatch paths. (#15547, #15525, #15527, #15562, #15632, #15634)
- **Pages and sharing** β€” Refreshes topic sharing, improves Page Editor
layout behavior, and routes Page Agent tool execution through the
server-side editor path. (#15581, #15556, #15588, #15023, #15610)
- **Model availability and provider updates** β€” Adds user-scoped LobeHub
model availability, Claude Fable 5, Qwen thinking preservation, and
MiniMax M3 updates. (#15590, #15639, #13494, #15376)

---

## πŸ—οΈ Core Product & Architecture

### Agent Runtime & Heterogeneous Agents

- Improves sub-agent lifecycle handling, including async suspend/resume,
queue-mode QStash resume delivery, and blocking nested sub-agent calls.
(#15481, #15620, #15575)
- Stabilizes heterogeneous agent ingestion and streaming with raw stream
dumps, per-turn usage, image forwarding on regenerate, and
duplicate-text fixes. (#15602, #15577, #15592, #15585)
- Adds execution-device and working-directory controls across device
RPC, legacy defaults, and remote-spawned Claude Code sessions. (#15543,
#15566, #15591, #15572)
- Improves runtime diagnostics and compatibility, including Gemini
multimodal output capture, abort stream semantics, and trace quality
analysis. (#15535, #13677, #15508)

---

## πŸ“± Platforms, Integrations & UX

### Connectors, Sandbox & Tools

- Ships API-level connector tool permissions, custom OAuth MCP connector
onboarding, and connector-first runtime execution. (#15463, #15546)
- Adds sandbox provider support, cloud sandbox file sync, and safer
external URL file input handling with SSRF validation. (#15184, #15550,
#12657)
- Improves tool visibility and execution with pinned app-fixed tools,
ANSI output rendering, gateway-tunneled MCP calls, and automatic
headless tool runs. (#15509, #15516, #15469, #15492)

### Desktop, CLI & Web UX

- Restores desktop startup and reload behavior, preserves IPC error
causes, and keeps the tab bar new-tab action visible across routes.
(#15547, #15597, #15638)
- Fixes desktop update and build stability for browser quit guards,
macOS update signing, and Windows Visual Studio detection. (#15525,
#15527, #15562)
- Shows the plan-limit upgrade UI on desktop builds. (#15628)
- Adds the Agent Run delivery checker and fixes CLI device dispatch plus
skill list/search output. (#15489, #15634, #15632)
- Refreshes onboarding, auth source preservation, topic UI states,
referral/Fable campaign copy, and chat-input control bar behavior.
(#15629, #15544, #15573, #15614, #15616, #15617, #15622, #15643)

---

## πŸ”’ Security, Reliability & Rollout Notes

- External URL file input now includes SSRF validation for safer Google
file handling. (#12657)
- Database workspace-scope migrations are part of this release;
self-hosted operators should run the normal migration path before
serving the updated app. (#15446, #15465, #15468, #15472)
- The release branch was re-cut from `canary` and includes the latest
`main` release-version commit so `v2.2.2` is the verified compare base.

---

## πŸ‘₯ Contributors

@ONLY-yours, @sxjeru, @hardy-one, @xujingli, @hezhijie0327, @Coooolfan,
@arvinxx, @tjx666, @Innei, @rivertwilight, @rdmclin2, @cy948,
@AmAzing129

**Full Changelog**:
v2.2.2...release/weekly-20260610-recut-3
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 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant