{"record":{"id":"0a625c8a22be3318","repo":"rohitg00/ai-engineering-from-scratch","slug":"recognized-parameter-header-does-not-match-the-bod","errorCode":null,"errorMessage":"recognized parameter header does not match the body","messagePattern":"recognized parameter header does not match the body","errorType":"validation","errorClass":"ContractViolation","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/28-mcp-tool-contracts-and-content/code/main.py","lineNumber":629,"sourceCode":"\n    checked_names: list[str] = []\n    properties = tool[\"inputSchema\"].get(\"properties\", {})\n    for path, suffix in validate_header_annotations(tool):\n        expected_name = f\"Mcp-Param-{suffix}\"\n        supplied = normalized.get(expected_name.casefold(), [])\n        body_value = _read_path(arguments, path)\n        if body_value is MISSING:\n            if supplied:\n                raise ContractViolation(\"recognized parameter header has no body argument\")\n            continue\n        if not supplied:\n            raise ContractViolation(\"recognized parameter header is missing\")\n        if len(supplied) != 1:\n            raise ContractViolation(\"recognized parameter header is duplicated\")\n        decoded = decode_parameter_header_value(supplied[0][1])\n        expected = _parameter_text(body_value, properties[path[0]][\"type\"])\n        if decoded != expected:\n            raise ContractViolation(\"recognized parameter header does not match the body\")\n        checked_names.append(expected_name)\n\n    audit_log.append(\n        {\n            \"event\": \"parameter_headers_validated\",\n            \"headerNames\": sorted(checked_names),\n        }\n    )\n\n\ndef streamable_http_tool_call(\n    server: ContractServer,\n    request: dict[str, Any],\n    headers: dict[str, str],\n    audit_log: list[dict[str, Any]],\n    *,\n    principal: str = \"analyst\",\n) -> tuple[int, dict[str, Any] | None]:","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/13-tools-and-protocols/28-mcp-tool-contracts-and-content/code/main.py#L611-L647","documentation":"Error \"recognized parameter header does not match the body\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/13-tools-and-protocols/28-mcp-tool-contracts-and-content/code/main.py:629 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}