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

recognized parameter header does not match the body

Error message

recognized parameter header does not match the body

What it means

Error "recognized parameter header does not match the body" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/13-tools-and-protocols/28-mcp-tool-contracts-and-content/code/main.py:629

    checked_names: list[str] = []
    properties = tool["inputSchema"].get("properties", {})
    for path, suffix in validate_header_annotations(tool):
        expected_name = f"Mcp-Param-{suffix}"
        supplied = normalized.get(expected_name.casefold(), [])
        body_value = _read_path(arguments, path)
        if body_value is MISSING:
            if supplied:
                raise ContractViolation("recognized parameter header has no body argument")
            continue
        if not supplied:
            raise ContractViolation("recognized parameter header is missing")
        if len(supplied) != 1:
            raise ContractViolation("recognized parameter header is duplicated")
        decoded = decode_parameter_header_value(supplied[0][1])
        expected = _parameter_text(body_value, properties[path[0]]["type"])
        if decoded != expected:
            raise ContractViolation("recognized parameter header does not match the body")
        checked_names.append(expected_name)

    audit_log.append(
        {
            "event": "parameter_headers_validated",
            "headerNames": sorted(checked_names),
        }
    )


def streamable_http_tool_call(
    server: ContractServer,
    request: dict[str, Any],
    headers: dict[str, str],
    audit_log: list[dict[str, Any]],
    *,
    principal: str = "analyst",
) -> tuple[int, dict[str, Any] | None]:

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/13-tools-and-protocols/28-mcp-tool-contracts-and-content/code/main.py:629 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/0a625c8a22be3318. Report an issue: GitHub.