test(mcp): add e2e test for stateless StreamableHTTP behavior#22033
test(mcp): add e2e test for stateless StreamableHTTP behavior#22033ishaan-jaff merged 1 commit intoBerriAI:mainfrom
Conversation
Adds TestProxyMcpStatelessBehavior to test_proxy_mcp_e2e.py with a test that verifies two independent MCP clients can connect, initialize, and call tools without sharing session state. This catches the regression from PR BerriAI#19809 where stateless=False broke clients that don't manage mcp-session-id headers. Regression test for BerriAI#20242
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryAdds an end-to-end regression test (
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| tests/mcp_tests/test_proxy_mcp_e2e.py | Adds TestProxyMcpStatelessBehavior class with a single e2e test that verifies two independent MCP clients can connect sequentially without sharing session state. Well-structured, follows existing patterns, no issues found. |
Sequence Diagram
sequenceDiagram
participant Test as Test Runner
participant CA as Client A
participant Proxy as LiteLLM Proxy (stateless)
participant MCP as MCP Math Server (stdio)
participant CB as Client B
Test->>CA: Create Client A
CA->>Proxy: POST /mcp (initialize)
Proxy->>MCP: Forward initialize
MCP-->>Proxy: Initialized
Proxy-->>CA: Initialized (no session ID required)
CA->>Proxy: POST /mcp (call_tool: add(10,20))
Proxy->>MCP: Forward call_tool
MCP-->>Proxy: Result: 30
Proxy-->>CA: Result: 30
CA->>Test: Assert result == "30"
Note over CA: Client A disconnects
Test->>CB: Create Client B (fresh, no shared state)
CB->>Proxy: POST /mcp (initialize)
Proxy->>MCP: Forward initialize
MCP-->>Proxy: Initialized
Proxy-->>CB: Initialized (no session ID required)
CB->>Proxy: POST /mcp (list_tools)
Proxy->>MCP: Forward list_tools
MCP-->>Proxy: Tools list
Proxy-->>CB: Tools list (includes "add")
CB->>Proxy: POST /mcp (call_tool: add(100,200))
Proxy->>MCP: Forward call_tool
MCP-->>Proxy: Result: 300
Proxy-->>CB: Result: 300
CB->>Test: Assert result == "300"
Last reviewed commit: 41af0e7
Review1. Does this PR fix the issue it describes? 2. Has this issue already been solved elsewhere? 3. Are there other PRs addressing the same problem? 4. Are there other issues this potentially closes? ✅ LGTM — test-only PR that adds valuable coverage for MCP stateless behavior. |
Adds TestProxyMcpStatelessBehavior to test_proxy_mcp_e2e.py with a test that verifies two independent MCP clients can connect, initialize, and call tools without sharing session state. This catches the regression from PR #19809 where stateless=False broke clients that don't manage mcp-session-id headers. Regression test for #20242
Adds TestProxyMcpStatelessBehavior to test_proxy_mcp_e2e.py with a test that verifies two independent MCP clients can connect, initialize, and call tools without sharing session state. This catches the regression from PR #19809 where stateless=False broke clients that don't manage mcp-session-id headers.
Regression test for #20242
Relevant issues
Fixes #20242
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
✅ Test
Changes
TestProxyMcpStatelessBehaviorclass totests/mcp_tests/test_proxy_mcp_e2e.pytest_independent_clients_no_shared_session: Two sequential independent MCP clients connect, initialize, list tools, and call tools without sharing any session state. Client A completes and disconnects, then Client B connects fresh — proving stateless mode works correctly.