guide

How to Send Email From an AI Agent (MCP, SDK and REST): A Trial-Conversion Agent Built Three Ways

One growth agent, a day-7 trial summary, wired three ways: an MCP connection for Claude or Cursor, a Vercel AI SDK tool for production, and plain REST for a scheduled job.

By Admaxxer Team • November 12, 2026 • 8 min read

Direct answer. To send email from an AI agent, give the agent its own capped API key on AgentiSend and connect it one of three ways: the hosted MCP server at https://api.agentisend.com/mcp for Claude, Cursor or Codex, a sendEmail tool built on the agentisend SDK for agents you deploy, or a plain POST /emails request for a scheduled job. All three hit the same API, so the key's send budget, the loop guard and the kill switch apply whichever route the agent takes. Choose a different provider when the agent's main job is reading a mailbox of its own (AgentMail is built for that) or when per-message price outranks everything (Amazon SES).

The example throughout is a growth agent with one job. On day 7 of every free trial it reads the account's usage, writes a short summary of what the team has set up and what it has not, and emails the trial owner. A SaaS with 600 new trials a month sends about 600 of these, plus the occasional follow-up when a trial owner replies.

How we put this together

Our editors read AgentiSend's API, MCP and framework documentation and the other providers' documentation between 28 September and 10 November 2026, and each provider's pricing page on 9 November 2026. We did not run our own send tests; the code below follows the shapes in AgentiSend's published examples.

Pick the route first

MCP SDK tool REST
Best for A person working with Claude, Cursor or Codex An agent you deploy, in TypeScript or Python A cron job, a workflow tool, any language
Where the key lives In the client, or held by Claude through OAuth Your server's environment Your job's environment
Retry safety idempotency_key on every writing tool idempotencyKey option on emails.send Idempotency-Key header
What the model sees on refusal Tool result with code, fix, retryable Whatever your tool returns; the examples return code and fix Your code reads the JSON error
Setup time One config line One file One request

A trial-conversion agent usually starts life on the MCP route while someone in growth tunes the copy in Claude, then moves to the SDK route once it runs unattended.

Before any route: the key

Give the agent a key of its own, never the one your backend uses. On AgentiSend, a key created with sending_access can send and read the mail it sent, and nothing else: it cannot touch your domains, read received mail or mint more keys. Every key is created with a send budget, by default the plan's monthly inclusion. For this agent, set it near the expected volume, say 700 a month, with PATCH /limits/keys/{id} and a budget_per_period of 700, and add a rate_ceiling_per_minute.

We walked through minting and capping a key for a different job, a campaign alert, in three calls before an agent sends a campaign alert; the steps are the same here, so this guide starts with the key already in hand.

Route 1: MCP, for Claude, Cursor and Codex

In Claude's web or desktop app, open claude.ai/directory/agentisend and connect; Claude holds the connection, so there is no key to paste. In Claude Code:

claude mcp add --transport http agentisend https://api.agentisend.com/mcp \
  --header "Authorization: Bearer $AGENTISEND_AGENT_KEY"

In Codex, with the key read from your environment:

codex mcp add agentisend --url https://api.agentisend.com/mcp \
  --bearer-token-env-var AGENTISEND_API_KEY

Then a prompt like "Draft the day-7 summary for the Northwind trial, send it to delivered@simulator.agentisend.com first, then to the owner" exercises the whole path. The tools the model will use are whoami (account, scopes, remaining budget), preflight_email (every send check, nothing sent), send_email, and explain_email if a message seems not to arrive. Simulator addresses cost nothing and reach nobody.

The server lists 46 of its 92 tools by default; the model calls list_more_tools for the rest.

Route 2: an SDK tool, for the deployed agent

Once the agent runs on a schedule, wrap the send in a tool. This version is for the Vercel AI SDK; AgentiSend publishes equivalent tools for LangChain, Mastra, the Claude Agent SDK and the OpenAI Agents SDK.

import { tool, generateText, stepCountIs } from 'ai';
import { z } from 'zod';
import { AgentiSend, AgentiSendError } from 'agentisend';

const agentisend = new AgentiSend(); // AGENTISEND_API_KEY: the agent's own key

