rohitg00/ai-engineering-from-scratch · error · RpcFault

-32022

-32022

Error message

Unsupported protocol version

What it means

Error "Unsupported protocol version" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/13-tools-and-protocols/09-mcp-transports/code/main.py:195

        raise RpcFault(-32602, "params._meta is required")
    version = meta.get(VERSION_KEY)
    if not isinstance(version, str):
        raise RpcFault(-32602, f"{VERSION_KEY} is required")
    if not isinstance(meta.get(CAPABILITIES_KEY), dict):
        raise RpcFault(-32602, f"{CAPABILITIES_KEY} is required")
    client_info = meta.get(CLIENT_INFO_KEY)
    if client_info is not None and (
        not isinstance(client_info, dict)
        or not isinstance(client_info.get("name"), str)
        or not isinstance(client_info.get("version"), str)
    ):
        raise RpcFault(-32602, f"{CLIENT_INFO_KEY} is malformed")
    return version


def validate_supported_version(version: str) -> None:
    if version not in SUPPORTED_VERSIONS:
        raise RpcFault(
            -32022,
            "Unsupported protocol version",
            {"supported": SUPPORTED_VERSIONS.copy(), "requested": version},
        )


def validate_http_headers(
    headers: Mapping[str, str],
    message: dict[str, Any],
    body_version: str,
) -> None:
    header_version = headers.get("MCP-Protocol-Version")
    if header_version is None or header_version != body_version:
        raise RpcFault(-32020, "Header mismatch: MCP-Protocol-Version")
    header_method = headers.get("Mcp-Method")
    if header_method is None or header_method != message["method"]:
        raise RpcFault(-32020, "Header mismatch: Mcp-Method")
    expected_name = body_name(message)

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/13-tools-and-protocols/09-mcp-transports/code/main.py:195 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26). Data as JSON: /api/errors/eed91613b000565c. Report an issue: GitHub.