From 320b9d35296f588bc4eb42cbb1c7925085b485c1 Mon Sep 17 00:00:00 2001 From: Chaim Date: Mon, 4 May 2026 06:40:16 +0000 Subject: [PATCH] fix(settings): guard paperclip mcp.json type + sort registrations --- web/mcp_registrations.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/web/mcp_registrations.py b/web/mcp_registrations.py index 30d204c..8ab5ab8 100644 --- a/web/mcp_registrations.py +++ b/web/mcp_registrations.py @@ -60,7 +60,16 @@ def _read_paperclip_registrations() -> list[dict[str, Any]]: instance_dir.name, e, ) continue - for name, cfg in (data.get("mcpServers") or data or {}).items(): + if not isinstance(data, dict): + logger.warning( + "paperclip_mcp_json_unexpected_type: %s type=%s", + instance_dir.name, type(data).__name__, + ) + continue + servers = data.get("mcpServers") or data + if not isinstance(servers, dict): + continue + for name, cfg in servers.items(): if not isinstance(cfg, dict): continue out.append(_normalize(f"Paperclip ({instance_dir.name})", name, cfg)) @@ -87,9 +96,11 @@ def list_registrations() -> dict[str, Any]: "error": "host_path_unavailable", "message": "תיקיית /host לא mounted. ראה runbook להגדרת volumes ב-Coolify.", } + registrations = ( + _read_claude_registrations() + _read_paperclip_registrations() + ) + registrations.sort(key=lambda r: (r["client"], r["server_name"])) return { - "registrations": ( - _read_claude_registrations() + _read_paperclip_registrations() - ), + "registrations": registrations, "error": None, }