From ec35098108eb31347d54155b5ea4376bd6b91a48 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 18 Aug 2026 13:57:07 -0700 Subject: [PATCH] fix(main): forward store and prompt_cache_key on the MCP gateway early-return --- litellm/main.py | 2 ++ tests/test_litellm/test_main.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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",