fix(mcp-server): include agent error detail and status in tool errors#1739
fix(mcp-server): include agent error detail and status in tool errors#1739hercemer42 wants to merge 1 commit into
Conversation
Tool error results returned the generic 'Agent responded with HTTP {status}' instead of the
JSON:API errors[0].detail. Route the tool-error catch through parseAgentError and append the
HTTP status when a real detail is present, so the underlying cause reaches all MCP clients.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (2)
🛟 Help
|
|
Claude Opus 4.8 (1M) — code review of #1739 No must-fix. The core fix is correct: the Two preferential edge-case notes inline (both newly reachable via the |

What
MCP tool error results now surface the agent's real error — the JSON:API
errors[0].detailplus the HTTP status (e.g.The value "reason" is required (HTTP 422)) — instead of the genericAgent responded with HTTP {status}.Why
registerToolWithLogging's catch built the{ isError: true }text fromerror.message. For a rawAgentHttpError(e.g.getActionForm) that was the generic string, leaving the real cause buried inerror.body.Changes
error-parser.ts—parseAgentErrorappends(HTTP <status>)to the extracted JSON:API detail; falls back to the raw message (no doubled status) when no detail can be extracted.tool-with-logging.ts— the catch builds the message viaparseAgentError(error), preserving the existing non-Errorfallback (JSON.stringify ?? String).error-parser,tool-with-logging,with-activity-log.Scope / notes
parseAgentError, so the suffix reaches allwithActivityLogdata tools (list/create/update/delete/associate/dissociate/listRelated) andgetActionForm.executeActionis unchanged:agent-clientconverts itsAgentHttpErrorto semanticActionFormValidationError/ActionRequiresApprovalErrorupstream, dropping the status — out of scope.Tests:
test/utils(110) andtest/tools(244) green; eslint / prettier / tsc clean.fixes PRD-729
🤖 Generated with Claude Code
Note
Include HTTP status and JSON:API detail in MCP server tool errors
parseAgentErrorin error-parser.ts to append the HTTP status code to JSON:API error details, returning'<detail> (HTTP <status>)'instead of just'<detail>'.registerToolWithLoggingin tool-with-logging.ts to useparseAgentErrorin its catch block, surfacing structured error details forAgentHttpErrorinstead of a raw stringified error.📊 Macroscope summarized 9caee51. 2 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.