BerriAI/litellm · error · HTTPException
Content blocked: MCP tool result matched a masking rule on a
Error message
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
What it means
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.
Source
Thrown at litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py:175
if masked_texts is None:
return response
if len(masked_texts) != len(originals):
verbose_proxy_logger.warning(
"MCP Guardrail: guardrail returned %d texts for %d tool result texts; leaving the result unmasked",
len(masked_texts),
len(originals),
)
return response
split: Final = len(text_blocks)
if content is not None:
for (index, original), masked in zip(text_blocks, masked_texts[:split]):
if masked != original:
content[index] = with_mcp_content_item_text(content[index], masked)
label_start: Final = split + len(structured_leaves)
if any(masked != original for original, masked in zip(structured_labels, masked_texts[label_start:])):
raise HTTPException(
status_code=400,
detail={
"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"
)
},
)
structured_replacements: Final = {
path: masked
for (path, original), masked in zip(structured_leaves, masked_texts[split:label_start])
if masked != original
}
if structured_replacements:
set_mcp_tool_result_structured_content(
response, with_json_string_leaves(structured, structured_replacements)View on GitHub (pinned to 77b7c6c40c)
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.
Example fix
Move sensitive values into string content fields.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/_experimental/mcp_server/guardrail_translation/handler.py:175 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/88200688dd5144ac.
Report an issue: GitHub.