Advanced Tool Use in Claude Code

From Blog Concept to Practical Workflow: Based on Anthropic’s engineering post on advanced tool use, this article explains how to apply those ideas in a real Claude Code setup.

Background

Anthropic recently introduced three important concepts in advanced tool use:

  1. Tool Search Tool
  2. Programmatic Tool Calling (PTC)
  3. Tool Use Examples

While these are described at the API level, many of the same benefits can already be achieved in Claude Code (CLI + MCP) with the right configuration.

This post explains how.


1️⃣ Tool Search in Claude Code

When you configure many MCP servers (GitHub, Jira, DB, internal tools, etc.), loading all tool schemas into context wastes tokens.

Claude Code supports deferred tool loading via MCP Tool Search.

# Default (auto enable if MCP tools exceed ~10% of context)
claude

# Force enable
ENABLE_TOOL_SEARCH=true claude

# Enable earlier (e.g. 5% of context)
ENABLE_TOOL_SEARCH=auto:5 claude

# Disable (load everything)
ENABLE_TOOL_SEARCH=false claude

When should you enable it?

If:

  • You maintain many MCP servers
  • Your tool schemas are large
  • You hit context pressure often

Then enable it permanently:

export ENABLE_TOOL_SEARCH=true

Why this matters

Instead of loading 100+ tools into context:

Claude → Search MCP → Load only relevant tools

This reduces:

  • Context bloat
  • Token usage
  • Tool selection confusion

2️⃣ Simulating Programmatic Tool Calling (PTC)

PTC in Anthropic’s API means:

Claude writes Python that calls tools inside a container, and intermediate results do not enter model context.

Claude Code does not directly expose managed PTC, but you can replicate the core idea.

Pattern A: Offload Heavy Work to Scripts

Instead of:

Claude repeatedly calling tools and reasoning over large outputs

Do this:

  1. Ask Claude to generate a small script.
  2. Run it locally.
  3. Return only aggregated results.

Example:

# Ask Claude:
# "Write a Python script to scan all logs and output only error counts per service."

Then:

python analyze_logs.py

Only feed the summarized output back to Claude.

This mirrors the main benefit of PTC:

  • Intermediate data stays outside the model context.

Pattern B: Wrap Multi-Step Logic into MCP Prompts

Instead of:

Search → Fetch → Filter → Format → Summarize

Define an MCP prompt that performs orchestration server-side.

Then invoke:

/mcp__yourserver__analyze_project

Benefits:

  • Cleaner interaction
  • Fewer tool calls
  • Lower reasoning overhead

3️⃣ Teaching Better Tool Use

Schemas alone are not enough.

To improve tool usage quality:

3.1 Improve MCP Server Instructions

Inside your MCP server definition, clearly describe:

  • When the tool should be used
  • What not to use it for
  • Output format expectations

Tool search becomes significantly more accurate when instructions are explicit.


3.2 Add Project-Level Instructions

Create a CLAUDE.md in your repo:

# Tool Usage Policy

- Use GitHub MCP for PR inspection
- Use local grep before large repository search
- Always summarize tool outputs before analysis

Claude Code treats this as workflow guidance.


4️⃣ Advanced: Hooks for Enforced Behavior

Claude Code supports hooks such as:

  • PreToolUse
  • PostToolUse

You can use them to:

  • Block dangerous tools
  • Automatically summarize large outputs
  • Redirect large outputs to files

Example idea:

PostToolUse:
If output > 5000 tokens → write to file → return summary

This creates a controlled, production-style tool environment.


Practical Configuration

If you:

  • Run multiple MCP servers
  • Work on large repositories
  • Use Claude Code daily for research or infra

I recommend:

export ENABLE_TOOL_SEARCH=true
export MAX_MCP_OUTPUT_TOKENS=50000

Then adopt:

  • Script-first heavy analysis
  • MCP prompt orchestration
  • Clear project tool instructions
  • Hooks for guardrails

Conceptual Mapping

Anthropic API ConceptClaude Code Equivalent
Tool Search ToolMCP Tool Search
Programmatic Tool CallingLocal script orchestration
Tool Use ExamplesMCP instructions + CLAUDE.md
Container isolationLocal execution boundary

Final Thoughts

Advanced tool use is not about “more tools.”

It is about:

  • Context efficiency
  • Delegation
  • Orchestration
  • Guardrails

Claude Code already supports most of the practical mechanisms — if configured correctly.

The difference between a basic assistant and a production agent is not model size.

It is tool discipline.