Skip to content

fix(mcp): backport StreamableHTTPSessionManager stateless fix to v1.81.12-stable#22030

Merged
krrishdholakia merged 1 commit intoBerriAI:litellm_stable_release_1_81_12from
michelligabriele:backport/mcp-stateless-to-1.81.12-stable
Feb 24, 2026
Merged

fix(mcp): backport StreamableHTTPSessionManager stateless fix to v1.81.12-stable#22030
krrishdholakia merged 1 commit intoBerriAI:litellm_stable_release_1_81_12from
michelligabriele:backport/mcp-stateless-to-1.81.12-stable

Conversation

@michelligabriele
Copy link
Collaborator

Cherry-pick of #21323 onto v1.81.12-stable.

Reverts stateless=Falsestateless=True in StreamableHTTPSessionManager and includes a regression test. The original fix was merged to main on Feb 16 but missed the v1.81.12-stable cut.

Fixes #20242

…iAI#21323)

PR BerriAI#19809 changed stateless=True to stateless=False to enable progress
notifications for MCP tool calls. This caused the mcp library to enforce
mcp-session-id headers on all non-initialize requests, breaking MCP
Inspector, curl, and any client without automatic session management.

Revert to stateless=True to restore compatibility with all MCP clients.
The progress notification code already handles missing sessions gracefully
(defensive checks + try/except), so no other changes are needed.

Fixes BerriAI#20242
@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 24, 2026 6:57pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 24, 2026

Greptile Summary

Cherry-pick of #21323 onto v1.81.12-stable. Reverts the stateless=False change introduced by PR #19809 back to stateless=True in StreamableHTTPSessionManager. The stateless=False setting caused the MCP library to enforce mcp-session-id headers on all non-initialize requests, breaking MCP Inspector, curl, and any HTTP client without automatic session management (issue #20242).

  • Reverts stateless=Falsestateless=True in server.py line 152
  • Adds a regression test (test_streamable_http_session_manager_is_stateless) that asserts session_manager.stateless is True
  • Adds @pytest.mark.no_parallel to the adjacent test_mcp_routing_with_conflicting_alias_and_group_name test
  • The progress notification code already handles missing sessions defensively, so no other changes are needed

Confidence Score: 5/5

  • This PR is a minimal, well-scoped one-line fix with a regression test — safe to merge.
  • The change is a single boolean flag revert (stateless=Falsestateless=True) that restores the original behavior. It is a clean cherry-pick of an already-merged fix from main (fix(mcp): revert StreamableHTTPSessionManager to stateless mode #21323). The regression test is mock-only and verifies the fix. No new dependencies, no architectural changes, no risk of side effects.
  • No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/_experimental/mcp_server/server.py One-line change reverting stateless=Falsestateless=True in StreamableHTTPSessionManager constructor. Fixes regression from PR #19809 that broke MCP clients without session management.
tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py Adds a regression test asserting session_manager.stateless is True, plus adds @pytest.mark.no_parallel to an adjacent test. No real network calls — all mock-based.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[MCP Client Request] --> B{stateless flag?}
    B -->|stateless=True| C[Accept request without mcp-session-id]
    B -->|stateless=False| D{Has mcp-session-id header?}
    D -->|Yes| E[Process request]
    D -->|No| F[Reject request ❌]
    C --> E
    E --> G[Return response to client]

    style B fill:#f9f,stroke:#333
    style C fill:#9f9,stroke:#333
    style F fill:#f99,stroke:#333
Loading

Last reviewed commit: 524cf26

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@krrishdholakia krrishdholakia merged commit 7e4e454 into BerriAI:litellm_stable_release_1_81_12 Feb 24, 2026
4 checks passed
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