Require Redaction Review Before an Elicitation Response Is Sent
The counterpart to declining a suspicious request outright: sometimes a form is legitimate but the human fills in more than the server actually needed. This re-scans the filled content one more time, right before it's sent back to the MCP server, and blocks if it still contains a secret-shaped or SSN-shaped string.
1. Save this as the hook script
#!/usr/bin/env python3
"""ElicitationResult hook — blocks sending the elicitation response back
to the MCP server if its content matches a secret or SSN pattern."""
import json, re, sys
data = json.load(sys.stdin)
content = json.dumps(data.get("content") or {})
PATTERNS = [r"\b\d{3}-\d{2}-\d{4}\b", r"sk-(ant|proj|live)-[A-Za-z0-9_-]{20,}"]
for p in PATTERNS:
if re.search(p, content):
print(f"BLOCKED: elicitation response content matches `{p}` — "
f"review before sending this to the MCP server.", file=sys.stderr)
sys.exit(2)
sys.exit(0)
Save to a path inside your project, e.g. .claude/hooks/require-redaction-before-elicitation-response.sh, then chmod +x it.
2. Wire it into .claude/settings.json
{
"hooks": {
"ElicitationResult": [
{
"hooks": [
{"type": "command", "command": "python3 .claude/hooks/require-redaction-before-elicitation-response.py"}
]
}
]
}
}
Before you use this
A hook runs with your local shell's permissions — review the script above before adding it, the same way you'd review any script you didn't write yourself. See our guide on hook security risks for the specific CVEs this category of feature has already produced.
Related hooks