Integration
Mastra Email Integration
Give Mastra agents email: wrap the deadsimple-email npm SDK with createTool and Zod, or connect all 14 tools at once with @mastra/mcp.
Why This Pairing Works
Mastra (YC W25, 1.0 released January 2026) has become the fastest-growing TypeScript agent framework as of August 2026, built by the team behind Gatsby on top of the Vercel AI SDK. Its tool model — createTool with Zod schemas — maps one-to-one onto Dead Simple's typed npm SDK, and its @mastra/mcp package speaks directly to Dead Simple's hosted MCP server. To be transparent: Dead Simple ships native adapters for LangChain, CrewAI, AutoGen, LlamaIndex, and the OpenAI Agents SDK; for Mastra the supported paths are the two on this page.
Custom Tools with createTool + Zod
Define exactly the email surface your agent needs. The deadsimple-email SDK handles auth and requests:
import { createTool } from "@mastra/core/tools"; import { z } from "zod"; import { DeadSimple } from "deadsimple-email"; const dse = new DeadSimple(process.env.DSE_API_KEY!); export const sendEmail = createTool({ id: "send-email", description: "Send a plain-text email from a Dead Simple inbox", inputSchema: z.object({ inboxId: z.string().describe("Inbox to send from, e.g. inb_a1b2c3"), to: z.string().email(), subject: z.string(), body: z.string(), }), outputSchema: z.object({ messageId: z.string() }), execute: async ({ context }) => { const result = await dse.messages.send({ inboxId: context.inboxId, to: context.to, subject: context.subject, textBody: context.body, }); return { messageId: result.message_id }; }, }); export const waitForEmail = createTool({ id: "wait-for-email", description: "Block until a new email arrives in an inbox, then return it", inputSchema: z.object({ inboxId: z.string(), fromContains: z.string().optional(), }), execute: async ({ context }) => { const msg = await dse.messages.waitFor(context.inboxId, { fromContains: context.fromContains, timeoutMs: 120_000, }); return msg ?? { error: "No matching email arrived before the timeout" }; }, });
Hand the tools to an agent:
import { Agent } from "@mastra/core/agent"; import { openai } from "@ai-sdk/openai"; import { sendEmail, waitForEmail } from "../tools/email"; export const emailAgent = new Agent({ name: "email-agent", instructions: "You handle email through Dead Simple inboxes.", model: openai("gpt-4o"), tools: { sendEmail, waitForEmail }, });
All 14 Tools via @mastra/mcp
Mastra's MCPClient connects to remote MCP servers over streamable HTTP. Point it at Dead Simple's hosted server and skip the wrappers entirely:
import { MCPClient } from "@mastra/mcp"; import { Agent } from "@mastra/core/agent"; import { openai } from "@ai-sdk/openai"; const mcp = new MCPClient({ servers: { deadsimple: { url: new URL("https://api.deadsimple.email/mcp"), requestInit: { headers: { Authorization: `Bearer ${process.env.DSE_API_KEY}` }, }, }, }, }); export const emailAgent = new Agent({ name: "email-agent", instructions: "You handle email through Dead Simple inboxes.", model: openai("gpt-4o"), tools: await mcp.getTools(), });
The agent gets create_inbox, list_inboxes, delete_inbox, send_email, read_messages, read_message, reply_to_message, forward_message, wait_for_email, get_verification_code, get_verification_link, list_threads, read_thread, and get_usage. The verification tools are the ones browser-less signup flows live on: they block until the email lands and return the extracted code or link.
Why Dead Simple Fits Mastra
- TypeScript end to end. The npm SDK is fully typed (CJS + ESM), so
createToolwrappers stay type-safe from Zod schema to API response. - Two-way inboxes, not a send API. Mastra agents can read, reply with threading, and wait for inbound mail — workflows a transactional email provider can't cover.
- Works in workflows too. The same SDK calls drop into Mastra workflow steps for deterministic pipelines (send, wait, branch on the reply).
- Deliverability handled. SPF, DKIM, DMARC, and bounce monitoring run on the Dead Simple side.
- Free plan is enough to build. Five inboxes and 5,000 emails/month, no card required.
FAQ
No. Mastra tools are createTool definitions with Zod schemas, so wrapping the deadsimple-email npm SDK is a short, honest snippet you own — shown on this page. If you want all 14 email tools without writing wrappers, use @mastra/mcp with the hosted MCP server.
createTool gives you a curated tool surface with your own descriptions and Zod validation — best for production agents. MCPClient gives the agent all 14 Dead Simple tools in a few lines — fastest to start and good for agents that plan their own email workflows. Both hit the same API.
Yes. Dead Simple inboxes are real two-way mailboxes: agents can list and read messages, reply with automatic threading, wait for a specific email to arrive, and extract OTP codes and magic links from verification emails.
Any provider Mastra supports through the Vercel AI SDK — OpenAI, Anthropic, Google, and more. The email tools are provider-agnostic TypeScript functions.
5 inboxes and 5,000 emails per month, no credit card required — enough to build and run a small Mastra agent in production.
Related Integrations
- Vercel AI SDK — the tool layer Mastra builds on, with ready-made Dead Simple tools
- TypeScript SDK — the client these tools wrap
- MCP Server — the server behind the MCPClient option
- LangChain — native Dead Simple toolkit for Python agents
- Browser Use — email verification codes for browser agents