0Pricing
MCP Academy · Lekcja

Błędy protokołu a awarie narzędzi

Odróżniaj błędy transportu od błędów logiki biznesowej.

Błędy protokołu a awarie narzędzi to bezpłatna lekcja MCP Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej MCP Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs MCP Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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. ✅

Często zadawane pytania

Czy lekcja „Błędy protokołu a awarie narzędzi” jest bezpłatna?

Tak — pełny tekst „Błędy protokołu a awarie narzędzi” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu MCP Academy, przejdź na CoddyKit PRO. Kurs MCP Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Błędy protokołu a awarie narzędzi”?

Odróżniaj błędy transportu od błędów logiki biznesowej. Ćwiczysz MCP Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć MCP Academy?

Nie wymagamy żadnego doświadczenia. MCP Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.

Ile czasu zajmuje lekcja „Błędy protokołu a awarie narzędzi”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji MCP Academy?

Tak. Każda lekcja MCP Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Błędy narzędzi widoczne dla modelu
  2. Błędy protokołu a awarie narzędzi
  3. Sprawdzanie danych wejściowych przed działaniem
  4. Bezpieczne kończenie bez zawieszania
← Powrót do MCP Academy