C.W.K.
Stream
Lesson 04 of 06 · published

Server Tools: Web Search, Code Execution, Computer Use

~16 min · server-tools, web-search, code-execution, computer-use

Level 0Observer
0 XP0/64 lessons0/13 achievements
0/150 XP to next level150 XP to go0% complete

Three classes Anthropic runs for you

Beyond your custom tools, Anthropic offers server tools — capabilities Anthropic implements and runs. The first three to know: web_search (live internet search), code_execution (Python sandbox for math/data), and computer_use (control a virtual desktop). You pass them in tools just like custom ones; the API handles the execution.

web_search and code_execution are productivity wins

web_search adds 2025+ knowledge to a 2024-cutoff model. code_execution lets the model do exact arithmetic instead of guessing. Both are billed; check pricing pages. Both have rate limits and configuration knobs (max searches per request, sandbox memory).

computer_use is a different beast

computer_use streams screenshots and accepts mouse/keyboard actions. It is intended for automation that drives a virtual desktop. Use cases: filling forms in legacy GUIs, browsing where headless scraping fails, accessibility testing. Power tool — pair with strict permissions.

Principle: Server tools shrink the surface area of capability you must build. Use them where they fit; do not rebuild what Anthropic ships.

Code

Adding web_search and code_execution·python
resp = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=2048,
    tools=[
        {
            "type": "web_search_20250305",
            "name": "web_search",
            "max_uses": 5,
        },
        {
            "type": "code_execution_20250522",
            "name": "code_execution",
        },
        # ... your custom tools alongside
    ],
    messages=[{"role": "user", "content": "What was the closing S&P 500 yesterday? Show the calculation in Python."}],
)
computer_use sketch (Python)·python
# computer_use requires a sandboxed desktop; this is the request shape only.
resp = client.beta.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=4096,
    tools=[
        {
            "type": "computer_20241022",
            "name": "computer",
            "display_width_px": 1280,
            "display_height_px": 720,
        }
    ],
    betas=["computer-use-2024-10-22"],
    messages=[{"role": "user", "content": "Open Firefox and go to anthropic.com"}],
)
# Each tool_use block is a coordinate-driven action; you stream screenshots back as tool_result.

External links

Exercise

Replace one of your custom tools with a server tool where appropriate (web_search instead of a wrapped Google API, code_execution instead of a Python eval bridge). Compare reliability and cost.
Hint
If your custom tool was rate-limited, server tools usually pay better — but check the pricing page for your specific volume.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.