feat(mcp-server): unified error taxonomy & mapper (MCP Prompt 17)#4021
Open
gilgardosh wants to merge 2 commits into
Open
feat(mcp-server): unified error taxonomy & mapper (MCP Prompt 17)#4021gilgardosh wants to merge 2 commits into
gilgardosh wants to merge 2 commits into
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
gilgardosh
temporarily deployed
to
accounter-fullstack
July 22, 2026 05:52 — with
GitHub Actions
Inactive
gilgardosh
temporarily deployed
to
accounter-fullstack
July 22, 2026 05:52 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
Implements Prompt 17’s unified error taxonomy for the MCP server by centralizing error codes, retryability defaults, and mapping of diverse failure sources into a consistent, business-safe tool error payload.
Changes:
- Added
src/errors/taxonomy.tsdefining the canonical error codes/classes and thetoErrorPayload/toToolErrorResultmapping pipeline. - Refactored tool execution to route validation, authorization, and runtime failures through the taxonomy (including sanitized internal errors).
- Added unit tests for the mapper and updated MCP-server README to document the new error taxonomy and payload shape.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/mcp-server/src/tools/execute.ts | Refactors tool execution to render all failures via the centralized taxonomy helpers and logs only unmapped/internal failures. |
| packages/mcp-server/src/errors/taxonomy.ts | Introduces unified error taxonomy, error base classes, and mapping/rendering helpers for MCP tool error results. |
| packages/mcp-server/src/errors/tests/taxonomy.test.ts | Adds unit coverage for payload building, mapping branches, internal-error detection, and tool-result rendering. |
| packages/mcp-server/README.md | Updates documentation to describe the unified taxonomy and the extended structured error payload fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Centralize all failure handling in one taxonomy (docs/mcp/spec.md §10.2).
- src/errors/taxonomy.ts: 7 machine codes (VALIDATION/AUTHENTICATION/
AUTHORIZATION/UPSTREAM/TIMEOUT/RATE_LIMIT/INTERNAL); McpError base with
ToolInputError and RateLimitError; toErrorPayload maps every source
(McpError, UpstreamError, TokenVerificationError, unknown) into a
business-safe { code, message, correlationId, retryable, issues?,
retryAfterMs? }; unknown errors sanitized to INTERNAL_ERROR (no leaks)
- refactor executeRegisteredTool to build/render errors through the taxonomy;
ToolInputError re-exported from execute for tool handlers
- unit tests for every mapping branch, retryability defaults, sanitization,
and tool-result rendering
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPMszz9gdZFhNjobRm6Ndo
- Drop the unnecessary double-cast on toToolErrorResult's structuredContent (ToolResult.structuredContent is already `unknown`). - Actually exercise the `retryable` override in the errorPayload test: pass `retryable: true` on a normally-non-retryable VALIDATION_ERROR and assert the override wins. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SPMszz9gdZFhNjobRm6Ndo
gilgardosh
force-pushed
the
claude/mcp-prompt-17-error-taxonomy
branch
from
July 22, 2026 12:00
b704dcf to
827b2f6
Compare
gilgardosh
temporarily deployed
to
accounter-fullstack
July 22, 2026 12:00 — with
GitHub Actions
Inactive
gilgardosh
temporarily deployed
to
accounter-fullstack
July 22, 2026 12:00 — with
GitHub Actions
Inactive
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.
Summary
Implements Prompt 17 – Unified error taxonomy and mapper (see
docs/mcp/spec.md§10.2/§10.3). Centralizes allfailure handling in one taxonomy so every error source produces a consistent,
business-safe payload.
Changes
src/errors/taxonomy.tsVALIDATION_ERROR,AUTHENTICATION_ERROR,AUTHORIZATION_ERROR,UPSTREAM_ERROR,TIMEOUT_ERROR,RATE_LIMIT_ERROR,INTERNAL_ERROR.McpErrorbase (+ToolInputError,RateLimitError) andDEFAULT_RETRYABLEper code.toErrorPayload(error, correlationId)maps every source —McpError,UpstreamError,TokenVerificationError, and anything unexpected — into{ code, message, correlationId, retryable, issues?, retryAfterMs? }. Unknown errors become a sanitizedINTERNAL_ERROR(no stack traces / SQL / internal detail).errorPayload(...)builder andtoToolErrorResult(payload)renderer (isError: true).src/tools/execute.ts— refactored to build/render all failures through the taxonomy; the canonicalToolInputErrornow lives in the taxonomy and is re-exported here for tool handlers.isInternalError, and tool-result rendering. 191 tests total.Validation
yarn workspace @accounter/mcp-server test→ 191 passedyarn workspace @accounter/mcp-server lint/typecheck/build→ passNotes
retryableis now always present (spec wants a retryability hint on every error) and the generic internal message is sanitized.AUTHENTICATION_ERRORis available for tool-layer mapping (e.g. aTokenVerificationErrorbubbling up); the transport-level401challenge for unauthenticatedPOST /mcp(Prompt 07) is unchanged.RateLimitError/RATE_LIMIT_ERRORare defined here and consumed by the rate limiter in Prompt 18.🤖 Generated with Claude Code
Generated by Claude Code