Skip to main content

Tool Sources

Where do the model's tools come from? Claude Code merges tools from four sources into a single array before every API call:

Sources
Built-in Tools (src/tools/)
MCP Server Tools
Plugin Tools
Skill Tool
Merge
Unified tools array — included in every API call

1. Built-in Tools

The base built-in registry comes from getAllBaseTools() in src/tools.ts. Most of those tools live under src/tools/, and some are conditionally included behind feature flags or environment checks:

  • File operations — Read, Write, Edit, Glob, Grep, NotebookEdit
  • Shell — Bash, PowerShell
  • Web — WebSearch, WebFetch
  • Agents — Agent, SendMessage
  • Tasks — TaskCreate, TaskUpdate, TaskList, TaskGet, TaskOutput, TaskStop, TodoWrite
  • Planning — EnterPlanMode, ExitPlanMode, EnterWorktree, ExitWorktree
  • Infrastructure — Skill, ToolSearch, AskUserQuestion, Config, Sleep, LSP

The Built-in Tools catalog focuses on the stable/common surface. The Tool Definitions appendix is where the feature-gated, testing-only, and source-only tools live.

2. MCP Server Tools

MCP (Model Context Protocol) servers expose tools that Claude Code wraps at runtime. The wrapper implementation lives in src/tools/MCPTool/, but those wrappers are not part of getAllBaseTools(). Each connected MCP tool becomes a model-visible tool named mcp__{server}__{tool}:

src/tools/MCPTool/MCPTool.ts (simplified)
// An MCP server "github" exposes a tool "create_issue"
// → becomes tool named "mcp__github__create_issue"

const mcpTool = {
name: `mcp__${serverName}__${toolName}`,
inputSchema: toolDefinition.inputSchema, // from MCP server

async call(args, context) {
return await mcpClient.callTool(serverName, toolName, args)
},
}

MCP tools go through the same permission checks and execution pipeline as built-in tools. Servers are configured at three scopes:

ScopeConfig FileWho Controls
Project.mcp.json in project rootProject maintainers
User~/.claude/mcp.jsonIndividual user
EnterpriseManaged settingsOrganization admins

MCP servers also expose resources (read-only data) accessed via the built-in ListMcpResources and ReadMcpResource tools, and may require authentication handled by the dynamically named McpAuth tool.

For full details on server types, configuration, and connection lifecycle, see MCP Integration.

3. Plugin Tools

Plugins are full CLI extensions that can register additional tools. A plugin declares its capabilities in a manifest, and its tools are loaded dynamically during initialization:

Plugin tool registration (simplified)
// Plugin manifest declares tools
{
name: "my-plugin",
capabilities: {
tools: [
{
name: "MyCustomTool",
inputSchema: { ... },
handler: "./tools/my-custom-tool.js"
}
]
}
}

Plugin tools are merged into the same tools array and follow the same execution pipeline. They can also add commands and hooks.

For plugin authoring and lifecycle details, see Plugins & Skills.

4. Skill Tool

Skills are lightweight prompt templates (markdown files with YAML frontmatter). They're not tools themselves — they're PromptCommands invoked via /skill-name. However, the model can invoke skills programmatically via the built-in Skill tool:

src/tools/SkillTool/SkillTool.ts
Skill({
skill: "commit",
args: "-m 'Fix auth bug'"
})
// → Loads the skill's markdown prompt
// → Injects it into the conversation

The Skill tool is an internal infrastructure tool — the model uses it to invoke skills discovered via ToolSearch.

Registration Flow

All sources merge during initialization in main.tsx:

src/main.tsx (simplified)
// 1. Load built-in tools
const builtinTools = loadBuiltinTools() // Base registry from src/tools.ts

// 2. Connect MCP servers, wrap their tools
const mcpTools = await connectMCPServers() // mcp__{server}__{tool}

// 3. Load plugin tools
const pluginTools = await loadPlugins() // From plugin manifests

// 4. Merge into single array
const allTools = [...builtinTools, ...mcpTools, ...pluginTools]

// 5. Include in every API call
api.call({
tools: allTools.map(t => t.inputSchema), // JSON Schema definitions
// ...
})

Every tool — regardless of source — goes through the same execution pipeline: validation, permission check, hooks, execution, result formatting.

Key Source Files

FilePurpose
src/tools.tsBase built-in registry and conditional inclusion logic
src/tools/Built-in tool implementations
src/tools/MCPTool/MCP tool wrapper
src/services/mcp/MCP client and configuration
src/services/plugins/Plugin management
src/tools/SkillTool/Skill invocation tool