Fail-Closed MCP Tool Hooks in Claude Code
MCP tool hooks in Claude Code can now block an action when the hook's own call fails, the way command and HTTP hooks already do.
Details
- Set "onFailure": "block" on an mcp_tool hook so a failed call blocks the action
- Matches how command and HTTP hooks already behave
- Small update for advanced setups. Most users will not notice. Shipped in Claude Code version 2.1.328.
Best for
Safety checks that must run before an action, such as a policy or approval check
Use it when
A hook calls an MCP tool and a failed check should stop the action instead of letting it through
Who benefits
Developers and admins who build guardrails with Claude Code hooks
Join the newsletter to get ahead with AI.
I share strategies, new modules, free guides, and tools to get you better at using AI in your work.
Leading a team? See team programs →