본문으로 건너뛰기
cccskills
무료GitHub에 공개

mcp-error-code-mapper

Map application errors to MCP error codes with proper messages, error types, and recovery suggestions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md5.6 KB
  • README.md1019 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

MCP Error Code Mapper

Map application errors to MCP error codes with proper handling.

Capabilities

  • Map errors to MCP error codes
  • Create structured error responses
  • Generate error documentation
  • Implement error recovery hints
  • Configure error serialization
  • Create error handler utilities

Usage

Invoke this skill when you need to:

  • Map application errors to MCP errors
  • Create structured error responses
  • Implement error handling for tools
  • Generate error documentation

Inputs

ParameterTypeRequiredDescription
languagestringYesTarget language
errorsarrayYesError definitions
includeRecoverybooleanNoInclude recovery hints

Error Structure

{
  "errors": [
    {
      "name": "FileNotFound",
      "mcpCode": -32002,
      "message": "File not found: {path}",
      "recovery": "Check if the file exists and the path is correct"
    },
    {
      "name": "InvalidInput",
      "mcpCode": -32602,
      "message": "Invalid input: {reason}",
      "recovery": "Review the input parameters and try again"
    }
  ]
}

Generated Patterns

TypeScript Error Mapper

import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';

// Standard MCP Error Codes
export const MCP_ERROR_CODES = {
  PARSE_ERROR: -32700,
  INVALID_REQUEST: -32600,
  METHOD_NOT_FOUND: -32601,
  INVALID_PARAMS: -32602,
  INTERNAL_ERROR: -32603,
  // Custom codes (-32000 to -32099)
  FILE_NOT_FOUND: -32001,
  PERMISSION_DENIED: -32002,
  RESOURCE_NOT_FOUND: -32003,
  VALIDATION_ERROR: -32004,
} as const;

// Error with recovery hint
interface McpErrorWithRecovery extends McpError {
  data?: {
    recovery?: string;
    details?: unknown;
  };
}

// Error factory functions
export function fileNotFoundError(path: string): McpErrorWithRecovery {
  return {
    code: MCP_ERROR_CODES.FILE_NOT_FOUND,
    message: `File not found: ${path}`,
    data: {
      recovery: 'Check if the file exists and the path is correct',
      details: { path },
    },
  };
}

export function invalidParamsError(reason: string): McpErrorWithRecovery {
  return {
    code: MCP_ERROR_CODES.INVALID_PARAMS,
    message: `Invalid parameters: ${reason}`,
    data: {
      recovery: 'Review the input parameters and try again',
    },
  };
}

// Error handler wrapper
export function handleToolError(error: unknown): McpErrorWithRecovery {
  if (error instanceof Error) {
    // Map known error types
    if (error.message.includes('ENOENT')) {
      return fileNotFoundError(error.message);
    }
    if (error.message.includes('EACCES')) {
      return {
        code: MCP_ERROR_CODES.PERMISSION_DENIED,
        message: `Permission denied: ${error.message}`,
        data: { recovery: 'Check file permissions' },
      };
    }
    // Fallback to internal error
    return {
      code: MCP_ERROR_CODES.INTERNAL_ERROR,
      message: error.message,
    };
  }
  return {
    code: MCP_ERROR_CODES.INTERNAL_ERROR,
    message: 'An unexpected error occurred',
  };
}

Python Error Mapper

from enum import IntEnum
from typing import Any, Optional
from dataclasses import dataclass

class McpErrorCode(IntEnum):
    PARSE_ERROR = -32700
    INVALID_REQUEST = -32600
    METHOD_NOT_FOUND = -32601
    INVALID_PARAMS = -32602
    INTERNAL_ERROR = -32603
    # Custom codes
    FILE_NOT_FOUND = -32001
    PERMISSION_DENIED = -32002
    RESOURCE_NOT_FOUND = -32003

@dataclass
class McpError(Exception):
    code: int
    message: str
    recovery: Optional[str] = None
    details: Optional[Any] = None

    def to_dict(self) -> dict:
        result = {'code': self.code, 'message': self.message}
        if self.recovery or self.details:
            result['data'] = {}
            if self.recovery:
                result['data']['recovery'] = self.recovery
            if self.details:
                result['data']['details'] = self.details
        return result

def file_not_found_error(path: str) -> McpError:
    return McpError(
        code=McpErrorCode.FILE_NOT_FOUND,
        message=f'File not found: {path}',
        recovery='Check if the file exists and the path is correct',
        details={'path': path}
    )

def handle_tool_error(error: Exception) -> McpError:
    error_msg = str(error)
    if 'FileNotFoundError' in type(error).__name__:
        return file_not_found_error(error_msg)
    if 'PermissionError' in type(error).__name__:
        return McpError(
            code=McpErrorCode.PERMISSION_DENIED,
            message=f'Permission denied: {error_msg}',
            recovery='Check file permissions'
        )
    return McpError(
        code=McpErrorCode.INTERNAL_ERROR,
        message=error_msg
    )

Workflow

  1. Define errors - List application errors
  2. Map codes - Assign MCP error codes
  3. Create messages - User-friendly messages
  4. Add recovery - Recovery suggestions
  5. Generate handlers - Error handling code
  6. Document errors - Error documentation

Target Processes

  • mcp-tool-implementation
  • mcp-server-security-hardening
  • error-handling-user-feedback

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Provide implementations of advanced data structures

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

Fresh adversarial code review with binary PASS/FAIL verdicts, evidence citations, and anchoring bias prevention via fresh reviewer spawning.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

WASM-based instant code transforms for simple tasks, achieving 352x speedup over LLM inference with zero cost.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

Coordinate Crew (persistent) and Polecat (transient) agents using Gas Town's hook-based work distribution and GUPP principle.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

Generate visual representations of algorithm execution

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

Hierarchical coordination and drift detection with frequent checkpoints, shared memory coherence validation, role specialization enforcement, and short task cycles.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

a5c-ai/babysitter1.9천2026년 9월 17일 업데이트

a5c-ai의 스킬 모두 보기

이 스킬의 문제 신고