mcp‑error‑formatter is a lightweight npm package designed to standardize error formatting for Model Context Protocol (MCP) tool calls, inspired by

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2025-08-03 19:30:02

mcp‑error‑formatter is a lightweight npm package designed to standardize error formatting for Model Context Protocol (MCP) tool calls, inspired by Cursor's clean and LLM‑friendly approach. If you've built MCP servers for LLM integrations and struggled with cryptic error messages that confuse models or hinder debugging, this utility simplifies the process by transforming JavaScript Errors into structured CallToolResult objects. It auto‑detects error types (timeouts, user aborts, network faults), tags each error with a request‑ID for easy tracing, and sets flags such as isRetryable so LLMs (and agents) can behave intelligently—reducing vague "something went wrong" outputs and speeding up development. With zero runtime dependencies beyond uuid and seamless compatibility with the official MCP SDK, FastMCP, or bare JSON‑RPC servers, it's a drop‑in upgrade that makes your MCP tools more robust and user‑friendly.

That's it! Drop formatMCPError into any MCP tool, get rich JSON for agents and readable stacks for humans—no extra setup required.

Leave a Comment
Related Posts