Generated: 2026-04-01 Extraction basis:
- tool type contract
- tool registry
- tool exposure rules
The tool type contract and the tool registry together define the model-tool contract:
- how tools are typed
- what context they receive
- how permission state is represented
- how results and progress are emitted
- which concrete tools can be exposed
This document is self-contained. It describes both the abstract tool API and the concrete exposure rules, so a reader can understand what the model can call and under what constraints.
ToolInputJSONSchema is the minimal schema shape exported for API-facing tool schemas:
type: 'object'- arbitrary properties
This is the bridge type between internal tool implementations and Anthropic API tool declarations.
The permission context passed into tool execution includes:
mode- additional working directories
- always-allow rules
- always-deny rules
- always-ask rules
- bypass-permissions availability
- auto-mode availability
- stripped dangerous rules
- “avoid permission prompts” flag
- “await automated checks before dialog” flag
prePlanMode
This means permission state is richer than a single boolean or mode enum.
The tool-use context is the real runtime contract passed to tools.
It includes:
- model/tool/options bundle
- abort controller
- read-file state
- AppState getters/setters
- MCP clients and resources
- prompt request callback
- tool JSX hooks
- notification hooks
- message list
- file-history and attribution state updaters
- per-tool and per-thread bookkeeping
- content replacement state for tool-result budgeting
- rendered system prompt snapshot for cache-sharing forks
This is one of the densest and most informative source artifacts in the repo.
A tool result can return:
data- optional
newMessages - optional
contextModifier - optional MCP metadata (
structuredContent,_meta)
This shows tool execution can mutate transcript state, not just return a blob.
The tool progress contract includes:
ToolProgressToolCallProgressProgress = ToolProgressData | HookProgress
So progress reporting is part of the first-class tool API, alongside final results.
At minimum, a tool definition carries:
- primary
name - optional aliases
- input schema
- human-readable
description(...) call(...)isEnabled()isReadOnly(...)isConcurrencySafe(...)
Optional but important fields and hooks include:
- output schema
- input-equivalence check
- destructive-operation marker
- interrupt behavior
- UI-collapse hints
- search hint for deferred tool discovery
This is closer to a typed RPC contract than a loose callback interface.
The file imports the standard tool implementations directly:
AgentToolSkillToolBashToolFileEditToolFileReadToolFileWriteToolGlobToolNotebookEditToolWebFetchToolTaskStopToolBriefToolTaskOutputToolWebSearchToolTodoWriteToolGrepToolAskUserQuestionToolLSPToolListMcpResourcesToolReadMcpResourceToolToolSearchToolEnterPlanModeToolEnterWorktreeToolExitWorktreeToolConfigTool- task CRUD tools
The registry also conditionally loads:
REPLToolSuggestBackgroundPRToolSleepTool- cron tools
RemoteTriggerToolMonitorToolSendUserFileToolPushNotificationToolSubscribePRToolOverflowTestToolCtxInspectToolTerminalCaptureToolWebBrowserToolSnipToolListPeersToolWorkflowToolPowerShellTool- testing-only tools
getAllBaseTools() is the source of truth for the exhaustive base pool in the current environment.
Always-present entries in that return list:
AgentToolTaskOutputToolBashToolExitPlanModeV2ToolFileReadToolFileEditToolFileWriteToolNotebookEditToolWebFetchToolTodoWriteToolWebSearchToolTaskStopToolAskUserQuestionToolSkillToolEnterPlanModeToolBriefToolListMcpResourcesToolReadMcpResourceTool
Conditional entries include search, config, LSP, worktree, team, schedule, browser, remote-trigger, notification, REPL, and ToolSearch surfaces.
The base pool covers these major execution families:
- shell and file operations: Bash, Read, Edit, Write, NotebookEdit, Glob, Grep, PowerShell
- knowledge retrieval: WebFetch, WebSearch, MCP resource list/read, ToolSearch
- planning and workflow control: EnterPlanMode, ExitPlanMode, Brief, TaskOutput, TaskStop
- user interaction: AskUserQuestion, Config
- agents and orchestration: Agent, Skill, SendMessage, team tools, worktree tools
- automation and scheduling: sleep, cron, workflow, remote trigger, monitor, push notification
The runtime does not expose getAllBaseTools() directly to the model.
filterToolsByDenyRules() (262-269) removes tools before the model ever sees them if there is a blanket deny match.
Important comment:
- MCP server-prefix deny rules can hide an entire server’s tool family before prompt assembly
When CLAUDE_CODE_SIMPLE is truthy (271-298):
- normal simple mode exposes only
BashTool,FileReadTool,FileEditTool - REPL-enabled simple mode exposes
REPLToolinstead - coordinator mode can add
AgentTool,TaskStopTool, andSendMessageTool
Before final exposure (300-307), some special tools are excluded from the ordinary prompt-visible tool list:
ListMcpResourcesToolReadMcpResourceTool- synthetic output tool
When REPL mode is enabled (312-320):
- primitive tools are hidden from direct use
- they remain accessible behind the REPL wrapper
The same installed binary can expose very different tool surfaces depending on mode:
- normal mode:
broad tool set from
getAllBaseTools(), minus deny rules and special hidden tools - simple mode:
minimal execution set, usually
Bash,Read,Edit - REPL-enabled simple mode: wrapper-style REPL tool instead of primitive tools
- coordinator mode: regains some orchestration tools even when the rest of the surface is narrow
- REPL mode generally: primitive tools may be hidden and invoked indirectly through the REPL wrapper
This is why tool availability cannot be understood from the registry alone; exposure rewriting is part of the contract.
TOOL_PRESETS currently contains only one preset:
default
That is interesting because the code is preset-ready even though only one preset currently exists.
The tool system is not just “a list of tools”.
The contract has at least five layers:
- type-level interface
- concrete registry
- environment and feature gating
- permission-context pruning
- execution-mode rewriting such as simple mode and REPL mode
That layering is exactly why a separate tool-contract document is useful even though the earlier analysis already covered some specific tools.
Top-level tool implementation families present in the product:
AgentToolAskUserQuestionToolBashToolBriefToolConfigToolEnterPlanModeToolEnterWorktreeToolExitPlanModeToolExitWorktreeToolFileEditToolFileReadToolFileWriteToolGlobToolGrepToolLSPToolListMcpResourcesToolMCPToolMcpAuthToolNotebookEditToolPowerShellToolREPLToolReadMcpResourceToolRemoteTriggerToolScheduleCronToolSendMessageToolSkillToolSleepToolSyntheticOutputToolTaskCreateToolTaskGetToolTaskListToolTaskOutputToolTaskStopToolTaskUpdateToolTeamCreateToolTeamDeleteToolTodoWriteToolToolSearchToolWebFetchToolWebSearchTool
That directory inventory is useful because it reveals the real product capability model, even for tools that are feature-gated in a given build.