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(main): forward store and prompt_cache_key on the MCP gateway early-return

mateo-berriec35098108eb
diff --git a/litellm/main.py b/litellm/main.py
index f5aa777dc64..cc27da830d8 100644
--- a/litellm/main.py
+++ b/litellm/main.py
@@ -5064,6 +5064,8 @@ def completion(
verbosity=verbosity,
safety_identifier=safety_identifier,
service_tier=service_tier,
+ store=store,
+ prompt_cache_key=prompt_cache_key,
base_url=base_url,
api_version=api_version,
api_key=api_key,
diff --git a/tests/test_litellm/test_main.py b/tests/test_litellm/test_main.py
index aad7fa208de..68b8d1c62b5 100644
--- a/tests/test_litellm/test_main.py
+++ b/tests/test_litellm/test_main.py
@@ -2473,6 +2473,30 @@ def test_completion_omits_store_and_prompt_cache_key_when_not_passed():
assert "prompt_cache_key" not in request_body
+def test_completion_forwards_store_and_prompt_cache_key_to_mcp_gateway():
+ """
+ Regression test for the MCP gateway early-return in completion(): store and
+ prompt_cache_key are named params, so they no longer travel via **kwargs and
+ must be forwarded explicitly like safety_identifier and service_tier.
+ """
+ with patch(
+ "litellm.responses.mcp.chat_completions_handler.acompletion_with_mcp"
+ ) as mock_mcp:
+ result = litellm.completion(
+ model="openai/gpt-4o",
+ messages=[{"role": "user", "content": "Hello"}],
+ tools=[{"type": "mcp", "server_url": "litellm_proxy"}],
+ store=False,
+ prompt_cache_key="test-cache-key",
+ )
+
+ result.close()
+ mock_mcp.assert_called_once()
+ call_kwargs = mock_mcp.call_args.kwargs
+ assert call_kwargs["store"] is False
+ assert call_kwargs["prompt_cache_key"] == "test-cache-key"
+
+
@pytest.mark.asyncio
@pytest.mark.parametrize(
"aws_credential_kwargs",