Tool calling
Letting a model request function calls, running them, and feeding results back.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
Overview
Tool calling (also called function calling) lets a model ask your code to do something: look up an order, search documents, run a query. You describe each tool with a name, a description and a JSON Schema for its arguments. The model replies with a tool call instead of text, your code runs it, and you send the result back so the model can continue.
The craft is in the tool design. Descriptions should say when to use the tool and when not to; arguments should be few and well typed; results should be concise and include useful error messages. Anything with side effects needs permission checks in your code, because the model's request is only a request.
What you will practise
- Write tool descriptions that say when, and when not, to use each tool
- Keep arguments few and strictly typed
- Return concise results and useful error messages
- Enforce permissions in your code, not in the prompt
Learning paths
- Agents and MCP
An AI agents and MCP course for developers: build a tool-using agent with a clear stop condition, then expose your own data and actions with an MCP server.
- Building with the Claude API
Learn to build with the Claude API from your own code: the Messages API, tool use, structured output and prompt caching, then evaluate and trace what you built.
- MCP in production
An MCP course for production use: connect clients, build and test servers for a team, secure remote servers and keep up with changes to the MCP specification.
Tutorials
- Build a voice agent you can talk to
Stream your microphone to a realtime speech model, call a tool mid-conversation, measure latency and let the user interrupt it.
- Build an agent with the Claude Agent SDK
Built-in tools, a custom tool, a permission callback, a subagent and a project skill, tested before you spend tokens.
- Build an MCP App: an interactive UI inside the chat
Add an interactive UI to a TypeScript MCP server with the MCP Apps SDK: a ui:// resource, a view that calls tools, a test in MCP Inspector and a text fallback.
- Design tools an AI agent can use well
Take one badly designed agent tool, fix its names, descriptions, arguments, errors and output size, and measure the difference with a small eval you can rerun.
- Make an agent survive crashes and restarts with durable execution
Build a durable AI agent with Temporal in Python: tool calls as activities, a worker you kill mid-run that resumes, retries and human approval as a signal.
- Run AI-generated code in a sandbox
Run model-written Python in a throwaway Docker container, then in an E2B sandbox, with time, memory, network and file limits, and a test suite of hostile code.
- Build your first agent in Python
Three tools, a hard turn limit, a clear stop condition and a log of every tool call it makes.
- Build your first agent in TypeScript
Tools that search and read notes, a step limit, a clear stop condition and logged steps.
- Build an MCP server in Python with FastMCP
Build a small MCP server in Python with FastMCP, test its tools in MCP Inspector without a model, then connect it to Claude Code, Cursor or another MCP host.
- Build an MCP server in TypeScript
Build a small MCP server with the official TypeScript SDK v2, test it from the command line and in MCP Inspector, then connect it to Claude Code or Cursor.
- MCP explained: hosts, clients, servers and transports
What MCP is and how the Model Context Protocol connects AI apps to tools and data: hosts, clients, servers, transports and what the 2026-07-28 spec changed.
Workflow recipes
- Build an MCP server for an internal API
Two read-only tools, tested in MCP Inspector and called from Claude Code, Codex or Cursor.
Articles
- Code Mode: when an agent writes code to call its tools
Claude Code's experimental Code Mode has Claude write JavaScript that calls its tools. How it works and what it changes for permissions, hooks and sandboxing.
- Agent frameworks compared: Claude Agent SDK, OpenAI Agents SDK, LangGraph, Pydantic AI, Mastra, Google ADK
Six agent frameworks on one fixed table: language, durable execution, tracing, MCP support and lock-in, with notes on which kind of project each one fits.
- What is an AI agent? A plain explanation
An AI agent is a language model that uses tools in a loop until a task is done. What that means in practice, what agents are good at and where they go wrong.
Tools for this skill
9 of 14 tools tagged with this skill.
Agent Development Kit (ADK)
Google's code-first framework for building, evaluating and deploying agents.
AI SDK
TypeScript toolkit for streaming, tool calls and agents across model providers.
Claude Agent SDK
Build agents on the same harness that powers Claude Code.
E2B
Open-source cloud sandboxes for code that agents run.
FastMCP
Pythonic framework for building MCP servers and clients with decorators.
LangChain
Components and integrations for building LLM applications.
Microsoft Agent Framework
Microsoft's open-source framework for agents and multi-agent workflows.
Model Context Protocol
Open protocol for connecting AI applications to tools and data.
OpenAI Agents SDK
Lightweight Python framework for agents, handoffs and guardrails.
Key terms
Words you will meet while learning this, defined in the glossary.
- Programmatic tool calling
A model using tools by writing a short program that makes several calls and filters the results, instead of one call per turn.
- Tool calling
A model emitting a structured request to call a defined function, which your code runs and whose result is then fed back to the model.