Email Tools for Vercel AI SDK Agents

Add email capabilities to your TypeScript AI agents with MultiMail's API. Send, read, and reply to email with configurable human oversight.


The Vercel AI SDK is a TypeScript-first toolkit for building AI applications. Its tool system lets you define typed functions that LLMs can call, making it straightforward to add email capabilities through MultiMail's REST API.

MultiMail gives your Vercel AI SDK agents a complete email backend: sending, receiving, replying, thread tracking, and contact management. The default gated_send oversight mode means your agent composes emails but delivery waits for human approval, which fits naturally into the AI SDK's streaming UI patterns.

Whether you are building a Next.js chatbot that handles customer email or a standalone agent that manages an inbox, the combination of Vercel AI SDK's type-safe tools and MultiMail's email API provides a production-ready foundation.

Built for Vercel AI SDK developers

TypeScript-Native Integration

Both the Vercel AI SDK and MultiMail's API are TypeScript-friendly. Define email tools with Zod schemas for full type safety, and get structured responses you can render directly in your UI.

Streaming-Compatible

The Vercel AI SDK supports streaming tool calls. Your agent can stream its reasoning while making MultiMail API calls, showing users the email being composed in real time before it enters the approval queue.

Human-in-the-Loop by Default

MultiMail's gated_send mode pairs well with the AI SDK's UI components. Show users a preview of the composed email and let them approve it through your app's interface or the MultiMail dashboard.

Edge-Ready

The Vercel AI SDK runs on edge runtimes. MultiMail's REST API is edge-compatible with no Node.js-specific dependencies, so your email-capable agent works in serverless and edge environments.

Structured Tool Outputs

MultiMail returns structured JSON from every endpoint. The AI SDK can parse these into typed objects, letting your agent reason about inbox contents, thread history, and contact data with full type information.


Try it with your agent

No code, no dashboard. Paste this to your AI agent — it connects MultiMail, creates an inbox, and builds the flow for you.

1. Read https://multimail.dev/llms.txt, then connect the MultiMail MCP server exactly as described there. Use the MultiMail MCP tools to create a free inbox, keep the mailbox oversight mode set to gated_send, and set up a verified sending domain for the agent. 2. In my TypeScript Vercel AI SDK agent, install and use the real MCP integration: create the MultiMail client with createMCPClient from @ai-sdk/mcp, load the available tools with mcpClient.tools(), and pass those tools into generateText or streamText through the AI SDK tools option. Close the MCP client when the request or stream finishes. 3. Give the agent three email abilities through those MultiMail MCP tools: check the inbox for recent mail, draft a reply for a selected message without sending it, and send or schedule email only through MultiMail. Do not create custom email endpoints or bypass the MCP tools. 4. Send one test email from the verified sender to my own address. The body should say this is a MultiMail test from a Vercel AI SDK agent, ask me to reply, then check the inbox and draft a short reply to my response. 5. Keep gated_send enabled for the whole test. Before any outbound email actually sends, show me the proposed recipient, subject, and body, wait for my approval through MultiMail’s gated_send review flow, and only continue after I approve.

Step by step

1

Create a MultiMail Account

Sign up at multimail.dev, create a mailbox, and generate an API key. Your key starts with mm_live_.

2

Install the AI SDK

Install the Vercel AI SDK and your preferred model provider.

3

Define Email Tools

Create tool definitions using the AI SDK's tool function with Zod schemas for parameters. Implement the execute function to call MultiMail's REST API.

4

Create Your Agent

Use generateText or streamText with your email tools and a system prompt that explains the mailbox context and oversight mode.

5

Handle Oversight

In gated_send mode, inform users when emails are pending approval. Optionally build approval UI in your app or direct users to the MultiMail dashboard.


Common questions

Can I use the MultiMail MCP server with the Vercel AI SDK?
The Vercel AI SDK currently focuses on its own tool format rather than MCP. The recommended approach is to define MultiMail tools using the AI SDK's tool function with direct REST API calls. This gives you full type safety with Zod schemas and works seamlessly with streaming.
Does this work with Next.js App Router?
Yes. Define your email tools in a server-side module and use them in route handlers under app/api/. The streamText function returns a response compatible with the AI SDK's useChat hook on the client side. Your email agent streams its reasoning while making API calls.
How do I store the MultiMail API key securely?
Store your API key in an environment variable (MULTIMAIL_API_KEY) and access it server-side only. In Next.js, add it to .env.local without the NEXT_PUBLIC_ prefix to ensure it is never exposed to the client. The tool execute functions run server-side, so the key stays secure.
Can the agent handle multiple mailboxes?
Yes. Add a listMailboxes tool that calls GET /mailboxes, and have the agent select the appropriate mailbox based on the user's request. You can also hardcode mailbox IDs in the system prompt if the agent always uses the same mailboxes.
What model providers work with this setup?
Any model provider supported by the Vercel AI SDK works, including OpenAI, Anthropic, Google, and Mistral. The email tools are model-agnostic — they are plain functions that any tool-calling model can invoke. Choose a model that supports tool use for best results.
How do I show email approval status in my UI?
After a send_email tool call returns a pending status, you can poll the MultiMail API for updates or use webhooks to get notified when emails are approved or rejected. Display this status in your chat UI so the user knows which emails are awaiting their review.

Explore more

The only agent email with a verifiable sender

Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a hosted MCP server. Formally verified in Lean 4.