A PreToolUse hook denies the tool when the bearer is missing or userinfo rejects it. Deny runs before permission rules, so an allow rule does not skip this check.
Getting started, including the planned sample, is Claude Agent SDK.
What fails closed
The hook returns permissionDecision deny when the token is missing or userinfo rejects it. The tool does not run.
The hook returns {} when userinfo accepts the bearer. A whoami tool may then return that subject.
A resolved subject is not authorization. Scopes and allowed tools are a later check. The trust-store sample is that later check for MCP. This page stops at admission.
Related
| Read | To learn how to |
|---|---|
| Claude Agent SDK | See the hook |
| API keys and M2M for Claude Agent SDK | Where the secret is allowed to live |
| Authorizing tool calls for Claude Agent SDK | What happens after the subject is known |