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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(mcp/): pass oauth2 headers on call tools
Krrish Dholakia47ef6a7ee676
diff --git a/litellm/experimental_mcp_client/client.py b/litellm/experimental_mcp_client/client.pyindex d4db9251fc7..2e02f460b65 100644--- a/litellm/experimental_mcp_client/client.py+++ b/litellm/experimental_mcp_client/client.py@@ -117,6 +117,9 @@ class MCPClient:await self._session.initialize()else: # httpheaders = self._get_auth_headers()+ verbose_logger.debug(+ "litellm headers for streamablehttp_client: ", headers+ )self._transport_ctx = streamablehttp_client(url=self.server_url,timeout=timedelta(seconds=self.timeout),diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.pyindex f79d40ca61a..7f161793901 100644--- a/litellm/proxy/_experimental/mcp_server/server.py+++ b/litellm/proxy/_experimental/mcp_server/server.py@@ -270,6 +270,7 @@ if MCP_AVAILABLE:user_api_key_auth=user_api_key_auth,mcp_auth_header=mcp_auth_header,mcp_server_auth_headers=mcp_server_auth_headers,+ oauth2_headers=oauth2_headers,**data, # for logging)except BlockedPiiEntityError as e:@@ -505,6 +506,7 @@ if MCP_AVAILABLE:user_api_key_auth: Optional[UserAPIKeyAuth] = None,mcp_auth_header: Optional[str] = None,mcp_server_auth_headers: Optional[Dict[str, str]] = None,+ oauth2_headers: Optional[Dict[str, str]] = None,**kwargs: Any,) -> List[Union[TextContent, ImageContent, EmbeddedResource]]:"""@@ -552,6 +554,7 @@ if MCP_AVAILABLE:user_api_key_auth=user_api_key_auth,mcp_auth_header=mcp_auth_header,mcp_server_auth_headers=mcp_server_auth_headers,+ oauth2_headers=oauth2_headers,litellm_logging_obj=litellm_logging_obj,)@@ -604,6 +607,7 @@ if MCP_AVAILABLE:user_api_key_auth: Optional[UserAPIKeyAuth] = None,mcp_auth_header: Optional[str] = None,mcp_server_auth_headers: Optional[Dict[str, str]] = None,+ oauth2_headers: Optional[Dict[str, str]] = None,litellm_logging_obj: Optional[Any] = None,) -> List[Union[TextContent, ImageContent, EmbeddedResource]]:"""Handle tool execution for managed server tools"""@@ -616,6 +620,7 @@ if MCP_AVAILABLE:user_api_key_auth=user_api_key_auth,mcp_auth_header=mcp_auth_header,mcp_server_auth_headers=mcp_server_auth_headers,+ oauth2_headers=oauth2_headers,proxy_logging_obj=proxy_logging_obj,)verbose_logger.debug("CALL TOOL RESULT: %s", call_tool_result)