Skip to content

fix(mcp): thread-safe MCP client across loops; workflow service MCP lifespan#279

Merged
duguwanglong merged 3 commits into
devfrom
feat/mcp-cross-loop-workflow-service-lifespan
May 18, 2026
Merged

fix(mcp): thread-safe MCP client across loops; workflow service MCP lifespan#279
duguwanglong merged 3 commits into
devfrom
feat/mcp-cross-loop-workflow-service-lifespan

Conversation

@xiami762
Copy link
Copy Markdown
Contributor

@xiami762 xiami762 commented May 18, 2026

Summary

  • MCP client: Track the owner event loop and submit commands via run_coroutine_threadsafe when callers run on a different loop, so disconnect and tool calls stay consistent across threads/loops.
  • Workflow service: Add FastAPI lifespan hooks to initialize MCP on startup and shut down the MCP manager on teardown (with tolerant logging on failure).
  • Tests: Add coverage for cross-loop call_tool / disconnect, workflow tool integration, workflow run route (no duplicate MCP init), and service runtime lifespan behavior.

xiami762 and others added 2 commits May 18, 2026 13:03
Route MCP client commands through the owner loop, initialize MCP in the
workflow service lifespan, and add regression tests for cross-loop usage
and route/service behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
…eadiness

Only enqueue disconnect when connected; expose mcp_ready in workflow service
health and return 503 when MCP init fails; add regression tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@xiami762 xiami762 requested a review from duguwanglong May 18, 2026 05:17
Return reconnected/reconnect_error in the update response; bound reconnect
with timeout derived from server config; extend route tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@duguwanglong duguwanglong merged commit 1852411 into dev May 18, 2026
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.

2 participants