أخطاء البروتوكول في مقابل أعطال الأدوات
ميّزوا بين أعطال النقل وأخطاء منطق الأعمال.
أخطاء البروتوكول في مقابل أعطال الأدوات درس مجاني في MCP Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في MCP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة MCP Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Two Very Different Failures
MCP has two kinds of failure: a protocol error in the wire itself, and a tool failure inside your business logic. They are handled differently.
Protocol Errors Live in JSON-RPC
A protocol error means the message could not be processed at all, like an unknown method or malformed params. It rides in the JSON-RPC error field.
{"jsonrpc": "2.0", "id": 7,
"error": {"code": -32601,
"message": "Method not found"}}Tool Failures Live in the Result
A tool failure means the call reached your function but the work went wrong. It returns a normal result marked with isError true.
Why the Split Matters
The model should see and react to tool failures, but protocol errors usually signal a bug the client must handle, not something the AI can retry.
Standard JSON-RPC Codes
Protocol codes are negative and standardized: -32601 is method not found, -32602 is invalid params, -32700 is a parse error.
Tool Failures Reach the Model
Because a tool failure is just a result, the model reads it as context and can decide to retry, adjust input, or explain it. 🔁
Raising Inside a Tool
When you raise an exception in a tool, FastMCP turns it into a tool failure result, not a protocol error. Your server keeps running.
@mcp.tool()
def fetch(url: str) -> str:
if not url.startswith("http"):
raise ValueError("url must be http")Unknown Tool Is Protocol-Level
If a client asks for a tool that does not exist, that is a protocol error. The request never reaches any function of yours.
Bad Arguments Can Be Either
Schema-level type mismatches surface as a protocol invalid-params error, while a valid type with a bad value is best a tool failure.
Match Failure to Audience
Ask who should react. If the model can fix it, make it a tool failure. If only the developer can, a protocol error is right.
Keep Transport Healthy
Never let business problems leak out as protocol errors. Doing so confuses clients and can tear down a session that should keep going.
Quick Check
Where does a failure inside your tool function get reported?
Recap
Protocol errors mean the message itself failed; tool failures mean your logic failed. Route each to who can act on it and keep transport healthy. ✅
الأسئلة الشائعة
هل درس «أخطاء البروتوكول في مقابل أعطال الأدوات» مجاني؟
نعم — نص درس «أخطاء البروتوكول في مقابل أعطال الأدوات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة MCP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة MCP Academy 4 دروس في المجموع.
ماذا ستتعلم في «أخطاء البروتوكول في مقابل أعطال الأدوات»؟
ميّزوا بين أعطال النقل وأخطاء منطق الأعمال. تتمرن على MCP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ MCP Academy؟
لا تُشترط خبرة سابقة. MCP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «أخطاء البروتوكول في مقابل أعطال الأدوات»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس MCP Academy هذا؟
نعم. كل درس في MCP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- أخطاء الأدوات التي يستطيع النموذج رؤيتها
- أخطاء البروتوكول في مقابل أعطال الأدوات
- التحقق من المدخلات قبل التنفيذ
- الفشل بأمان دون تعليق التنفيذ