Errores del protocolo frente a fallos de herramientas
Distinga los fallos de transporte de los errores de lógica de negocio.
Errores del protocolo frente a fallos de herramientas es una lección gratuita de MCP Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de MCP Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de MCP Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
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. ✅
Preguntas frecuentes
¿La lección «Errores del protocolo frente a fallos de herramientas» es gratis?
Sí — el texto completo de «Errores del protocolo frente a fallos de herramientas» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de MCP Academy, actualiza a CoddyKit PRO. El curso de MCP Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Errores del protocolo frente a fallos de herramientas»?
Distinga los fallos de transporte de los errores de lógica de negocio. Practicas MCP Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar MCP Academy?
No se requiere experiencia previa. MCP Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «Errores del protocolo frente a fallos de herramientas»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de MCP Academy?
Sí. Cada lección de MCP Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Errores de herramientas visibles para el modelo
- Errores del protocolo frente a fallos de herramientas
- Validar las entradas antes de actuar
- Fallar de forma segura, sin bloqueos