fix(mcp): fix falsy field check; add field-name validation; add take limit; document server-managed fields; close dialog on error

This commit is contained in:
Ishaan Jaffer 2026-03-10 13:55:23 -07:00
parent 31f6568bad
commit 29a7497211
4 changed files with 20 additions and 7 deletions

View file

@ -514,6 +514,7 @@ async def get_mcp_submissions(
rows = await prisma_client.db.litellm_mcpservertable.find_many(
where={"submitted_at": {"not": None}},
order={"submitted_at": "desc"},
take=500, # safety cap; paginate if needed in a future iteration
)
items = [LiteLLM_MCPServerTable(**r.model_dump()) for r in rows]

View file

@ -1124,10 +1124,17 @@ class NewMCPServerRequest(LiteLLMPydanticObjectBase):
byok_description: List[str] = Field(default_factory=list)
byok_api_key_help_url: Optional[str] = None
source_url: Optional[str] = None
# BYOM submission fields (set by endpoint, not by caller)
approval_status: Optional[str] = None
submitted_by: Optional[str] = None
submitted_at: Optional[datetime] = None
# BYOM submission fields — set by the endpoint, not by the caller.
# Any caller-provided values are silently overridden before persistence.
approval_status: Optional[str] = Field(
None, description="Server-managed: set by the endpoint; caller values are overridden."
)
submitted_by: Optional[str] = Field(
None, description="Server-managed: set by the endpoint; caller values are overridden."
)
submitted_at: Optional[datetime] = Field(
None, description="Server-managed: set by the endpoint; caller values are overridden."
)
@model_validator(mode="before")
@classmethod

View file

@ -195,7 +195,10 @@ if MCP_AVAILABLE:
def _field_present(field_name: str) -> bool:
value = getattr(payload, field_name, None)
if not value:
if value is None:
return False
# Treat empty string and empty list as absent (mirrors UI compliance check)
if isinstance(value, (str, list)) and not value:
return False
if field_name == "auth_type" and value == _AUTH_TYPE_SENTINEL:
return False

View file

@ -542,11 +542,12 @@ export function MCPSubmissionsTab({ accessToken }: MCPSubmissionsTabProps) {
if (!accessToken) return;
try {
await approveMCPServer(accessToken, serverId);
setConfirmAction(null);
await fetchData();
NotificationsManager.success(`MCP server "${serverName}" approved`);
} catch {
NotificationsManager.fromBackend("Failed to approve MCP server");
} finally {
setConfirmAction(null);
}
}
@ -554,11 +555,12 @@ export function MCPSubmissionsTab({ accessToken }: MCPSubmissionsTabProps) {
if (!accessToken) return;
try {
await rejectMCPServer(accessToken, serverId, reviewNotes);
setConfirmAction(null);
await fetchData();
NotificationsManager.success(`MCP server "${serverName}" rejected`);
} catch {
NotificationsManager.fromBackend("Failed to reject MCP server");
} finally {
setConfirmAction(null);
}
}