Skip to content

fix: reconnect stale SSE MCP sessions#12437

Open
mturac wants to merge 1 commit into
continuedev:mainfrom
mturac:fix/issue-12431-mcp-sse-reconnect
Open

fix: reconnect stale SSE MCP sessions#12437
mturac wants to merge 1 commit into
continuedev:mainfrom
mturac:fix/issue-12431-mcp-sse-reconnect

Conversation

@mturac
Copy link
Copy Markdown

@mturac mturac commented May 19, 2026

Description

Closes #12431.

This makes SSE MCP tool, prompt, and resource calls recover from stale session or closed transport errors by resetting the client/transport, reconnecting, and retrying the operation once. The reconnect path creates a fresh MCP client so restarted SSE servers do not receive requests with an old session.

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screen recording or screenshot

Not applicable; this is MCP connection recovery behavior.

Tests

  • npm run vitest -- context/mcp/MCPConnection.vitest.ts
  • npm run tsc:check
  • git diff --check

Summary by cubic

Fixes SSE MCP calls that fail after stale or closed sessions by resetting the client/transport, reconnecting, and retrying once. Improves reliability when SSE servers restart or drop connections.

  • Bug Fixes
    • Added an SSE-only reconnect-and-retry wrapper that detects session/transport-closed errors, resets the Client/Transport, calls connectClient(true, ...), then retries once.
    • Wrapped getResource, getPrompt, and callTool; updated MCPManagerSingleton and core/tools/callTool.ts to use these connection methods.
    • Added tests for SSE tool-call retry and to ensure non-SSE calls do not retry.

Written for commit e57c06f. Summary will update on new commits. Review in cubic

@mturac mturac requested a review from a team as a code owner May 19, 2026 10:01
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 19, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

Re-trigger cubic

@mturac mturac force-pushed the fix/issue-12431-mcp-sse-reconnect branch from 4c05a94 to e57c06f Compare May 19, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

(sse) mcp restarts breaks communication

1 participant