<< All versions
Skill v1.0.0
currentLLM-judged scan95/100caglarkc/sentinel-coming/agentic-mcp-error-codes
──Details
PublishedOctober 23, 2026 at 06:36 PM
Content Hashsha256:0cb43d1087c17830...
Git SHA4e4c06c66b00
──Files
Files (1 file, 4.0 KB)
SKILL.md4.0 KBactive
SKILL.md · 115 lines · 4.0 KB
version: "1.0.0" name: agentic-mcp-error-codes description: "MCP JSON-RPC hata kodu standartları, istemci tarafı hata işleme ve kullanıcıya anlamlı hata mesajı üretimi; hata sınıflandırması ve retry stratejisi"
Purpose
MCP protokolünde JSON-RPC 2.0 hata kodlarını doğru kullanmak, istemcilerin hataları kategorize edip uygun şekilde işleyebilmesini sağlamak.
Workflow
Hata Kodu Sınıflandırması
| Kod | Sabit | Açıklama | Retry? | |
|---|---|---|---|---|
| -32700 | PARSE_ERROR | JSON parse edilemedi | Hayır | |
| -32600 | INVALID_REQUEST | JSON-RPC şeması geçersiz | Hayır | |
| -32601 | METHOD_NOT_FOUND | Araç/kaynak bulunamadı | Hayır | |
| -32602 | INVALID_PARAMS | Parametre doğrulama hatası | Hayır | |
| -32603 | INTERNAL_ERROR | Sunucu iç hatası | Evet (backoff) | |
| -32000 | SERVER_ERROR | Uygulama seviyesi hata | Bağlama göre | |
| -32001 | RATE_LIMITED | İstek hız sınırı | Evet (backoff) | |
| -32002 | RESOURCE_NOT_FOUND | MCP resource mevcut değil | Hayır |
Sunucu Tarafı Hata Üretimi
python
# mcp_server/errors.pyfrom dataclasses import dataclassfrom typing import Any@dataclassclass MCPError(Exception):code: intmessage: strdata: Any = Nonedef to_jsonrpc(self, request_id) -> dict:error = {"code": self.code, "message": self.message}if self.data is not None:error["data"] = self.datareturn {"jsonrpc": "2.0", "id": request_id, "error": error}# Özel hata sınıflarıclass ToolNotFoundError(MCPError):def __init__(self, tool_name: str):super().__init__(code=-32601,message=f"Tool '{tool_name}' not found",data={"available_tools": _get_available_tools()})class ValidationError(MCPError):def __init__(self, field: str, reason: str):super().__init__(code=-32602,message=f"Invalid parameter '{field}': {reason}",data={"field": field, "reason": reason})
İstemci Tarafı Hata İşleme
python
import asynciofrom sentinel.mcp_client import MCPClientasync def call_with_retry(client: MCPClient, tool: str, args: dict, max_retries=3):RETRYABLE_CODES = {-32603, -32001}for attempt in range(max_retries):try:return await client.call_tool(tool, args)except MCPError as e:if e.code not in RETRYABLE_CODES:raise # retry etme, hemen yükseltif e.code == -32001: # rate limitedretry_after = e.data.get("retry_after", 5) if e.data else 5await asyncio.sleep(retry_after)else:# exponential backoffawait asyncio.sleep(2 ** attempt)if attempt == max_retries - 1:raiseraise RuntimeError("unreachable")
Structured Error Logging
python
import structloglog = structlog.get_logger()async def dispatch_method(method: str, params: dict, request_id):try:result = await _call(method, params)return {"jsonrpc": "2.0", "id": request_id, "result": result}except MCPError as e:log.warning("mcp_error", code=e.code, message=e.message, method=method)return e.to_jsonrpc(request_id)except Exception as e:log.exception("mcp_internal_error", method=method)return MCPError(code=-32603, message="Internal error").to_jsonrpc(request_id)
Common mistakes
-32000tek bir "genel sunucu hatası" olarak kullanmak — alt kodlar (-32001,-32002) ile kategorize et- Hata
dataalanına stack trace gömmek — production'da güvenlik riski; sadece structured metadata ekle - İstemcide tüm hataları aynı şekilde işlemek — retry edilemez hataları retry etmek gereksiz yük
messagealanını i18n için kullanmaya çalışmak —dataiçinecode_keyekle, istemci kendi locale'ini uygulasın
References
skills/agentic-mcp-versioningskills/agentic-mcp-testing