{"record":{"id":"88200688dd5144ac","repo":"BerriAI/litellm","slug":"content-blocked-mcp-tool-result-matched-a-masking","errorCode":null,"errorMessage":"Content blocked: MCP tool result matched a masking rule on a non-rewritable field (a structuredContent key or numeric value), which cannot be redacted without changing the payload contract","messagePattern":"Content blocked: MCP tool result matched a masking rule on a non-rewritable field \\(a structuredContent key or numeric value\\), which cannot be redacted without changing the payload contract","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py","lineNumber":175,"sourceCode":"        if masked_texts is None:\n            return response\n        if len(masked_texts) != len(originals):\n            verbose_proxy_logger.warning(\n                \"MCP Guardrail: guardrail returned %d texts for %d tool result texts; leaving the result unmasked\",\n                len(masked_texts),\n                len(originals),\n            )\n            return response\n\n        split: Final = len(text_blocks)\n        if content is not None:\n            for (index, original), masked in zip(text_blocks, masked_texts[:split]):\n                if masked != original:\n                    content[index] = with_mcp_content_item_text(content[index], masked)\n\n        label_start: Final = split + len(structured_leaves)\n        if any(masked != original for original, masked in zip(structured_labels, masked_texts[label_start:])):\n            raise HTTPException(\n                status_code=400,\n                detail={\n                    \"error\": (\n                        \"Content blocked: MCP tool result matched a masking rule on a non-rewritable field \"\n                        \"(a structuredContent key or numeric value), which cannot be redacted without changing \"\n                        \"the payload contract\"\n                    )\n                },\n            )\n\n        structured_replacements: Final = {\n            path: masked\n            for (path, original), masked in zip(structured_leaves, masked_texts[split:label_start])\n            if masked != original\n        }\n        if structured_replacements:\n            set_mcp_tool_result_structured_content(\n                response, with_json_string_leaves(structured, structured_replacements)","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py#L157-L193","documentation":"Error \"Content blocked: MCP tool result matched a masking rule on a non-rewritable field (a structuredContent key or numeric value), which cannot be redacted without changing the payload contract\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py:175 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Adjust the masking rule to target rewritable text fields only.","Or change the payload so matched entities appear in string fields that can be redacted."],"exampleFix":"Move sensitive values into string content fields.","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}