From 1f5130073d98a3f28a5e6706068d05e8d82c86dc Mon Sep 17 00:00:00 2001 From: Tin Chi Lo Date: Wed, 17 Jun 2026 15:43:50 -0700 Subject: [PATCH] refactor(mcp): relocate the v2 gateway to litellm/proxy/gateway/mcp Moves the clean-room gateway package out of litellm/proxy/_experimental/mcp_server/v2 into its final home litellm/proxy/gateway/mcp (the folder graduation the migration plan had slated for Phase 2, pulled forward so all further work lands at the final path with no later import churn). Sitting outside _experimental/mcp_server also sharpens the clean-room boundary: the gateway no longer nests under the v1 MCP code it must not import. Pure relocation, no behavior change: git-tracked renames preserve history; relative imports are unaffected; the test's absolute imports, the README's basedpyright command, and the pyrightconfig venvPath depth are updated for the new location. Tests move to tests/mcp_tests/gateway. black, ruff, basedpyright strict, and the 16 resolver tests all pass at the new path. --- litellm/proxy/gateway/__init__.py | 5 +++++ .../mcp_server/v2 => gateway/mcp}/README.md | 2 +- .../mcp_server/v2 => gateway/mcp}/__init__.py | 0 .../v2 => gateway/mcp}/_spike_exhaustiveness.py | 0 .../mcp_server/v2 => gateway/mcp}/oauth/__init__.py | 0 .../mcp_server/v2 => gateway/mcp}/oauth/httpx_auth.py | 0 .../mcp_server/v2 => gateway/mcp}/oauth/types.py | 0 .../v2 => gateway/mcp}/oauth/upstream_credentials.py | 0 .../mcp_server/v2 => gateway/mcp}/pyrightconfig.json | 2 +- .../mcp_server/v2 => gateway/mcp}/result.py | 0 .../{v2 => gateway}/test_upstream_credentials.py | 8 ++++---- 11 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 litellm/proxy/gateway/__init__.py rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/README.md (97%) rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/__init__.py (100%) rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/_spike_exhaustiveness.py (100%) rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/oauth/__init__.py (100%) rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/oauth/httpx_auth.py (100%) rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/oauth/types.py (100%) rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/oauth/upstream_credentials.py (100%) rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/pyrightconfig.json (86%) rename litellm/proxy/{_experimental/mcp_server/v2 => gateway/mcp}/result.py (100%) rename tests/mcp_tests/{v2 => gateway}/test_upstream_credentials.py (93%) diff --git a/litellm/proxy/gateway/__init__.py b/litellm/proxy/gateway/__init__.py new file mode 100644 index 00000000000..d85d81c0a6a --- /dev/null +++ b/litellm/proxy/gateway/__init__.py @@ -0,0 +1,5 @@ +"""LiteLLM MCP Gateway — the clean-room v2 gateway, grafted into v1 behind a flag. + +Written v2-native; nothing here imports from v1 (`litellm.proxy._experimental.mcp_server.*`). +v1 only ever reaches this package through a thin adapter, never the other way round. +""" diff --git a/litellm/proxy/_experimental/mcp_server/v2/README.md b/litellm/proxy/gateway/mcp/README.md similarity index 97% rename from litellm/proxy/_experimental/mcp_server/v2/README.md rename to litellm/proxy/gateway/mcp/README.md index 0874c02541c..0a2d09e2e7c 100644 --- a/litellm/proxy/_experimental/mcp_server/v2/README.md +++ b/litellm/proxy/gateway/mcp/README.md @@ -41,7 +41,7 @@ error. That is the property we want, so the gate is load-bearing rather than dec Run the gate (passes clean, 0 errors): ``` -basedpyright --project litellm/proxy/_experimental/mcp_server/v2/pyrightconfig.json +basedpyright --project litellm/proxy/gateway/mcp/pyrightconfig.json ``` Now prove the gate actually bites. Delete any one arm from `label_enum` in diff --git a/litellm/proxy/_experimental/mcp_server/v2/__init__.py b/litellm/proxy/gateway/mcp/__init__.py similarity index 100% rename from litellm/proxy/_experimental/mcp_server/v2/__init__.py rename to litellm/proxy/gateway/mcp/__init__.py diff --git a/litellm/proxy/_experimental/mcp_server/v2/_spike_exhaustiveness.py b/litellm/proxy/gateway/mcp/_spike_exhaustiveness.py similarity index 100% rename from litellm/proxy/_experimental/mcp_server/v2/_spike_exhaustiveness.py rename to litellm/proxy/gateway/mcp/_spike_exhaustiveness.py diff --git a/litellm/proxy/_experimental/mcp_server/v2/oauth/__init__.py b/litellm/proxy/gateway/mcp/oauth/__init__.py similarity index 100% rename from litellm/proxy/_experimental/mcp_server/v2/oauth/__init__.py rename to litellm/proxy/gateway/mcp/oauth/__init__.py diff --git a/litellm/proxy/_experimental/mcp_server/v2/oauth/httpx_auth.py b/litellm/proxy/gateway/mcp/oauth/httpx_auth.py similarity index 100% rename from litellm/proxy/_experimental/mcp_server/v2/oauth/httpx_auth.py rename to litellm/proxy/gateway/mcp/oauth/httpx_auth.py diff --git a/litellm/proxy/_experimental/mcp_server/v2/oauth/types.py b/litellm/proxy/gateway/mcp/oauth/types.py similarity index 100% rename from litellm/proxy/_experimental/mcp_server/v2/oauth/types.py rename to litellm/proxy/gateway/mcp/oauth/types.py diff --git a/litellm/proxy/_experimental/mcp_server/v2/oauth/upstream_credentials.py b/litellm/proxy/gateway/mcp/oauth/upstream_credentials.py similarity index 100% rename from litellm/proxy/_experimental/mcp_server/v2/oauth/upstream_credentials.py rename to litellm/proxy/gateway/mcp/oauth/upstream_credentials.py diff --git a/litellm/proxy/_experimental/mcp_server/v2/pyrightconfig.json b/litellm/proxy/gateway/mcp/pyrightconfig.json similarity index 86% rename from litellm/proxy/_experimental/mcp_server/v2/pyrightconfig.json rename to litellm/proxy/gateway/mcp/pyrightconfig.json index 6ad94a4ab1b..ca075d1be85 100644 --- a/litellm/proxy/_experimental/mcp_server/v2/pyrightconfig.json +++ b/litellm/proxy/gateway/mcp/pyrightconfig.json @@ -2,7 +2,7 @@ "include": ["."], "typeCheckingMode": "strict", "pythonVersion": "3.10", - "venvPath": "../../../../..", + "venvPath": "../../../..", "venv": ".venv", "reportMissingTypeStubs": false, "reportUnknownMemberType": true, diff --git a/litellm/proxy/_experimental/mcp_server/v2/result.py b/litellm/proxy/gateway/mcp/result.py similarity index 100% rename from litellm/proxy/_experimental/mcp_server/v2/result.py rename to litellm/proxy/gateway/mcp/result.py diff --git a/tests/mcp_tests/v2/test_upstream_credentials.py b/tests/mcp_tests/gateway/test_upstream_credentials.py similarity index 93% rename from tests/mcp_tests/v2/test_upstream_credentials.py rename to tests/mcp_tests/gateway/test_upstream_credentials.py index 0824fc1961b..5170c9b971e 100644 --- a/tests/mcp_tests/v2/test_upstream_credentials.py +++ b/tests/mcp_tests/gateway/test_upstream_credentials.py @@ -8,11 +8,11 @@ import httpx import pytest from pydantic import ValidationError -from litellm.proxy._experimental.mcp_server.v2.oauth.httpx_auth import ( +from litellm.proxy.gateway.mcp.oauth.httpx_auth import ( NoOpAuth, StaticHeaderAuth, ) -from litellm.proxy._experimental.mcp_server.v2.oauth.types import ( +from litellm.proxy.gateway.mcp.oauth.types import ( ApiKeyConfig, AuthSpecKind, NoneConfig, @@ -20,10 +20,10 @@ from litellm.proxy._experimental.mcp_server.v2.oauth.types import ( ServerSpec, Subject, ) -from litellm.proxy._experimental.mcp_server.v2.oauth.upstream_credentials import ( +from litellm.proxy.gateway.mcp.oauth.upstream_credentials import ( UpstreamCredentialProvider, ) -from litellm.proxy._experimental.mcp_server.v2.result import Error, Ok +from litellm.proxy.gateway.mcp.result import Error, Ok PROVIDER = UpstreamCredentialProvider() SUBJECT = Subject(tenant_id="t1", subject_id="u1")