From 4e6b9716d79f3f465b5a483ceb60654362b06bef Mon Sep 17 00:00:00 2001 From: Mydd <226531072+mydd7@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:05:58 +0200 Subject: [PATCH] fix(mcp): surface API error field when message is missing --- packages/mcp/src/lib/api.ts | 5 ++++- packages/pi/lib/api.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/mcp/src/lib/api.ts b/packages/mcp/src/lib/api.ts index d8d702399..20c1b226f 100644 --- a/packages/mcp/src/lib/api.ts +++ b/packages/mcp/src/lib/api.ts @@ -22,10 +22,13 @@ const API_TIMEOUT_MS = 60_000; */ async function parseErrorResponse(response: Response, apiKey?: string): Promise { try { - const json = (await response.json()) as { message?: string }; + const json = (await response.json()) as { message?: string; error?: string }; if (json.message) { return json.message; } + if (json.error) { + return json.error; + } } catch { // JSON parsing failed, fall through to default } diff --git a/packages/pi/lib/api.ts b/packages/pi/lib/api.ts index 3dd351fca..1950567c6 100644 --- a/packages/pi/lib/api.ts +++ b/packages/pi/lib/api.ts @@ -14,8 +14,9 @@ function authHeaders(): Record { async function parseErrorResponse(response: Response): Promise { try { - const json = (await response.json()) as { message?: string }; + const json = (await response.json()) as { message?: string; error?: string }; if (json.message) return json.message; + if (json.error) return json.error; } catch { // JSON parsing failed, fall through to status-based message }