Harmonize MCP Error Handling Across Tools and HTTP Parsing#73
Merged
Conversation
…eurs HTTP/WFS - Introduit `BaseTool` pour centraliser `createErrorResponse()` et la normalisation des erreurs tool. - Ajoute `src/helpers/errors/` avec `normalizeToolError()` et `zodErrorMapFr` (installée au chargement module). - Refactorise `http.ts` (ordre d’appel, JSDoc, parsing XML/JSON/HTML) et enrichit `ServiceResponseError` (`http` + `service`). - Rend l’extraction d’erreurs JSON plus stricte (listes de champs connues, suppression des clés parasites). - Aligne le moteur WFS sur la nouvelle classe d’erreur (`instanceof ServiceResponseError`) et conserve les diagnostics métier. - Met à jour `docs/mcp-tools.md` avec le contrat d’erreur MCP généré automatiquement. - Exclut `BaseTool` de la génération de docs tools. - Renforce et aligne les tests (HTTP, toolError, BaseTool, WFS), dont les tests WFS sur la vraie `ServiceResponseError`.
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 #35
Overview
This PR introduces a unified error contract for all MCP tools and improves upstream error parsing to make failures more consistent, actionable, and localized (French) across the project.
What Changed
BaseToolclass and moved tool error response creation to a single normalization path.src/helpers/errors/with:toolError.tsfor centralized error classification/normalization (invalid_tool_params,upstream,execution).zodErrorMapFr.tsfor French Zod messages, installed at module load to avoid first-call English messages.src/helpers/http.ts:ServiceResponseErrorshape to nested metadata (http+service).BaseToolso all tool failures share the same MCPstructuredContenterror contract.instanceof ServiceResponseError.BaseToolfrom generated tool docs.docs/mcp-tools.md.docs:mcprun a build first to ensure docs are generated from current compiled tools.toolErrorandBaseToolnormalization.ServiceResponseErrorconstructor/signature.Why
Validation
npm run typecheckpasses.npm testpasses (124tests).Notes
mcp-frameworkbuild output may still reportValidated 11 tools successfullybecause its internal validator scans compiled files differently; runtime loading and docs generation explicitly excludeBaseTool.