Hooks reference changedhooks
Nearest release: v2.1.322, published 3 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 10 Nov 2026 05:35 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 10 Nov 2026 05:37 UTC.
Upstream edited
Recorded here
Lines+14added
Lines−3removed
From line
568
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits136to this page, all time
The whole hunk
from line 568, old and new numbered
/
This page is larger than the 256 KiB this site keeps, so one side of the diff below stops where the stored text does.
from line 568
568568
569569Claude Code reads the tool's text content the same way it reads command-hook stdout, following the [parsing rule under exit code 0](#exit-code-0). If the tool returns `isError: true`, the hook produces a non-blocking error and execution continues.
570570
571If a hook error contains one of these messages, Claude Code couldn't read the tool's answer, so the hook gave no verdict:
572
573```text theme={null}
574MCP tool "security_scan" on server "my_server" gave no answer that could be read, because a message from the server was too large, so this hook gave no verdict. If this keeps happening, the tool must send a smaller answer.
575MCP tool "security_scan" on server "my_server" answered without its text, which happens when a result is too large, so this hook gave no verdict. If this keeps happening, the tool must send a smaller answer.
576```
577
578On `PreToolUse`, Claude Code refuses the tool call the hook was checking. On other events such as `UserPromptSubmit`, `PostToolUse`, and `Stop`, the error is non-blocking.
579
580If the error keeps appearing, return less data from the tool, or change the hook's [`tool` or `input`](#mcp-tool-hook-fields) so the answer is smaller.
581
571582##### When the server is still connecting
572583
573584On events where a hook can block or change the result, such as `PreToolUse` or `Stop`, Claude Code waits for a connecting server before it calls the tool, for at most [`MCP_TIMEOUT`](https://code.claude.com/docs/en/env-vars) and within the hook's own [`timeout`](#common-fields). On observational events, such as `Notification` or `SessionEnd`, it doesn't wait.
from line 1200
11891200
11901201* `PreToolUse`: `updatedInput` directly under `hookSpecificOutput` replaces a tool's arguments before it runs. See [PreToolUse decision control](#pretooluse-decision-control)
11911202* `PermissionRequest`: `updatedInput` inside the `decision` object. See [PermissionRequest decision control](#permissionrequest-decision-control)
1192* `PostToolUse`: `updatedToolOutput` replaces the tool's result. See [PostToolUse decision control](#posttooluse-decision-control)
1203* `PostToolUse`: `updatedToolOutput` replaces the tool's result. In a [Cowork](https://claude.com/docs/cowork/overview) cloud session, Claude Code ignores `updatedToolOutput` when the tool is `AskUserQuestion` or `ExitPlanMode`, and Claude reads the original answer or plan. See [PostToolUse decision control](#posttooluse-decision-control)
11931204* `UserPromptSubmit`: can't replace the prompt; it only injects `additionalContext` alongside it
11941205
11951206For redaction or transformation use cases, intercept at `PreToolUse` for outbound tool inputs and `PostToolUse` for inbound tool results.
from line 2304
22932304| `reason` | Explanation shown to Claude when `decision` is `"block"` |
22942305| `additionalContext` | String added to Claude's context alongside the tool result. See [Add context for Claude](#add-context-for-claude) |
22952306| `classifierContext` | Short note about this call's result for the [auto mode](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode) classifier rather than for Claude. See [Annotate a result for the auto mode classifier](#annotate-a-result-for-the-auto-mode-classifier). Requires Claude Code v2.1.236 or later |
2296| `updatedToolOutput` | Replaces the tool's output with the provided value before it is sent to Claude. The value must match the tool's output shape |
2297| `updatedMCPToolOutput` | Replaces the output for [MCP tools](#match-mcp-tools) only. Prefer `updatedToolOutput`, which works for all tools |
2307| `updatedToolOutput` | Replaces the tool's output with the provided value before it is sent to Claude. The value must match the tool's output shape. In a [Cowork](https://claude.com/docs/cowork/overview) cloud session, Claude Code ignores this field when the tool is `AskUserQuestion` or `ExitPlanMode`, and Claude reads the original answer or plan |
2308| `updatedMCPToolOutput` | Replaces the output for [MCP tools](#match-mcp-tools) only. Prefer `updatedToolOutput`, which also works for built-in tools |
22982309
22992310The example below replaces the output of a `Bash` call. The replacement value matches the `Bash` tool's output shape:
23002311
from line 3690
36793690{
36803691 "session_id": "abc123",
36813692 "transcript_path": "/Users/.../.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
3682 "cwd": "/Users/...",
3683 "hook_event_name": "Elicitation",
3684 "mcp_server_name": "my-mcp-server",
3685 "message": "Please provide your credentials",
3686 "mode": "form",
3687 "requested_schema": {
3688 "type": "object",
3689 "properties": {
3690 "username": { "type": "string", "title": "Username" }
3691 }
3692 }
3693}
3694```
3695
3696For URL-mode elicitation, used for browser-based authentication:
3697
3698```json theme={null}
3699{
3700 "session_id": "abc123",
3701 "transcript_path": "/Users/.../.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
3702 "cwd": "/Users/...",
3703 "hook_event_name": "Elicitation",
3704 "mcp_server_name": "my-mcp-server",
3705 "message": "Please authenticate",
3706 "mode": "url",
3707 "url": "https://auth.example.com/login"
3708}
3709```
3710
3711#### Elicitation output
3712
3713An Elicitation hook can answer the request for the user, decline or cancel it, or leave it to the dialog. To answer, decline, or cancel, exit 0 and print a `hookSpecificOutput` object with an `action`. The server gets your answer and no dialog appears. Each row of this table shows what to return for one outcome and what the MCP server receives:
3714
3715| To | Return | The server receives |
3716| :- | :- | :- |
3717| Answer for the user | `"action": "accept"`, with the form field values in `content` | `accept` with your `content` |
3718| Decline the request | `"action": "decline"` | `decline` |
3719| Cancel the request |
3693 "cwd": "/Users/..."
No line in this hunk matches that.