#1143

CLI bridge does not report a local MCP server that dies after mcp.opened; calls burn the 120 s timeout

Openaryanranderiyaopened 3mo ago

Symptom

If the local MCP server process on the device dies after the bridge has already sent mcp.opened for it (crash, OOM, the user kills it), the API-side session never learns. The next tool call sits until MCP_SESSION_CALL_TIMEOUT_SECONDS (120 s) and the user waits two minutes for a "timed out" error instead of an immediate "your <server> server exited".

Where

  • CLI bridge: packages/cli/src/commands/bridge/ — the child-process lifecycle for a spawned MCP server. After MCP_OPENED is sent (constants.ts:13), a child exit/error needs to be turned into an mcp.error frame for that sid (constants.ts:14). Today the frame is only emitted for failures during open.
  • API side already handles it correctly once the frame arrives: apps/api/app/services/mcp/device_connector.py _drain_inbox treats a mid-session mcp.error as a read-stream failure and tears the session down (L153–158). No API change should be needed.

Expected

Child exits → bridge sends {"t":"mcp.error","sid":…,"error":"<server> exited with code N"} → the in-flight call fails immediately with that message, and the session is closed so the next call re-opens (or reports the server as unavailable) instead of reusing a dead one.

Notes

  • Found while profiling tests/integration/real/test_device_bridge_e2e.py on the self-hosted CI box; the diagnosis is from reading the CLI bridge and connector code, not from a reproduced production incident.
  • Regression test: bridge e2e case that kills the spawned server-everything process mid-session and asserts the next call fails fast with the exit message.
  • Related: #1142 (device WebSocket drop leaves sessions hanging) — the transport-level twin of this bug.

Activity

0

No activity yet.