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(server.py): allow user to specify custom headers to forward to mcp server
Krrish Dholakiac6a7e676f6d8
diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.pyindex 62ad1cc9107..913673f2811 100644--- a/litellm/proxy/_experimental/mcp_server/server.py+++ b/litellm/proxy/_experimental/mcp_server/server.py@@ -414,6 +414,13 @@ if MCP_AVAILABLE:if server.auth_type == MCPAuth.oauth2:extra_headers = oauth2_headers+ if server.forwardable_headers and raw_headers:+ if extra_headers is None:+ extra_headers = {}+ for header in server.forwardable_headers:+ if header in raw_headers:+ extra_headers[header] = raw_headers[header]+# Fall back to deprecated mcp_auth_header if no server-specific header foundif server_auth_header is None:server_auth_header = mcp_auth_headerdiff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yamlindex c50d391e058..533d28395e7 100644--- a/litellm/proxy/_new_secret_config.yaml+++ b/litellm/proxy/_new_secret_config.yaml@@ -25,6 +25,7 @@ mcp_servers:client_id: os.environ/GITHUB_OAUTH_CLIENT_IDclient_secret: os.environ/GITHUB_OAUTH_CLIENT_SECRETscopes: ["public_repo", "user:email"]+ forwardable_headers: ["custom_key"]# allowed_tools: ["list_tools"]# disallowed_tools: ["repo_delete"]