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(mypy): resolve type errors introduced by MCP user permissions (#21462)
Julio Quinteros Profdcb2ca37dce
diff --git a/litellm/proxy/guardrails/guardrail_hooks/mcp_end_user_permission/__init__.py b/litellm/proxy/guardrails/guardrail_hooks/mcp_end_user_permission/__init__.pyindex 02b38fe04eb..237364f9714 100644--- a/litellm/proxy/guardrails/guardrail_hooks/mcp_end_user_permission/__init__.py+++ b/litellm/proxy/guardrails/guardrail_hooks/mcp_end_user_permission/__init__.py@@ -1,4 +1,4 @@-from typing import TYPE_CHECKING+from typing import TYPE_CHECKING, Any, Dict, castfrom litellm.types.guardrails import SupportedGuardrailIntegrations@@ -14,7 +14,7 @@ def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail"# Default to always-on. Only disable if the user explicitly sets default_on: false.# We check the raw guardrail dict because LitellmParams normalizes None → False,# making it impossible to distinguish "not set" from "explicitly false" via litellm_params.- _raw_default_on = guardrail.get("litellm_params", {}).get("default_on")+ _raw_default_on = cast(Dict[str, Any], guardrail).get("litellm_params", {}).get("default_on")_default_on = False if _raw_default_on is False else True_callback = MCPEndUserPermissionGuardrail(diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.pyindex 609e19b2443..e30614711d4 100644--- a/litellm/responses/litellm_completion_transformation/transformation.py+++ b/litellm/responses/litellm_completion_transformation/transformation.py@@ -1349,7 +1349,7 @@ class LiteLLMCompletionResponsesConfig:result.append(tool) # type: ignorecontinueif tool.get("type") == "function":- fn = tool.get("function") or {}+ fn: Dict[str, Any] = cast(Dict[str, Any], tool.get("function") or {})parameters = dict(fn.get("parameters", {}) or {})if not parameters or "type" not in parameters:parameters["type"] = "object"