Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(mcp): pass the original receive to the SSE handler when no body was consumed

yassinc085619f2924
diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py
index 1ba20a7aa0c..bfd0587f86b 100644
--- a/litellm/proxy/_experimental/mcp_server/server.py
+++ b/litellm/proxy/_experimental/mcp_server/server.py
@@ -4837,7 +4837,9 @@ if MCP_AVAILABLE:
scope, receive, send, sse_body, _sse_client_ip
):
return
- sse_receive: Final = _replay_consumed_messages(sse_consumed_messages, receive)
+ sse_receive: Final = (
+ _replay_consumed_messages(sse_consumed_messages, receive) if sse_consumed_messages else receive
+ )
async with _gateway_initialize_instructions_request_scope(
user_api_key_auth,