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 ensure mcp tools are llm api routes (#10473)
Ishaan Jaffba67ca1f844b
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex ed5a0b1b049..ed80c72dec4 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -324,6 +324,10 @@ class LiteLLMRoutes(enum.Enum):anthropic_routes = ["/v1/messages",+ # MCP routes+ "/mcp/tools",+ "/mcp/tools/list",+ "/mcp/tools/call",]llm_api_routes = openai_routes + anthropic_routes + mapped_pass_through_routes@@ -655,9 +659,9 @@ class GenerateRequestBase(LiteLLMPydanticObjectBase):allowed_cache_controls: Optional[list] = []config: Optional[dict] = {}permissions: Optional[dict] = {}- model_max_budget: Optional[- dict- ] = {} # {"gpt-4": 5.0, "gpt-3.5-turbo": 5.0}, defaults to {}+ model_max_budget: Optional[dict] = (+ {}+ ) # {"gpt-4": 5.0, "gpt-3.5-turbo": 5.0}, defaults to {}model_config = ConfigDict(protected_namespaces=())model_rpm_limit: Optional[dict] = None@@ -919,12 +923,12 @@ class NewCustomerRequest(BudgetNewRequest):alias: Optional[str] = None # human-friendly aliasblocked: bool = False # allow/disallow requests for this end-userbudget_id: Optional[str] = None # give either a budget_id or max_budget- allowed_model_region: Optional[- AllowedModelRegion- ] = None # require all user requests to use models in this specific region- default_model: Optional[- str- ] = None # if no equivalent model in allowed region - default all requests to this model+ allowed_model_region: Optional[AllowedModelRegion] = (+ None # require all user requests to use models in this specific region+ )+ default_model: Optional[str] = (+ None # if no equivalent model in allowed region - default all requests to this model+ )@model_validator(mode="before")@classmethod@@ -946,12 +950,12 @@ class UpdateCustomerRequest(LiteLLMPydanticObjectBase):blocked: bool = False # allow/disallow requests for this end-usermax_budget: Optional[float] = Nonebudget_id: Optional[str] = None # give either a budget_id or max_budget- allowed_model_region: Optional[- AllowedModelRegion- ] = None # require all user requests to use models in this specific region- default_model: Optional[- str- ] = None # if no equivalent model in allowed region - default all requests to this model+ allowed_model_region: Optional[AllowedModelRegion] = (+ None # require all user requests to use models in this specific region+ )+ default_model: Optional[str] = (+ None # if no equivalent model in allowed region - default all requests to this model+ )class DeleteCustomerRequest(LiteLLMPydanticObjectBase):@@ -1087,9 +1091,9 @@ class BlockKeyRequest(LiteLLMPydanticObjectBase):class AddTeamCallback(LiteLLMPydanticObjectBase):callback_name: str- callback_type: Optional[- Literal["success", "failure", "success_and_failure"]- ] = "success_and_failure"+ callback_type: Optional[Literal["success", "failure", "success_and_failure"]] = (+ "success_and_failure"+ )callback_vars: Dict[str, str]@model_validator(mode="before")@@ -1347,9 +1351,9 @@ class ConfigList(LiteLLMPydanticObjectBase):stored_in_db: Optional[bool]field_default_value: Anypremium_field: bool = False- nested_fields: Optional[- List[FieldDetail]- ] = None # For nested dictionary or Pydantic fields+ nested_fields: Optional[List[FieldDetail]] = (+ None # For nested dictionary or Pydantic fields+ )class ConfigGeneralSettings(LiteLLMPydanticObjectBase):@@ -1617,9 +1621,9 @@ class LiteLLM_OrganizationMembershipTable(LiteLLMPydanticObjectBase):budget_id: Optional[str] = Nonecreated_at: datetimeupdated_at: datetime- user: Optional[- Any- ] = None # You might want to replace 'Any' with a more specific type if available+ user: Optional[Any] = (+ None # You might want to replace 'Any' with a more specific type if available+ )litellm_budget_table: Optional[LiteLLM_BudgetTable] = Nonemodel_config = ConfigDict(protected_namespaces=())@@ -2369,9 +2373,9 @@ class TeamModelDeleteRequest(BaseModel):# Organization Member Requestsclass OrganizationMemberAddRequest(OrgMemberAddRequest):organization_id: str- max_budget_in_organization: Optional[- float- ] = None # Users max budget within the organization+ max_budget_in_organization: Optional[float] = (+ None # Users max budget within the organization+ )class OrganizationMemberDeleteRequest(MemberDeleteRequest):@@ -2561,9 +2565,9 @@ class ProviderBudgetResponse(LiteLLMPydanticObjectBase):Maps provider names to their budget configs."""- providers: Dict[- str, ProviderBudgetResponseObject- ] = {} # Dictionary mapping provider names to their budget configurations+ providers: Dict[str, ProviderBudgetResponseObject] = (+ {}+ ) # Dictionary mapping provider names to their budget configurationsclass ProxyStateVariables(TypedDict):@@ -2691,9 +2695,9 @@ class LiteLLM_JWTAuth(LiteLLMPydanticObjectBase):enforce_rbac: bool = Falseroles_jwt_field: Optional[str] = None # v2 on role mappingsrole_mappings: Optional[List[RoleMapping]] = None- object_id_jwt_field: Optional[- str- ] = None # can be either user / team, inferred from the role mapping+ object_id_jwt_field: Optional[str] = (+ None # can be either user / team, inferred from the role mapping+ )scope_mappings: Optional[List[ScopeMapping]] = Noneenforce_scope_based_access: bool = Falseenforce_team_based_model_access: bool = Falsediff --git a/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py b/tests/proxy_admin_ui_tests/test_route_check_unit_tests.pyindex 937eb6f298a..a4d9eab0ad9 100644--- a/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py+++ b/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py@@ -88,6 +88,12 @@ def test_is_llm_api_route():is True)+ # MCP routes+ assert RouteChecks.is_llm_api_route("/mcp/tools") is True+ assert RouteChecks.is_llm_api_route("/mcp/tools/call") is True+ assert RouteChecks.is_llm_api_route("/mcp/tools/list") is True++# check non-matching routesassert RouteChecks.is_llm_api_route("/some/random/route") is Falseassert RouteChecks.is_llm_api_route("/key/regenerate/82akk800000000jjsk") is False