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
test(mcp): cover static-prefix issuer discovery
Joshua Valluruf66239a50f7a
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.pyindex 7ecc1313ba3..e08d00f07e1 100644--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py@@ -11234,3 +11234,50 @@ def test_named_resource_discovery_follows_matching_authorization_issuer(authorization = client.get(f"{prefix}/.well-known/oauth-authorization-server/{issuer_path}")assert authorization.status_code == 200assert authorization.json()["issuer"] == resource["authorization_servers"][0]+++def test_static_root_path_authorization_discovery_preserves_issuer(monkeypatch):+ import subprocess+ import sys++ monkeypatch.setenv("SERVER_ROOT_PATH", "/gateway")+ monkeypatch.setenv("PROXY_BASE_URL", "http://testserver/gateway")+ result = subprocess.run(+ [+ sys.executable,+ "-c",+ """+import json+from fastapi import FastAPI+from fastapi.testclient import TestClient+from litellm.proxy._experimental.mcp_server.discoverable_endpoints import router+from litellm.proxy._experimental.mcp_server.mcp_server_manager import global_mcp_server_manager+from litellm.types.mcp import MCPAuth, MCPTransport+from litellm.types.mcp_server.mcp_server_manager import MCPServer++global_mcp_server_manager.registry['example'] = MCPServer(+ server_id='example', name='example', server_name='example', alias='example',+ transport=MCPTransport.http, auth_type=MCPAuth.oauth2,+ authorization_url='https://idp.example.com/authorize', token_url='https://idp.example.com/token',+)+app = FastAPI(root_path='/gateway')+app.include_router(router)+with TestClient(app) as client:+ responses = {+ path: client.get('/.well-known/oauth-authorization-server/gateway/' + path)+ for path in ('mcp/example', 'example/mcp', 'example', 'mcp')+ }+ print(json.dumps({path: {'status': response.status_code, 'body': response.json()}+ for path, response in responses.items()}))+""",+ ],+ capture_output=True,+ text=True,+ check=True,+ timeout=60,+ )+ responses = json.loads(result.stdout)+ for path in ("mcp/example", "example/mcp", "example", "mcp"):+ assert responses[path]["status"] == 200, responses[path]+ assert responses[path]["body"]["issuer"] == f"http://testserver/gateway/{path}"+ assert responses["example/mcp"]["body"]["token_endpoint"] == "http://testserver/gateway/example/token"