Skip to content

fix(core): handle tool execution errors with isError flag and add tests - #70

Open
fabiooliveir wants to merge 1 commit into
hostinger:mainfrom
fabiooliveir:fix/mcp-tool-error-handling
Open

fabiooliveir wants to merge 1 commit into
hostinger:mainfrom
fabiooliveir:fix/mcp-tool-error-handling

Conversation

@fabiooliveir

Copy link
Copy Markdown

Description

This PR addresses two key improvements for the Hostinger MCP Server:

  1. MCP Specification Compliance (isError: true):

    • Previously, HTTP errors (4xx/5xx) and unhandled execution exceptions either returned raw response payloads as success or threw unhandled JSON-RPC exceptions.
    • Now, tool execution errors return a standard MCP CallToolResult with isError: true and the error details in the text content, allowing LLM clients (Claude, Cursor, Gemini, Copilot) to understand and self-correct on API failures.
    • Protocol errors for missing tools (Tool not found) are preserved.
  2. Automated Test Suite & Hygiene:

    • Added automated tests in test/runtime-errors.test.js using Node.js native test runner (npm test) covering success (2xx), API errors (400, 401, 422, 5xx), connection drops (ECONNREFUSED), and custom tool validations.
    • Added a root .gitignore to prevent committing dist/, node_modules/, and sensitive .env credentials.

Verification

  • npm test: 8/8 tests passing.
  • npm run build: TypeScript compilation succeeded without errors.

@fabiooliveir
fabiooliveir requested a review from a team as a code owner September 15, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant