api-errors

Standardize error handling with McpError factories and ErrorHandler.tryCatch for MCP TS core.

148|28|Updated Mar 20, 2025
One-click install
npx skills add https://github.com/cyanheads/mcp-ts-core --skill api-errors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-errors
Source: https://github.com/cyanheads/mcp-ts-core/tree/main/skills/api-errors
Command: npx skills add https://github.com/cyanheads/mcp-ts-core --skill api-errors

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Centralizes and standardizes error handling for MCP TS core, providing a consistent way to create and classify errors across tools, resources, and services.

Core Features & Use Cases

  • McpError construction and a rich set of error factories for common conditions.
  • JsonRpcErrorCode mappings and automatic error classification to ensure predictable client behavior.
  • ErrorHandler.tryCatch integration for safe, logged error wrapping in service code.

Quick Start

Install and adopt McpError factories and ErrorHandler.tryCatch in your MCP TS core components to enforce consistent error handling.

Frequently Asked Questions about api-errors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize error handling for JSON-RPC responses in TypeScript?

Standardizing error handling for JSON-RPC responses involves mapping internal exceptions to predictable JSON-RPC error codes. This ensures clients receive consistent error classifications and safe recovery behavior across tool and resource handlers.

What is the best way to normalize MCP errors across tool and resource handlers?

Normalizing MCP errors across handlers requires centralizing error construction with standardized factories. Using a core McpError constructor ensures consistent error codes, classification, and predictable client responses throughout the service layer.

How does tryCatch integration work for safe error wrapping in service code?

TryCatch integration for safe error wrapping works by intercepting service code exceptions and logging them automatically. It wraps thrown errors into normalized McpError instances, mapping them to JSON-RPC error codes for predictable client responses.

Does this error handling approach require external dependencies?

This error handling approach does not require external dependencies. It provides standalone McpError constructors and error factories that integrate directly into TypeScript core components to enforce consistent error normalization.

When do I need automatic error classification for JSON-RPC mappings?

Automatic error classification for JSON-RPC mappings is needed when exposing tools or resources to clients. It guarantees that internal exceptions translate into predictable, standardized JSON-RPC error codes, preventing inconsistent client behavior.