Topic 1 of 4 · 5 min read
Client tools versus provider-hosted tools
Goal: Decide whether a capability should be a provider-hosted tool or a tool your own code executes, and justify the choice.
A client tool runs in your code; a provider-hosted tool runs on the provider's servers. Pick by asking who should execute the capability, who should see the data, and who should be billed.
Check yourself · 1 of 3
A tool call arrives as a tool_use block. Who runs it?
Why it matters
The same model call can look identical in both cases: you list a tool, the model asks for it, an answer comes back. But the data path, the cost and the failure handling are different. Choosing wrong either leaks data you meant to keep or makes you rebuild something the provider already runs.
How the two differ
| Client tool | Hosted (server) tool | |
|---|---|---|
| Who executes | Your code | The provider |
| Response block | tool_use; you send back a tool_result |
server_tool_use plus a result block, already filled in |
| Round trips | You loop until the model stops asking | One request; the provider loops internally |
| Data that leaves | Only what you put in the result | Whatever the tool sends or fetches on the provider side |
| Billing | Your own compute | Per-use fees plus tokens for the results |
| Examples | Your database, your internal API | Web search, code execution, file search |
With Claude, a hosted tool call shows up as a server_tool_use block whose id starts with srvtoolu_. You never answer it. A long turn can return stop_reason: "pause_turn"; you send the assistant message back unchanged to continue.
How to decide
- Does it need your private systems or credentials? Then it is a client tool. A hosted tool cannot reach your database.
- Is it a generic capability the provider already offers? Search the web, run Python on a file. Use the hosted tool and skip the plumbing.
- Do you need to log, approve or filter every call? A client tool gives you the hook. With a hosted tool you see the call only after it happened.
- What does it cost per use? Search is billed per search on top of tokens. Estimate calls per request before you ship.
- Does the data policy allow it? Anything a hosted tool touches is processed by the provider.
Before and after
Weak: "We will add web search by writing our own scraper tool and a loop that feeds pages back." Weeks of work, and your scraper becomes the thing to maintain.
Better: "Web search is generic and public, so we use the provider's hosted search with a domain allow list. Order lookup needs our database, so that stays a client tool." Each capability sits where its data lives.
tools = [
{"type": "web_search_20250305", "name": "web_search", "max_uses": 3},
{"name": "get_order", "description": "Look up an order by id",
"input_schema": {"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"]}},
]
What goes wrong
- Treating a hosted tool as free. Each call has a fee and its results count as input tokens.
- Expecting a hook that is not there. You cannot veto one hosted search before it runs, only limit them up front.
- Forgetting the mixed case. One turn can contain a server tool call and a client tool call. You must still answer the client call and keep the same
toolsarray.
Examples
Choosing per capability
A support bot needs three things. Public product docs: hosted web search limited to the company's docs domain. Order status: a client tool that queries the orders database with the customer's id. Calculating a refund from a spreadsheet: hosted code execution on an uploaded file. One request can use all three.
Reading the response
The response holds a server_tool_use block named web_search, a web_search_tool_result block right after it, then text. Nothing for you to execute. A tool_use block named get_order in the same response is yours: run it and reply with a tool_result.
Key points
- A client tool runs in your code and needs a tool_result from you; a hosted tool runs on the provider and returns its result in the same response.
- Anything that needs your private systems or credentials must be a client tool.
- Hosted tools bill per use on top of tokens, so estimate calls per request before launch.
- With a hosted tool you can limit calls up front but cannot approve each one before it runs.
- A single turn can mix both kinds, and you still answer the client tool calls.
Common mistakes
- Building a client tool for something the provider already hosts and then maintaining it.
- Putting a database lookup behind a hosted tool idea and finding it cannot reach private systems.
- Ignoring per-use fees when estimating the cost of a feature.
- Replying to a hosted tool call with a tool_result, or dropping the tools array on the follow-up request.
Check yourself · 2 of 3
A tool must read rows from your private Postgres database. Which kind fits?
Check yourself · 3 of 3
Which is a real cost difference of hosted web search compared with a client tool you wrote?
Practice items, not counted towards your mastery.
Start here
- Web search tool (Claude docs) (opens in a new tab)DocsFree
Parameters, response blocks, citations and the $10 per 1,000 searches price.
- Code execution tool (Claude docs) (opens in a new tab)DocsFree
Container limits, file upload, result blocks and error codes.
- Server tools (Claude API docs) (opens in a new tab)DocsFree
How server_tool_use blocks, pause_turn and domain filtering work for provider-run tools.