Protocol Errors vs Tool Failures
Tell transport faults from business-logic errors.
Protocol Errors vs Tool Failures is a free MCP Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MCP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
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. ✅
Frequently asked questions
Is the “Protocol Errors vs Tool Failures” lesson free?
Yes — the full text of “Protocol Errors vs Tool Failures” is free to read here on the web, and the MCP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MCP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Protocol Errors vs Tool Failures”?
Tell transport faults from business-logic errors. You practise MCP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MCP Academy?
No prior experience is required. MCP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Protocol Errors vs Tool Failures” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MCP Academy lesson?
Yes. Every MCP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Tool Errors the Model Can See
- Protocol Errors vs Tool Failures
- Validate Inputs Before Acting
- Fail Safely, Never Hang