From b37ac05f4e2c995b1554ac035b677600ee5d4e15 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Tue, 10 Mar 2026 17:54:27 -0700 Subject: [PATCH] fix(responses-api): use server_name for MCP URL routing, fix test path - Use server_name (not alias) as the URL path segment for MCP server_url; alias is a display name that may differ from the registered proxy route. URL-encode the path to handle names with spaces/special characters. - Fix sys.path.insert in tests to use __file__-relative path so tests pass regardless of which directory pytest is invoked from. --- tests/test_litellm/test_chat_ui_responses_session.py | 3 ++- .../components/playground/llm_calls/responses_api.tsx | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_litellm/test_chat_ui_responses_session.py b/tests/test_litellm/test_chat_ui_responses_session.py index 6ff1f06fa7d..09ef003ebdb 100644 --- a/tests/test_litellm/test_chat_ui_responses_session.py +++ b/tests/test_litellm/test_chat_ui_responses_session.py @@ -12,7 +12,8 @@ import os import sys import unittest.mock as mock -sys.path.insert(0, os.path.abspath("../..")) +# Use __file__ so the import path is correct regardless of the pytest working directory. +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..")) import httpx import pytest diff --git a/ui/litellm-dashboard/src/components/playground/llm_calls/responses_api.tsx b/ui/litellm-dashboard/src/components/playground/llm_calls/responses_api.tsx index 923c613d77b..8b83b4824ed 100644 --- a/ui/litellm-dashboard/src/components/playground/llm_calls/responses_api.tsx +++ b/ui/litellm-dashboard/src/components/playground/llm_calls/responses_api.tsx @@ -105,13 +105,16 @@ export async function makeOpenAIResponsesRequest( // Individual servers selected - create one entry per server selectedMCPServers.forEach((serverId) => { const server = mcpServers?.find((s) => s.server_id === serverId); - const serverName = server?.alias || server?.server_name || serverId; + // Use server_name for URL routing (proxy registers by name, not alias). + const routeName = server?.server_name || serverId; + // Use alias as the human-readable label when available. + const serverLabel = server?.alias || routeName; const allowedTools = mcpServerToolRestrictions?.[serverId] || []; tools.push({ type: "mcp", - server_label: serverName, // unique label per server so tool calls route correctly - server_url: `${proxyBaseUrl}/mcp/${serverName}`, + server_label: serverLabel, // unique human-readable label per server + server_url: `${proxyBaseUrl}/mcp/${encodeURIComponent(routeName)}`, require_approval: "never", ...(allowedTools.length > 0 ? { allowed_tools: allowedTools } : {}), });