rohitg00/ai-engineering-from-scratch · error · ProtocolViolation
-32021
-32021
Error message
modern request is missing {CLIENT_CAPABILITIES_KEY} What it means
Error "modern request is missing {CLIENT_CAPABILITIES_KEY}" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:204
if not isinstance(params, dict):
raise ProtocolViolation("params must be an object", -32602)
wire_headers = normalized_headers(headers)
if era == "legacy":
if body["method"] != "initialize" and wire_headers.get("mcp-protocol-version") == MODERN_VERSION:
raise ProtocolViolation("modern metadata reached the legacy branch", -32020)
return
if era != "modern":
raise ValueError(f"unknown era: {era}")
metadata = params.get("_meta")
if not isinstance(metadata, dict):
raise ProtocolViolation("modern request is missing params._meta", -32602)
protocol_version = metadata.get(PROTOCOL_VERSION_KEY)
capabilities = metadata.get(CLIENT_CAPABILITIES_KEY)
if not isinstance(protocol_version, str):
raise ProtocolViolation(f"modern request is missing {PROTOCOL_VERSION_KEY}", -32602)
if not isinstance(capabilities, dict):
raise ProtocolViolation(f"modern request is missing {CLIENT_CAPABILITIES_KEY}", -32021)
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: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:204 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/16ee77d3306b347f.
Report an issue: GitHub.