Skip to content

Build an agent

Vercel AI SDK tools: tool calling and agents, with an inbox and number for the agent

How tools, tool calling and agents work in the Vercel AI SDK, from its own documentation, and how to give an agent an inbox, a phone number and a browser it can use for real.

In the Vercel AI SDK a tool is made with tool(): a description, an input schema and an execute function. Pass tools to generateText with a stopWhen limit so the model can call them in steps, or put them in a ToolLoopAgent. To give the agent real-world tools such as an inbox or a phone number, wrap each call as a tool or load a server’s tools over MCP.

On this page
  1. The kinds of tool in the AI SDK
  2. Making a tool and using it
  3. Agents: the same loop, packaged
  4. Loading tools from an MCP server
  5. Giving the agent real-world tools
  6. One agent, one identity, every piece the job needs
  7. Questions about Vercel AI SDK tools

A tool lets a language model do something besides write text. The Vercel AI SDK, a TypeScript toolkit for building with models, runs a loop: the model reads the prompt, may call a tool, gets the result and carries on, so the answer can rest on real data and real actions. That loop is tool calling, and an agent is a model that keeps going through it until the task is done.

Everything here about the SDK comes from its own documentation, read on 23 November 2026. The SDK changes between versions, so confirm names against the pages linked for the version you install.

The kinds of tool in the AI SDK

The AI SDK’s tools page describes 4 kinds:

  • Function tools. You give a description, an input schema and an optional execute function. They work with any provider and give you full control.
  • Dynamic tools. Function-style tools whose input and output types are not known when you write the code, such as tools loaded from an MCP server or a database.
  • Provider-defined tools. The provider sets the schema and description, and you supply the execute function. Anthropic’s bash tool is the docs’ example.
  • Provider-executed tools. The provider runs them on its own servers, so you only configure them. OpenAI’s web search is the docs’ example.

The Model Context Protocol (MCP) is the standard way an agent connects to another service’s tools, and the AI SDK loads those as dynamic tools. Most builders start with function tools, because anything you can call from code becomes a tool.

Making a tool and using it

The docs show a tool with 3 parts, using the tool helper from the ai package and Zod, a library that describes and checks the shape of data:

  1. A description, such as “Get the weather in a location”. The model reads it to decide when to call the tool, so write it for the model.
  2. An inputSchema, a Zod object such as one location string with its own description. It tells the model what arguments the tool takes.
  3. An execute function, which receives the arguments and returns the result. In the docs’ example it returns a temperature and conditions.

You pass tools to generateText in a tools object, keyed by name, with a prompt and a model. A tool with an execute function runs automatically when the model calls it. Setting stopWhen: isStepCount(10), as the docs’ example does, lets multi-step calls continue for up to 10 steps, so tool results go back to the model before the SDK stops it.

Agents: the same loop, packaged

The AI SDK’s agents page documents the ToolLoopAgent class. You create it with a model, instructions and tools, plus a stopWhen condition. The page gives the default as 20 steps, where each step is one model generation producing text or a tool call, and says you can pass an array of conditions. You call agent.generate({ prompt }) to get a result with text, or stream for a text stream.

Two habits keep an agent safe. Set a step limit you can afford, because a loop that keeps calling tools keeps costing money. And give each tool a narrow job with a clear description, so a mistake in one call has a small effect.

Loading tools from an MCP server

The AI SDK’s MCP page shows a client made with createMCPClient, imported from @ai-sdk/mcp. You give it an HTTP transport with the server’s address and optional headers such as an Authorization bearer token, call mcpClient.tools() to get the server’s tools, pass them to generateText or streamText, and close the client when you finish, in a finally block for requests that don’t stream. The page also recommends rejecting redirects, and passing a guarded fetch if the server address comes from users.

The trade against a function tool is who maintains it. With MCP the service publishes its tools and you connect. With a function tool you write and own the call. AI agent tools versus MCP goes through it.

Giving the agent real-world tools

