🧩tool() Helper
Also known as @tool decorator, Agent SDK custom tool, Claude Agent SDK tool() Helper
The helper that makes your own tool. You give it a name, a note on what it does, its inputs and the code to run.
Think of it like
It is like a new button with its job written on it.
Example
Mia wants her agent to look up orders. She writes a get_order tool with tool(), with the order ID as its only input.
Why it matters
Built-in tools reach files and the shell. Your own tools reach your own systems.
Definition
Example code
typescript
const getTemp = tool(
"get_temperature",
"Get the temperature at a place",
{ city: z.string() },
async ({ city }) => ({ content: [{ type: "text", text: await lookUp(city) }] }),
);Common mistake
Key takeaways
- 1Four parts. Name, description, schema, handler.
- 2Zod or a dict. For the schema.
- 3isError for failures. Claude reads it.