From aa0ff9131ea0be71cabbd0a3af3f14e8ee29bb6c Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 26 Dec 2025 16:59:31 +0900 Subject: [PATCH] fix: format --- .../mcp_server/mcp_server_manager.py | 19 ++++++++++++------- .../mcp_management_endpoints.py | 5 +++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py index 1171eef75d..58e9a345dc 100644 --- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py +++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py @@ -11,7 +11,7 @@ import datetime import hashlib import json import re -from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast +from typing import Any, Dict, List, Literal, Optional, Set, Tuple, Union, cast from urllib.parse import urlparse from fastapi import HTTPException @@ -2152,7 +2152,7 @@ class MCPServerManager: last_health_check=datetime.now(), ) - status = "unknown" + status: Literal["healthy", "unhealthy", "unknown"] = "unknown" health_check_error = None # Check if we should skip health check based on auth configuration @@ -2162,7 +2162,11 @@ class MCPServerManager: if server.auth_type == MCPAuth.oauth2: should_skip_health_check = True # Skip if auth_type is not none and authentication_token is missing - elif server.auth_type and server.auth_type != MCPAuth.none and not server.authentication_token: + elif ( + server.auth_type + and server.auth_type != MCPAuth.none + and not server.authentication_token + ): should_skip_health_check = True if not should_skip_health_check: @@ -2178,6 +2182,7 @@ class MCPServerManager: ) try: + async def _noop(session): return "ok" @@ -2192,9 +2197,7 @@ class MCPServerManager: server_name=server.server_name, alias=server.alias, description=( - server.mcp_info.get("description") - if server.mcp_info - else None + server.mcp_info.get("description") if server.mcp_info else None ), url=server.url, transport=server.transport, @@ -2235,7 +2238,9 @@ class MCPServerManager: allowed_server_ids = await self.get_allowed_mcp_servers(user_api_key_auth) # Run health checks concurrently - tasks = [self.health_check_server(server_id) for server_id in allowed_server_ids] + tasks = [ + self.health_check_server(server_id) for server_id in allowed_server_ids + ] results = await asyncio.gather(*tasks) # Filter out None results (servers that were not found) diff --git a/litellm/proxy/management_endpoints/mcp_management_endpoints.py b/litellm/proxy/management_endpoints/mcp_management_endpoints.py index a77c7c8754..59b9659dd8 100644 --- a/litellm/proxy/management_endpoints/mcp_management_endpoints.py +++ b/litellm/proxy/management_endpoints/mcp_management_endpoints.py @@ -296,7 +296,6 @@ if MCP_AVAILABLE: access_groups_list = sorted(list(access_groups)) return {"access_groups": access_groups_list} - ## FastAPI Routes @router.get( "/server", @@ -374,7 +373,9 @@ if MCP_AVAILABLE: server_id ) # Update the server object with health check results - mcp_server.status = health_result.status if health_result.status else "unknown" + mcp_server.status = ( + health_result.status if health_result.status else "unknown" + ) mcp_server.last_health_check = health_result.last_health_check mcp_server.health_check_error = health_result.health_check_error except Exception as e: