From a7c83a14e20109d77f679aaa73497e9aa0813789 Mon Sep 17 00:00:00 2001 From: yucheng Date: Thu, 24 Sep 2026 09:24:27 +0000 Subject: [PATCH] refactor: type the MCP credentials validators and drop stray whitespace (LIT-8429) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/_types.py | 4 ++-- litellm/proxy/auth/jwt_algorithms.py | 3 ++- tests/test_litellm/types/test_mcp.py | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 036dcb01759..fdf58e50ede 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -1586,7 +1586,7 @@ class NewMCPServerRequest(LiteLLMPydanticObjectBase): @field_validator("credentials") @classmethod - def check_client_assertion_signing_alg(cls, credentials): + def check_client_assertion_signing_alg(cls, credentials: MCPCredentials | None) -> MCPCredentials | None: return _validated_client_assertion_signing_alg(credentials) @model_validator(mode="before") @@ -1690,7 +1690,7 @@ class UpdateMCPServerRequest(LiteLLMPydanticObjectBase): @field_validator("credentials") @classmethod - def check_client_assertion_signing_alg(cls, credentials): + def check_client_assertion_signing_alg(cls, credentials: MCPCredentials | None) -> MCPCredentials | None: return _validated_client_assertion_signing_alg(credentials) @model_validator(mode="before") diff --git a/litellm/proxy/auth/jwt_algorithms.py b/litellm/proxy/auth/jwt_algorithms.py index a3f7ec0c4f9..0e1839ec200 100644 --- a/litellm/proxy/auth/jwt_algorithms.py +++ b/litellm/proxy/auth/jwt_algorithms.py @@ -20,7 +20,8 @@ def allowed_jwt_algorithms(fips_mode: bool) -> tuple[str, ...]: def jwks_keys_for( keys: Sequence[Mapping[str, object]], algorithms: Collection[str] ) -> tuple[Mapping[str, object], ...]: - """Keep keys whose declared alg is allowed; keys without alg are kept only when their kty can sign with an allowed algorithm.""" + """Keep keys whose declared alg is allowed; keys without alg are kept only when their kty can sign with an + allowed algorithm.""" return tuple(key for key in keys if _key_allowed(key, frozenset(algorithms))) diff --git a/tests/test_litellm/types/test_mcp.py b/tests/test_litellm/types/test_mcp.py index e714f89be03..5450ec4aa48 100644 --- a/tests/test_litellm/types/test_mcp.py +++ b/tests/test_litellm/types/test_mcp.py @@ -85,4 +85,3 @@ async def test_the_hook_drops_the_slot_only_once_the_origin_changes() -> None: foreign = httpx.Request("GET", "https://attacker.example.com/x", headers={"esb-oauth": "Bearer x"}) await hook(foreign) assert "esb-oauth" not in foreign.headers -