export const sendTrialSummary = tool({
  description:
    'Email a trial owner their day-7 summary. Returns the message id, or a refusal with ' +
    'a code and a fix. If the fix says a person decides, stop and report it.',
  inputSchema: z.object({
    to: z.string(),
    subject: z.string().min(1).max(200),
    text: z.string().min(1),
    trialId: z.string().regex(/^[a-z0-9-]{1,48}$/),
  }),
  execute: async ({ to, subject, text, trialId }) => {
    try {
      const { id } = await agentisend.emails.send(
        {
          from: 'Ada at Acme <ada@acme.com>',
          to,
          subject,
          text,
          tags: { flow: 'trial_day7', trial: trialId },
        },
        { idempotencyKey: `trial-day7/${trialId}/${to}` },
      );
      return { sent: true, id };
    } catch (err) {
      if (err instanceof AgentiSendError) return { sent: false, code: err.code, fix: err.fix };
      throw err;
    }
  },
});

await generateText({
  model, // any provider the AI SDK supports
  tools: { sendTrialSummary },
  stopWhen: stepCountIs(3),
  prompt: 'Write and send the day-7 summary for trial northwind-2291 to owner@northwind.example.',
});

Two choices in that file do most of the safety work:

The tags come back on every email.* webhook event, so flow: trial_day7 lets you report delivery and replies for this agent separately and join them to trial conversion in your analytics.

Route 3: REST, for a scheduled job

A nightly job that picks yesterday's day-7 trials can skip the framework and call the API directly:

curl -X POST https://api.agentisend.com/emails \
  -H "Authorization: Bearer $AGENTISEND_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: trial-day7/northwind-2291/owner@northwind.example" \
  -d '{
    "from": "Ada at Acme <ada@acme.com>",
    "to": "owner@northwind.example",
    "subject": "Your first week on Acme: 3 of 5 steps done",
    "text": "You connected two ad accounts and invited one teammate. Two steps left: ...",
    "tags": { "flow": "trial_day7", "trial": "northwind-2291" }
  }'

A success returns {"id": "…"}. A refusal returns an error object with code, message, fix, docs_url and retryable, and retry_after_seconds when waiting helps. Branch on code and retryable, never on the message text. For a batch night, POST /emails/batch takes up to 500 messages and accepts or refuses each one on its own.

What the agent cannot do, on any route

These are the same over MCP, the SDK and REST, which is the reason to route everything through one API:

The full tool list, scopes and refusal codes are at agentisend.com/docs/guides/mcp, and accounts open at agentisend.com.

Other providers for this job

Resend

Best for: teams already on Resend. It runs an official hosted MCP server at mcp.resend.com/mcp with OAuth, a local server from the resend-mcp package, and supports idempotency keys on sends for 24 hours.

Watch out for: a per-key send budget is not listed on its pricing page, so the agent's ceiling is the plan's.

AgentMail

Best for: agents that live in an inbox. Inboxes, threads and drafts are the product, its hosted MCP server lists 39 tools, and errors carry a fix.

Watch out for: limits are plan caps per day and per 5 minutes, not per key. Developer is $20 for 10,000 emails.

Amazon SES

Best for: teams that will build the agent's guardrails themselves to get $0.10 per 1,000.

Watch out for: new accounts start in a per-Region sandbox (200 messages per 24 hours to verified recipients) with an initial response to production access within 96 hours, and SendEmail documents no idempotency key.

MailerSend

Best for: agents that also need to send SMS; its hosted MCP server includes send_email, send_bulk_email and send_sms.

Watch out for: the MCP page does not say a send budget applies to the key the server uses.

Questions people ask

Which is better for an agent, MCP or an SDK? MCP when a person is working alongside the model in Claude, Cursor or Codex. An SDK tool when the agent runs unattended, because you control the tool description, the idempotency key and what the model sees on refusal.

How do I test an agent's emails without reaching customers? Send to delivered@simulator.agentisend.com, bounced@, complained@ or suppressed@ at the same domain. They cost nothing, reach nobody, and produce events marked "simulated": true.

Can the agent read replies from trial owners? Yes, once receiving is on for a verified domain. Reading received mail takes a full-access key with inbound:read; a sending_access key can still reply by id to a message the email.received webhook handed it.

What does 600 trial emails a month cost? On AgentiSend, nothing: the free plan includes 5,000 a month and 170 a day.

Sources

Documentation read 28 September to 10 November 2026: resend.com/docs (MCP server), resend.com/docs/dashboard/emails/idempotency-keys, docs.agentmail.to/integrations/mcp, docs.agentmail.to/errors, docs.aws.amazon.com/ses/latest/dg/request-production-access.html, docs.aws.amazon.com/ses/latest/APIReference-V2/API_SendEmail.html, developers.mailersend.com/mcp. Pricing pages read 9 November 2026: resend.com/pricing, agentmail.to/pricing, aws.amazon.com/ses/pricing.

send email from ai agent mcp vercel ai sdk rest api
Try Admaxxer Free