From 6c06e6dc80fd7a2870a3f6fef57a8d651de1a82b Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Thu, 19 Mar 2026 22:57:27 -0700 Subject: [PATCH] fix: link new object_permission_id back to team on first MCP server create When a team has no object_permission_id yet, the auto-assign logic creates an ObjectPermissionTable row but never linked it to the team. Now updates the team's object_permission_id after creation. Co-Authored-By: Claude Opus 4.6 --- .../management_endpoints/mcp_management_endpoints.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/management_endpoints/mcp_management_endpoints.py b/litellm/proxy/management_endpoints/mcp_management_endpoints.py index 3400f90f489..522a533d43f 100644 --- a/litellm/proxy/management_endpoints/mcp_management_endpoints.py +++ b/litellm/proxy/management_endpoints/mcp_management_endpoints.py @@ -1358,7 +1358,7 @@ if MCP_AVAILABLE: set(existing_mcp_servers + [new_mcp_server.server_id]) ) - await handle_update_object_permission_common( + new_permission_id = await handle_update_object_permission_common( data_json={ "object_permission": { "mcp_servers": updated_mcp_servers, @@ -1367,6 +1367,13 @@ if MCP_AVAILABLE: existing_object_permission_id=existing_permission_id, prisma_client=prisma_client, ) + + # If the team had no object_permission_id, link the new one + if existing_permission_id is None and new_permission_id is not None: + await prisma_client.db.litellm_teamtable.update( + where={"team_id": manager_team_id}, + data={"object_permission_id": new_permission_id}, + ) except Exception as e: verbose_proxy_logger.exception(f"Error creating mcp server: {str(e)}") raise HTTPException(