fix(mcp): Handle non-JSON responses and correct JSON errors

This commit is contained in:
Adam Outler
2026-02-02 23:08:39 +01:00
parent 92029badaa
commit b2501d98a5

View File

@@ -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