From 29f468d60c7e20c8d1dd4a6eeea1661802cbb569 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Mon, 9 Feb 2026 18:32:55 -0800 Subject: [PATCH] fixes greptile --- .../mcp_server/rest_endpoints.py | 2 +- litellm/proxy/proxy_config.yaml | 7 -- tests/mcp_tests/test_oauth2_e2e.sh | 67 ------------------- .../mcp_server/test_rest_endpoints.py | 2 + .../mcp_tools/create_mcp_server.tsx | 2 +- .../src/components/mcp_tools/types.tsx | 1 - .../src/hooks/useTestMCPConnection.tsx | 4 +- 7 files changed, 6 insertions(+), 79 deletions(-) delete mode 100755 tests/mcp_tests/test_oauth2_e2e.sh diff --git a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py index e618e88e454..43b388993d9 100644 --- a/litellm/proxy/_experimental/mcp_server/rest_endpoints.py +++ b/litellm/proxy/_experimental/mcp_server/rest_endpoints.py @@ -595,7 +595,7 @@ if MCP_AVAILABLE: return { "status": "error", "error": True, - "message": f"Failed to connect to MCP server: {e}", + "message": "Failed to connect to MCP server. Check proxy logs for details.", } @router.post("/test/connection", dependencies=[Depends(user_api_key_auth)]) diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml index c6053dd20d3..a094eb84bf3 100644 --- a/litellm/proxy/proxy_config.yaml +++ b/litellm/proxy/proxy_config.yaml @@ -45,13 +45,6 @@ mcp_servers: deepwiki: transport: "http" url: "https://mcp.deepwiki.com/mcp" - test_oauth2_server: - url: "http://localhost:8765/mcp" - transport: "http" - auth_type: "oauth2" - client_id: "test-client" - client_secret: "test-secret" - token_url: "http://localhost:8765/oauth/token" # General Settings diff --git a/tests/mcp_tests/test_oauth2_e2e.sh b/tests/mcp_tests/test_oauth2_e2e.sh deleted file mode 100755 index edeffd93fb7..00000000000 --- a/tests/mcp_tests/test_oauth2_e2e.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash -# E2E test for OAuth2 client_credentials MCP flow -# Usage: bash tests/mcp_tests/test_oauth2_e2e.sh -set -euo pipefail - -MOCK_PORT=8765 -PROXY_PORT=4000 -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -CONFIG="$SCRIPT_DIR/test_oauth2_mcp_config.yaml" -MOCK_SERVER="$SCRIPT_DIR/mock_oauth2_mcp_server.py" - -cleanup() { - echo "" - echo "=== Cleaning up ===" - kill "$MOCK_PID" 2>/dev/null || true - kill "$PROXY_PID" 2>/dev/null || true - wait "$MOCK_PID" 2>/dev/null || true - wait "$PROXY_PID" 2>/dev/null || true - echo "Done." -} -trap cleanup EXIT - -# ── 1. Start mock OAuth2 MCP server ────────────────────────────────────────── -echo "=== Starting mock OAuth2 MCP server on :$MOCK_PORT ===" -python "$MOCK_SERVER" & -MOCK_PID=$! -sleep 2 - -# Quick smoke test on the token endpoint -TOKEN_RESP=$(curl -sf http://localhost:$MOCK_PORT/oauth/token \ - -d "grant_type=client_credentials&client_id=test-client&client_secret=test-secret") -echo "Token endpoint OK: $TOKEN_RESP" - - -# ── 3. List tools ──────────────────────────────────────────────────────────── -echo "" -echo "=== Request 1: List MCP tools ===" -curl -s http://localhost:$PROXY_PORT/mcp-rest/tools/list \ - -H "Authorization: Bearer sk-1234" | python3 -m json.tool - -# ── 4. Call the echo tool ──────────────────────────────────────────────────── -echo "" -echo "=== Request 2: Call echo tool ===" -# Get the server_id from health endpoint -SERVER_ID=$(curl -s http://localhost:$PROXY_PORT/v1/mcp/server/health \ - -H "Authorization: Bearer sk-1234" | python3 -c "import json,sys; print(json.load(sys.stdin)[0]['server_id'])") - -curl -s http://localhost:$PROXY_PORT/mcp-rest/tools/call \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer sk-1234" \ - -d "{\"name\": \"echo\", \"arguments\": {\"message\": \"Hello from OAuth2 client_credentials\"}, \"server_id\": \"$SERVER_ID\"}" | python3 -m json.tool - -# ── 5. Call again (uses cached token) ──────────────────────────────────────── -echo "" -echo "=== Request 3: Call echo again (cached token) ===" -curl -s http://localhost:$PROXY_PORT/mcp-rest/tools/call \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer sk-1234" \ - -d "{\"name\": \"echo\", \"arguments\": {\"message\": \"Second call - token should be cached\"}, \"server_id\": \"$SERVER_ID\"}" | python3 -m json.tool - -# ── 6. Show OAuth2-specific proxy logs ─────────────────────────────────────── -echo "" -echo "=== Proxy OAuth2 logs ===" -grep -E "(Fetching OAuth2|Fetched OAuth2)" /tmp/litellm_oauth2_test.log || echo "(no OAuth2 log lines found)" - -echo "" -echo "=== All requests succeeded ===" diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_rest_endpoints.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_rest_endpoints.py index f86f1e448cb..9c77edc6743 100644 --- a/tests/test_litellm/proxy/_experimental/mcp_server/test_rest_endpoints.py +++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_rest_endpoints.py @@ -305,6 +305,8 @@ class TestExecuteWithMcpClient: assert result["status"] == "error" assert result["error"] is True assert "Failed to connect to MCP server" in result["message"] + # Error message must not leak raw exception details + assert "cancel scope" not in result["message"] class TestTestConnection: diff --git a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx index d5285a5a19d..ff476bd999d 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx @@ -479,7 +479,7 @@ const CreateMCPServer: React.FC = ({ rules={[ { required: false, - message: "Please enter a server description!!!!!!!!!", + message: "Please enter a server description", }, ]} > diff --git a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx index eb70a6695a3..5cb840ec7d4 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx @@ -24,7 +24,6 @@ export const TRANSPORT = { }; export const handleTransport = (transport?: string | null): string => { - console.log(transport); if (transport === null || transport === undefined) { return TRANSPORT.SSE; } diff --git a/ui/litellm-dashboard/src/hooks/useTestMCPConnection.tsx b/ui/litellm-dashboard/src/hooks/useTestMCPConnection.tsx index e5ffc1f1cd9..0cb4288db0e 100644 --- a/ui/litellm-dashboard/src/hooks/useTestMCPConnection.tsx +++ b/ui/litellm-dashboard/src/hooks/useTestMCPConnection.tsx @@ -1,6 +1,6 @@ import { useState, useEffect } from "react"; import { testMCPToolsListRequest } from "../components/networking"; -import { AUTH_TYPE } from "@/components/mcp_tools/types"; +import { AUTH_TYPE, OAUTH_FLOW } from "@/components/mcp_tools/types"; interface MCPServerConfig { server_id?: string; @@ -53,7 +53,7 @@ export const useTestMCPConnection = ({ // Check if we have the minimum required fields to fetch tools const isM2MOAuth = formValues.auth_type === AUTH_TYPE.OAUTH2 - && formValues.oauth_flow_type === "m2m"; + && formValues.oauth_flow_type === OAUTH_FLOW.M2M; const requiresOAuthToken = formValues.auth_type === AUTH_TYPE.OAUTH2 && !isM2MOAuth; const canFetchTools = !!( formValues.url &&