MCP concepts

Errors

Every MCP refusal, what it means, and which end to look at — the address, the token, the server or the protocol.

11 codesIaGenifyErrorthe server's message is carried
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

The address

CodeStatusMeans
url_required400No address was given.
url_not_https400Plain http. The token would travel unencrypted.
url_blocked400It does not resolve to a public address.
mcp_redirect502The server answered with a redirect. They are never followed — the destination was never checked.

The token

CodeStatusMeans
mcp_token_malformed400It contains a space. Paste the token alone.
mcp_token_required401The server wants one and none was given.
mcp_unauthorized401It was refused. Rotate it with update().

The server

CodeStatusMeans
mcp_unreachable502No answer at all.
mcp_timeout504Past the ceiling — 30 s listing, 60 s calling.
mcp_http_error502A refusal at the HTTP level.
mcp_bad_response502The answer was not a readable protocol message.
mcp_error502A protocol error. The server's own message is carried.
mcp_protocol_unsupported502No revision in common.
mcp_error carries the server's words

It is the one to read rather than interpret: whoever operates the server wrote that message, and it usually names the real cause — a missing capability, an unsupported version, a header that does not match the body.

Handling them

import { IaGenifyError } from "iagenify";

try {
  await api.mcp.call("example", "search_docs", { query });
} catch (err) {
  if (!(err instanceof IaGenifyError)) throw err;

  switch (err.code) {
    case "mcp_unauthorized": return rotateToken();
    case "mcp_timeout":
    case "mcp_unreachable":  return markServerDown();
    default:                 throw err;
  }
}
from iagenify import IaGenifyError

try:
    api.mcp.call("example", "search_docs", {"query": query})
except IaGenifyError as error:
    if error.code == "mcp_unauthorized":
        rotate_token()
    elif error.code in ("mcp_timeout", "mcp_unreachable", "mcp_http_error"):
        mark_server_down()
    else:
        raise

The last one is remembered

A connection keeps lastError, so a server whose token expired or whose address moved shows it in list() rather than only failing inside a run.