From b2501d98a5475b8077326bd3fb92cbc0b74e0e04 Mon Sep 17 00:00:00 2001 From: Adam Outler Date: Mon, 2 Feb 2026 23:08:39 +0100 Subject: [PATCH] fix(mcp): Handle non-JSON responses and correct JSON errors --- server/api_server/mcp_endpoint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/api_server/mcp_endpoint.py b/server/api_server/mcp_endpoint.py index 1aa3ba49..db65ebe3 100644 --- a/server/api_server/mcp_endpoint.py +++ b/server/api_server/mcp_endpoint.py @@ -749,7 +749,8 @@ def _execute_tool(route: Dict[str, Any], args: Dict[str, Any]) -> Dict[str, Any] "type": "text", "text": json.dumps(json_content, indent=2) }) - except json.JSONDecodeError: + except (json.JSONDecodeError, ValueError): + # Fallback for endpoints that return plain text instead of JSON (e.g., /metrics) content.append({ "type": "text", "text": api_response.text