Skip to content

fix(mcp): reconnect Streamable HTTP after MCP server restart - #12270

Closed
schuellerf wants to merge 3 commits into
langflow-ai:release-1.9.0from
schuellerf:release-1.9.0_stable_mcp
Closed

fix(mcp): reconnect Streamable HTTP after MCP server restart#12270
schuellerf wants to merge 3 commits into
langflow-ai:release-1.9.0from
schuellerf:release-1.9.0_stable_mcp

Conversation

@schuellerf

Copy link
Copy Markdown
Contributor

…without bogus SSE fallback

When the remote MCP process restarts, Langflow kept a stale ClientSession: tool list updates could fail with "Session terminated", the session health check could re-raise instead of discarding the session, and any Streamable HTTP failure triggered SSE fallback and could lock transport preference to SSE—masking the real issue and producing misleading TaskGroup/dual-transport errors.

This invalidates all sessions for the server URL on list_tools failure, treat any health-check failure as a dead session, retry transient Streamable HTTP errors before considering SSE, only fall back to SSE for clear transport-mismatch signals (e.g. 404/405/406), reset and re-record transport preference accordingly, and bust sessions on run_tool using the same termination/connection signals.

Add unit tests with mocked streamablehttp_client and sse_client.

Please check if this makes sense and if we should do those retries…

…without bogus SSE fallback

When the remote MCP process restarts, Langflow kept a stale ClientSession:
tool list updates could fail with "Session terminated", the session
health check could re-raise instead of discarding the session, and
any Streamable HTTP failure triggered SSE fallback and could lock
transport preference to SSE—masking the real issue and producing
misleading TaskGroup/dual-transport errors.

Invalidate all sessions for the server URL on list_tools failure,
treat any health-check failure as a dead session, retry transient
Streamable HTTP errors before considering SSE, only fall back to
SSE for clear transport-mismatch signals (e.g. 404/405/406),
reset and re-record transport preference accordingly, and bust
sessions on run_tool using the same termination/connection signals.

Add unit tests with mocked streamablehttp_client and sse_client.
@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7d7ede57-52bb-42e4-bae5-39482b00e648

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added community Pull Request from an external contributor bug Something isn't working labels Mar 20, 2026
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Mar 29, 2026
@schuellerf

Copy link
Copy Markdown
Contributor Author

This PR is too late for 1.9.0, I guess, but will be part of 1.10.0 (see #12777 )
ping me if I should backport this to 1.9.x …

@schuellerf schuellerf closed this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working community Pull Request from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant