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 linting
Ishaan Jaffer54a383879cba
diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.pyindex 92fd54e8775..0087bc05b25 100644--- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py+++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py@@ -11,7 +11,7 @@ import datetimeimport hashlibimport jsonimport re-from typing import Any, Dict, List, Literal, Optional, Set, Tuple, Union, cast, Callable+from typing import Any, Callable, Dict, List, Literal, Optional, Set, Tuple, Union, castfrom urllib.parse import urlparsefrom fastapi import HTTPException@@ -30,7 +30,6 @@ from pydantic import AnyUrlimport litellmfrom litellm._logging import verbose_logger-from litellm.types.utils import CallTypesfrom litellm.exceptions import BlockedPiiEntityError, GuardrailRaisedExceptionfrom litellm.experimental_mcp_client.client import MCPClientfrom litellm.llms.custom_httpx.http_handler import get_async_httpx_client@@ -63,20 +62,26 @@ from litellm.types.mcp_server.mcp_server_manager import (MCPOAuthMetadata,MCPServer,)+from litellm.types.utils import CallTypestry:- from mcp.shared.tool_name_validation import SEP_986_URL, validate_tool_name # type: ignore+ from mcp.shared.tool_name_validation import ( # type: ignore+ SEP_986_URL,+ ToolNameValidationResult,+ validate_tool_name,+ )except ImportError:+ from typing import AnySEP_986_URL = "https://github.com/modelcontextprotocol/protocol/blob/main/proposals/0001-tool-name-validation.md"- def validate_tool_name(name: str):+ def validate_tool_name(name: str) -> Any:from pydantic import BaseModel- class MockResult(BaseModel):+ class ToolNameValidationResult(BaseModel):is_valid: bool = Truewarnings: list = []- return MockResult()+ return ToolNameValidationResult()# Probe includes characters on both sides of the separator to mimic real prefixed tool names.diff --git a/litellm/proxy/management_endpoints/mcp_management_endpoints.py b/litellm/proxy/management_endpoints/mcp_management_endpoints.pyindex 83d7f3fde4c..1e06c1eace4 100644--- a/litellm/proxy/management_endpoints/mcp_management_endpoints.py+++ b/litellm/proxy/management_endpoints/mcp_management_endpoints.py@@ -37,6 +37,8 @@ from litellm._uuid import uuidfrom litellm.constants import LITELLM_PROXY_ADMIN_NAMEfrom litellm.proxy._experimental.mcp_server.utils import (get_server_prefix,+)+from litellm.proxy._experimental.mcp_server.utils import (validate_and_normalize_mcp_server_payload as _base_validate_and_normalize_mcp_server_payload,)@@ -57,17 +59,21 @@ except ImportError as e:if MCP_AVAILABLE:try:- from mcp.shared.tool_name_validation import validate_tool_name # type: ignore+ from mcp.shared.tool_name_validation import ( # type: ignore+ ToolNameValidationResult,+ validate_tool_name,+ )except ImportError:+ from typing import Any- def validate_tool_name(name: str):+ def validate_tool_name(name: str) -> Any:from pydantic import BaseModel- class MockResult(BaseModel):+ class ToolNameValidationResult(BaseModel):is_valid: bool = Truewarnings: list = []- return MockResult()+ return ToolNameValidationResult()from litellm.proxy._experimental.mcp_server.db import (create_mcp_server,@@ -77,9 +83,9 @@ if MCP_AVAILABLE:update_mcp_server,)from litellm.proxy._experimental.mcp_server.discoverable_endpoints import (- get_request_base_url,authorize_with_server,exchange_token_with_server,+ get_request_base_url,register_client_with_server,)from litellm.proxy._experimental.mcp_server.mcp_server_manager import (