0Pricing
MCP Academy · Aula

Erros de protocolo e falhas de ferramentas

Diferencie falhas de transporte de erros de lógica de negócio.

Erros de protocolo e falhas de ferramentas é uma aula grátis de MCP Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de MCP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de MCP Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em 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. ✅

Perguntas Frequentes

A aula “Erros de protocolo e falhas de ferramentas” é grátis?

Sim — o texto completo de “Erros de protocolo e falhas de ferramentas” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de MCP Academy, atualize para CoddyKit PRO. O curso de MCP Academy inclui 4 aulas no total.

O que vou aprender em “Erros de protocolo e falhas de ferramentas”?

Diferencie falhas de transporte de erros de lógica de negócio. Você pratica MCP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar MCP Academy?

Nenhuma experiência prévia é necessária. MCP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Erros de protocolo e falhas de ferramentas”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de MCP Academy?

Sim. Cada aula de MCP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Erros de ferramentas visíveis para o modelo
  2. Erros de protocolo e falhas de ferramentas
  3. Validar entradas antes de agir
  4. Falhar com segurança, sem nunca travar
← Voltar para MCP Academy