Skip to content

Commit 86f6d09

Browse files
committed
fix: preserve structured McpError data in request history
When a tool call returns an MCP error (e.g. -32042 URLElicitationRequired), the catch block was only capturing error.message (a string), discarding the structured error.code and error.data fields. Now McpError instances push the full JSON-RPC error structure to history: { error: { code, message, data } } This means the Response panel will show the complete error including data.elicitations for -32042, rather than just a message string.
1 parent 04646d7 commit 86f6d09

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

client/src/lib/hooks/useConnection.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,19 @@ export function useConnection({
259259

260260
pushHistory(requestWithMetadata, response);
261261
} catch (error) {
262-
const errorMessage =
263-
error instanceof Error ? error.message : String(error);
264-
pushHistory(requestWithMetadata, { error: errorMessage });
262+
if (error instanceof McpError) {
263+
pushHistory(requestWithMetadata, {
264+
error: {
265+
code: error.code,
266+
message: error.rpcMessage ?? error.message,
267+
...(error.data !== undefined && { data: error.data }),
268+
},
269+
});
270+
} else {
271+
const errorMessage =
272+
error instanceof Error ? error.message : String(error);
273+
pushHistory(requestWithMetadata, { error: errorMessage });
274+
}
265275
throw error;
266276
}
267277

0 commit comments

Comments
 (0)