Skip to content

Fix stateful MCP tool discovery - #495

Draft
eladrave wants to merge 1 commit into
LiteLLM-Labs:mainfrom
eladrave:codex/fix-mcp-discovery-handshake
Draft

Fix stateful MCP tool discovery#495
eladrave wants to merge 1 commit into
LiteLLM-Labs:mainfrom
eladrave:codex/fix-mcp-discovery-handshake

Conversation

@eladrave

@eladrave eladrave commented Aug 7, 2026

Copy link
Copy Markdown

What changed

  • initialize Streamable HTTP MCP servers before requesting their tools
  • propagate the negotiated MCP protocol and session ID across the initialized notification and tools/list
  • parse both JSON and SSE MCP responses
  • close stateful MCP sessions with a best-effort DELETE
  • preserve caller-provided authentication and static headers across the handshake

Why

The discovery client previously sent tools/list as its first request. Stateful MCP servers correctly rejected that request as Server not initialized, which the gateway surfaced as an HTTP 502. This made otherwise healthy MCP integrations fail during discovery.

Validation

  • regression test verifies initialize -> notifications/initialized -> tools/list -> DELETE
  • regression test covers negotiated protocol headers, session propagation, static authorization headers, and SSE responses
  • cargo fmt --check
  • focused MCP discovery regression test
  • full cargo test suite (140 unit tests plus non-ignored integration tests)
  • cargo clippy --all-targets -- -D warnings
  • live deployment acceptance against a stateful Remote Chrome MCP server returned HTTP 200 with 26 tools

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.

1 participant