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

-32022

-32022

Error message

unsupported protocol version: {protocol_version}

What it means

Error "unsupported protocol version: {protocol_version}" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:223

    mirrored = {
        "mcp-protocol-version": protocol_version,
        "mcp-method": body["method"],
    }
    name = routing_name(body)
    if name is not None:
        mirrored["mcp-name"] = name
    for header, body_value in mirrored.items():
        header_value = wire_headers.get(header)
        if header == "mcp-name" and header_value is not None:
            header_value = decode_header_value(header_value)
        if header_value != body_value:
            raise ProtocolViolation(
                f"{header} does not match the JSON-RPC body",
                -32020,
            )
    if protocol_version != MODERN_VERSION:
        raise ProtocolViolation(f"unsupported protocol version: {protocol_version}", -32022)


def allowed_result_types(capabilities: set[str]) -> set[str]:
    allowed = set(CORE_RESULT_TYPES)
    for capability in capabilities:
        allowed.update(EXTENSION_RESULT_TYPES.get(capability, set()))
    return allowed


def validate_result(
    result: dict[str, Any],
    era: str,
    capabilities: set[str] | None = None,
) -> dict[str, Any]:
    if not isinstance(result, dict):
        raise ProtocolViolation("result must be an object")
    preserved = dict(result)
    result_type = result.get("resultType")

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:223 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/0d1d71df8e8a7380. Report an issue: GitHub.