Weather and web search reach public information. An agent that acts as a buyer, a booker or a support rep also needs an address of its own to receive a confirmation link, a phone number to receive the 6-digit code, and a browser that stays signed in. Bought one by one, each is another vendor, key and bill.

Obsession is the toolkit for AI agents: phone numbers, inboxes, browsers and sandboxes on one API and one bill. Its developers page shows each piece as one call. Here is the AI SDK pattern with 1 of them, using the call names the page gives:

  1. Create the client and the inbox. Build new Obsession({ apiKey: process.env.OBSESSION_API_KEY }), then call obsession.inboxes.create() once. The inbox has its own address, inbox.address.
  2. Make a sendEmail tool. Use tool() with a description (“Send an email from the agent’s own inbox”), an inputSchema of to, subject and text strings, and an execute function that calls inbox.send({ to, subject, text }).
  3. Run the agent. Create a ToolLoopAgent with your model, the instruction “Book tables by email from your own address.” and the sendEmail tool, then call generate with “Ask bookings@larkfield.example for 2 at 19:30 on Friday.”
  4. Receive the reply. Each new email reaches your webhook as email.received, so your code passes it to the agent as the next prompt.

A number follows the same pattern. obsession.numbers.create({ country: "US" }) gives the agent a number, number.sms sends a text, and each text back arrives as sms.received.

One agent, one identity, every piece the job needs

Wrapping 3 vendors as 3 sets of tools works. It breaks at the seams: the code arrives by text at one vendor while the browser waits at another, and the email thread and the call log live in separate places. Obsession puts the pieces under one persona: obsession.personas.create({ inbox: true, phone: "US", browser: true }) gives the agent an inbox, a number and a browser as one identity, free while it waits.

  • The inbox: email for agents sends and receives, keeps threads and attachments, and reads codes and links out of each email. An inbox is $0.50 a month.
  • The number: a phone number sends and receives texts and takes calls, through the voice agent you bring or connect. A US number is $2 a month and a text $0.015.
  • The browser: a cloud browser keeps its logins between runs, so the agent signs in once and stays signed in.
  • The event log: every email, text and page lands in one log, dated, so you can see why the agent did what it did.

If your agent needs only one piece, one specialist is enough, and the best email API for AI agents compares 7. AgentMail, Twilio, Browserbase and E2B, or every piece on one API sets 4 vendors beside one. Obsession’s MCP server gives the same calls as tools to any MCP client, and its address comes with your API access. See the email MCP server guide for how email tools work. Teams who don’t code can run a blueprint such as the Inbox agent. With its own number and browser, the same agent can also confirm appointments by text, chase a supplier’s quote or watch a competitor’s sign-up, whether you run one agent or ten thousand.

Questions about Vercel AI SDK tools

You define a tool with a description, an input schema and an execute function, and pass it to generateText or an agent. The model decides when to call it, the SDK runs execute with the arguments and returns the result to the model, and the loop continues until the step limit or a final answer.

Through stopWhen. Setting it to isStepCount(10) lets multi-step calls continue for up to 10 steps, so tool results go back to the model.

It is the SDK’s agent class. You give it a model, instructions, tools and a stopWhen condition, and call generate with a prompt. It repeats model calls and tool calls until it stops, with a default of 20 steps.

Yes. createMCPClient from @ai-sdk/mcp connects to a server over HTTP, mcpClient.tools() returns its tools, and you pass them to generateText or streamText. Close the client when you finish.

AI agent tools versus MCP

Wrap a call that creates an inbox or number as a tool, or load a server’s tools over MCP. With Obsession, obsession.inboxes.create() gives the agent an address and obsession.numbers.create gives it a number, and replies reach your webhook as events.

See the API and MCP

With a provider-defined tool the provider sets the schema and you supply the execute function. A provider-executed tool runs on the provider’s own servers, so you only configure it.

ShareLinkedInX

Sources

In the order the article cites them. Every link was checked on 23 Nov 2026.

  1. ToolsAI SDK documentation
  2. Building agentsAI SDK documentation
  3. MCP toolsAI SDK documentation

What should your first AI agent do?