Skip to content

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]

[Fix] MCP - Ensure internal users can access /mcp and /mcp/ routes (#12106)

Ishaan Jaffe3c9318bd453
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py
index db0959a1d43..d4d852031da 100644
--- a/litellm/proxy/_types.py
+++ b/litellm/proxy/_types.py
@@ -341,7 +341,12 @@ class LiteLLMRoutes(enum.Enum):
anthropic_routes = [
"/v1/messages",
- # MCP routes
+ ]
+
+ mcp_routes = [
+ "/mcp",
+ "/mcp/",
+ "/mcp/{subpath}",
"/mcp/tools",
"/mcp/tools/list",
"/mcp/tools/call",
@@ -365,6 +370,7 @@ class LiteLLMRoutes(enum.Enum):
+ anthropic_routes
+ mapped_pass_through_routes
+ apply_guardrail_routes
+ + mcp_routes
)
info_routes = [
"/key/info",
diff --git a/litellm/proxy/auth/route_checks.py b/litellm/proxy/auth/route_checks.py
index 5fae38cee65..22490919e01 100644
--- a/litellm/proxy/auth/route_checks.py
+++ b/litellm/proxy/auth/route_checks.py
@@ -195,6 +195,12 @@ class RouteChecks:
if route in LiteLLMRoutes.anthropic_routes.value:
return True
+ if RouteChecks.check_route_access(
+ route=route,
+ allowed_routes=LiteLLMRoutes.mcp_routes.value
+ ):
+ return True
+
# fuzzy match routes like "/v1/threads/thread_49EIN5QF32s4mH20M7GFKdlZ"
# Check for routes with placeholders
for openai_route in LiteLLMRoutes.openai_routes.value:
diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml
index 11e90307a22..b31ab0b2724 100644
--- a/litellm/proxy/proxy_config.yaml
+++ b/litellm/proxy/proxy_config.yaml
@@ -8,13 +8,3 @@ mcp_servers:
deepwiki_mcp:
url: "https://mcp.deepwiki.com/mcp"
transport: "http"
-
-general_settings:
- store_model_in_db: true
- store_prompts_in_spend_logs: true
-
-litellm_settings:
- callbacks: ["langfuse", "datadog"]
- cache: True
- cache_params: # set cache params for redis
- type: redis
\ No newline at end of file
diff --git a/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py b/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py
index a4d9eab0ad9..8f758884683 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
@@ -89,6 +89,8 @@ def test_is_llm_api_route():
)
# MCP routes
+ assert RouteChecks.is_llm_api_route("/mcp") is True
+ assert RouteChecks.is_llm_api_route("/mcp/") is True
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