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): redact compact credential field names
Joshua Valluru3883a891f080
diff --git a/litellm/proxy/_experimental/mcp_server/mcp_debug.py b/litellm/proxy/_experimental/mcp_server/mcp_debug.pyindex 0ca17d1c336..1f157aefdc3 100644--- a/litellm/proxy/_experimental/mcp_server/mcp_debug.py+++ b/litellm/proxy/_experimental/mcp_server/mcp_debug.py@@ -414,7 +414,10 @@ def safe_upstream_url(url: httpx.URL) -> str:def _sensitive_field(key: str) -> bool:- return key.lower() in ("code", "cookie", "client_assertion") or _LOG_MASKER.is_sensitive_key(key)+ normalized: Final = re.sub(r"[^a-z0-9]", "", key.casefold())+ return normalized in ("code", "clientassertion") or any(+ pattern in normalized for pattern in _LOG_MASKER.sensitive_patterns+ )def _redact_object(diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_debug.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_debug.pyindex 88de9df5d39..b6535e6326a 100644--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_debug.py+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_debug.py@@ -578,3 +578,16 @@ def test_deep_request_omits_response_when_credentials_cannot_be_inspected():assert detail is not None and "HTTP 401" in detailassert "response body: (omitted: request credentials unavailable)" in detailassert "nested-credential" not in detail++[email protected]("field", ["accessToken", "refreshToken", "clientSecret", "apikey", "CLIENTASSERTION", "cost_token"])[email protected]("encoding", ["json", "form"])+def test_compact_credential_fields_and_reflected_values_are_redacted(field, encoding):+ secret = "generic-private-value"+ fields = {field: secret}+ request = httpx.Request("POST", "https://upstream/token", json=fields if encoding == "json" else None,+ data=fields if encoding == "form" else None)+ response = httpx.Response(401, request=request, json={field: secret, "error": "invalid_client", "detail": "Rejected " + secret})+ detail = describe_upstream_http_failure(httpx.HTTPStatusError("failed", request=request, response=response))+ assert detail is not None and "invalid_client" in detail+ assert "REDACTED" in detail and secret not in detail