fix: handle missing 'env' attribute in MCP server Prisma model (#12560)

- Use getattr() with default value when accessing mcp_server.env
- Prevents AttributeError when Prisma doesn't include the field
- Fixes startup error: 'LiteLLM_MCPServerTable' object has no attribute 'env'

The issue occurs when Prisma fetches records and doesn't include
null/undefined fields in the returned object.
This commit is contained in:
Cole McIntosh
2025-07-12 15:23:12 -07:00
committed by GitHub
parent 65533ccf62
commit 7f5033d8a6
@@ -160,7 +160,9 @@ class MCPServerManager:
_mcp_info: MCPInfo = mcp_server.mcp_info or {}
# Use helper to deserialize environment dictionary
env_dict = _deserialize_env_dict(mcp_server.env)
# Safely access env field which may not exist on Prisma model objects
env_data = getattr(mcp_server, 'env', None)
env_dict = _deserialize_env_dict(env_data)
new_server = MCPServer(
server_id=mcp_server.server_id,