MCP 概念

错误

每一 MCP 拒绝、它意味着什么,以及看什么的结束——地址、象征、服务器或协议。

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.

地址地址地址

代码状态含义
url_required400没有提供地址。
url_not_https400直接在http上。 信物会无加密地行驶 。
url_blocked400它没有决心发表公开讲话。
mcp_redirect502服务器以重定向回应。 从未被跟踪, 目标从未检查 。

象征性

代码状态含义
mcp_token_malformed400里面有空间 仅贴上象征
mcp_token_required401服务器想要一个,但没有给。
mcp_unauthorized401被拒,旋转 update().

服务器服务器

代码状态含义
mcp_unreachable502完全没有答案
mcp_timeout504超过上限——30秒,60秒呼叫。
mcp_http_error502拒绝在 HTTP 级别。
mcp_bad_response502答案不是可读协议信息。
mcp_error502协议错误 。 服务器的邮件已携带 。
mcp_protocol_unsupported502没有共同的修订。
mcp_error 携带服务器的单词

其内容是阅读而非解释:不管服务器操作者是谁,都写了这个信息,通常写出真实原因——缺少能力、没有支持的版本、与身体不匹配的页眉。

处理

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

最后一个被记住

A连接保持 lastError,因此一个服务器的标记过期或地址被移动的服务器显示在 (列表) 而不是仅仅在跑步中失败