fix(mcp): surface HTTP status and API error details in MCP tool error responses#153
Open
JayDS22 wants to merge 2 commits intoaccordproject:mainfrom
Open
fix(mcp): surface HTTP status and API error details in MCP tool error responses#153JayDS22 wants to merge 2 commits intoaccordproject:mainfrom
JayDS22 wants to merge 2 commits intoaccordproject:mainfrom
Conversation
c4dc499 to
8093333
Compare
added 2 commits
March 28, 2026 12:02
… responses Previously, all MCP tool and resource handlers threw generic error messages like 'Failed to load template' regardless of whether the REST API returned a 400, 404, or 500. MCP clients had no way to distinguish between different failure modes. Added buildApiErrorMessage() helper that captures the HTTP status code and response body from failed API calls. Updated all 8 error paths in mcp.ts to include this context in thrown errors. Signed-off-by: Jay <DELL@MacBook-Air-34.local> Signed-off-by: Jay Guwalani <guwalanijj@gmail.com>
…ilure modes Covers 404, 400, 500, and body-read-failure scenarios. Verifies that different HTTP status codes produce distinct error messages so MCP clients can tell apart a missing resource from a validation error from a server crash. Signed-off-by: Jay <DELL@MacBook-Air-34.local> Signed-off-by: Jay Guwalani <guwalanijj@gmail.com>
8093333 to
d3def87
Compare
|
This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Author
|
@github-actions unstale |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #152
Problem
All MCP tools and resource handlers in
handlers/mcp.tsdiscard the HTTP status code and error body whenmakeApiRequest()returns a non-ok response. Every failure produces a genericthrow new Error('Failed to load ...')regardless of whether the REST API returned 400, 404, or 500. MCP clients receive identical error messages for completely different failure modes.Changes
Added
buildApiErrorMessage()helper that extracts the HTTP status code and response body from failed API responses, producing errors like:Failed to load template 'abc-123' (HTTP 404): {"error": "Template not found"}
instead of:
Failed to load template
Updated all 8 error paths in
mcp.ts:getAgreement()- now includes agreement ID and HTTP statusgetTemplates()- now includes HTTP status and API error bodygetAgreements()- now includes HTTP status and API error bodydraftAgreement()- now includes agreement ID, format, and HTTP statustriggerAgreement()- now includes agreement ID and HTTP statusgetTemplatetool - now includes template ID and HTTP statusgetAgreementtool - now includes agreement ID and HTTP statusAlso improved error logging in the two resource list handlers (agreements and templates) which already returned empty arrays on failure but were logging without status context.
Why This Matters
MCP clients like Claude Desktop and ChatGPT need to distinguish between "this template doesn't exist" (404) and "the server is down" (500) to provide useful feedback to users. This change makes every MCP error actionable.