From 700fd86de971f0ca50bafafed129ab17af661f3a Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Fri, 20 Mar 2026 12:13:09 -0700 Subject: [PATCH] Fix importorskip guard and add LiteLLM_TeamTableCachedObj import - Add pytest.importorskip("mcp") at module level so tests skip cleanly in CI environments without the mcp package (instead of ImportError) - Import LiteLLM_TeamTableCachedObj into MCP_AVAILABLE block so type annotations resolve for static analysis and get_type_hints() - Remove string quotes from type annotations now that the import exists Co-Authored-By: Claude Opus 4.6 --- .../proxy/management_endpoints/mcp_management_endpoints.py | 7 ++++--- .../proxy/management_endpoints/test_mcp_manager_role.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/management_endpoints/mcp_management_endpoints.py b/litellm/proxy/management_endpoints/mcp_management_endpoints.py index e137ad15f1b..8c8bd629884 100644 --- a/litellm/proxy/management_endpoints/mcp_management_endpoints.py +++ b/litellm/proxy/management_endpoints/mcp_management_endpoints.py @@ -112,6 +112,7 @@ if MCP_AVAILABLE: ) from litellm.proxy._types import ( LiteLLM_MCPServerTable, + LiteLLM_TeamTableCachedObj, LitellmUserRoles, MakeMCPServersPublicRequest, MCPApprovalStatus, @@ -147,7 +148,7 @@ if MCP_AVAILABLE: user_api_key_dict: UserAPIKeyAuth, team_id: Optional[str] = None, server_id: Optional[str] = None, - ) -> Tuple[str, "LiteLLM_TeamTableCachedObj"]: + ) -> Tuple[str, LiteLLM_TeamTableCachedObj]: """ Verify that the caller is an MCP server manager for a team and (for edit/delete) that the target server belongs to that team. @@ -206,7 +207,7 @@ if MCP_AVAILABLE: async def _auto_assign_mcp_server_to_team( server_id: str, team_id: str, - team_obj: "LiteLLM_TeamTableCachedObj", + team_obj: LiteLLM_TeamTableCachedObj, prisma_client: Any, ) -> None: """ @@ -245,7 +246,7 @@ if MCP_AVAILABLE: async def _remove_mcp_server_from_team( server_id: str, - team_obj: "LiteLLM_TeamTableCachedObj", + team_obj: LiteLLM_TeamTableCachedObj, ) -> None: """Remove a server ID from a team's ObjectPermissionTable.mcp_servers list.""" from litellm.proxy.proxy_server import prisma_client diff --git a/tests/test_litellm/proxy/management_endpoints/test_mcp_manager_role.py b/tests/test_litellm/proxy/management_endpoints/test_mcp_manager_role.py index 36cecde65b9..86b0419fb22 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_mcp_manager_role.py +++ b/tests/test_litellm/proxy/management_endpoints/test_mcp_manager_role.py @@ -1,5 +1,7 @@ import pytest +pytest.importorskip("mcp", reason="mcp package not installed") + from litellm.proxy._types import ( LiteLLM_TeamTable, LitellmUserRoles,