PreToolUse hook on a ClaudeAgentOptions config. Every tool call the agent attempts is evaluated against your bundle and recorded in the audit log. Denied calls become a deny permission decision — the model sees it and adapts, no harness changes required.
Install
claude-agent-sdk package as a peer dep. Compatible with claude-agent-sdk 0.2.x and later.
Basic usage
governance_hook_matchers(gov, session_id) returns a dict matching the structure Claude Agent expects under options.hooks — one matcher that fires on every tool call.
Tool name extraction
Claude Agent sees MCP tool names asmcp__<server>__<tool> (e.g. mcp__quickstart-tools__delete_file). By default the adapter strips the mcp__<server>__ prefix so your policies can reference plain tool names:
Denied calls
The hook returns the standard Claude Agent permission-decision shape:With traces
The adapter automatically threads the agent’s hook payloads (tool name, tool input, tool_use_id) into aTraceContext and uploads it. To disable trace upload, pass trace=False:
True because the dashboard’s trace drawer is the single highest-leverage feature for triaging Claude Agent runs.
Multi-session
Claude Agent runs eachquery() as one session. If your application maintains multiple long-running conversations, build the hook once per conversation with that conversation’s id:
user-<id> session in the dashboard.
Full example
A runnable end-to-end script ships with the SDK atexamples/claude_agent_quickstart.py. It runs Claude Agent against an in-tree MCP server with governance installed end-to-end.