Send USPS Mail from the Claude API or Claude Agent SDK

Give an agent built on the Claude API or the Claude Agent SDK an MCP server that mails USPS letters and Certified Mail: one URL and an API key. With code.

agents-sdkmcpapi

An agent built on the Claude API or the Claude Agent SDK can mail a real USPS letter, Certified Mail included, with no code written around our API. Both take a remote MCP server as a URL with a token, and Mailsnail has an address made for that. It takes an API key, asks for no browser sign-in, and pays for each letter from a balance a person funds by card.

1. Get a key

curl -X POST "https://api.mailsnail.dev/v1/accounts?ref=claude-api-physical-mail"
export MAILSNAIL_KEY="msk_live_..."

One call, with no sign-up form. The key is shown once, so keep it with your agent's other secrets.

2. Give the agent the server

The address is https://api.mailsnail.dev/key/mcp. There are two ways to attach it, and they differ in who makes the calls.

Claude API: Anthropic's servers connect

The MCP connector of the Messages API calls the server while the request runs, so your code holds no MCP client. The connector is a beta, named in the request, and the key goes in authorization_token.

import os
import anthropic

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    betas=["mcp-client-2025-11-20"],
    mcp_servers=[
        {
            "type": "url",
            "url": "https://api.mailsnail.dev/key/mcp",
            "name": "mailsnail",
            "authorization_token": os.environ["MAILSNAIL_KEY"],
        }
    ],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "mailsnail"}],
    messages=[{"role": "user", "content": "Make a proof of this letter to Jane Doe, 1 Main St, Brooklyn NY 11201: ..."}],
)

The calls and their results come back in the response as mcp_tool_use and mcp_tool_result blocks.

Claude Agent SDK: your own process connects

import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const message of query({
  prompt: "Make a proof of this letter to Jane Doe, 1 Main St, Brooklyn NY 11201: ...",
  options: {
    mcpServers: {
      mailsnail: {
        type: "http",
        url: "https://api.mailsnail.dev/key/mcp",
        headers: { Authorization: "Bearer " + process.env.MAILSNAIL_KEY },
      },
    },
    allowedTools: ["mcp__mailsnail__*"],
  },
})) {
  if (message.type === "result" && message.subtype === "success") console.log(message.result);
}

The tools are named mcp__mailsnail__ and the tool name, as in mcp__mailsnail__preview_letter. In Python the same settings go in ClaudeAgentOptions, as mcp_servers and allowed_tools.

Either way the agent gets eight tools:

  • verify_address checks a US address with USPS. Free.
  • preview_letter returns the proof PDF, the exact price and a draft_id, from typed text or the address of your own PDF. Free, and nothing is mailed.
  • send_letter mails that proof and takes its price from the balance.
  • get_letter gives the letter's status and, for Certified Mail, its USPS tracking.
  • cancel_letter cancels before printing starts and returns the price to the balance.
  • get_balance says what is left to spend.
  • add_payment_method returns the link to the Stripe page where a person adds funds.
  • turn_off_auto_reload stops automatic top-ups, if you turned them on.

3. Decide who approves a letter

A letter cannot be called back once printing starts, usually about a day after it is sent. So settle this before the agent runs.

  • Nobody is at the keyboard. Let every tool run. The balance is the most the agent can spend, and nothing adds to it unless you asked for auto-reload.
  • A person is there. Let the free steps run, and hold send_letter until they have read the proof.

With the connector, make the first request with send_letter switched off in the toolset, so that it can only check the address and make the proof:

tools=[
    {
        "type": "mcp_toolset",
        "mcp_server_name": "mailsnail",
        "configs": {"send_letter": {"enabled": False}},
    }
]

Show the person the proof and the price. When they say yes, a second request with the toolset as in step 2 mails it: give the model the draft_id the proof came with.

With the Agent SDK, name only the free tools in allowedTools. Its documentation says a tool without that permission is seen and cannot be called.

allowedTools: [
  "mcp__mailsnail__verify_address",
  "mcp__mailsnail__preview_letter",
  "mcp__mailsnail__get_balance",
  "mcp__mailsnail__get_letter",
],

Certified Mail and a return receipt

preview_letter takes extra_service. Leave it out for a First-Class letter, or set one of three values:

What you get, and the value that asks for it From the balance
A First-Class letterleave extra_service out $1.21
USPS tracking and proof of mailingcertified $8.61
The same, and the recipient's signature as a PDFcertified_return_receipt_electronic $11.64
The same, and the signed green card (PS Form 3811) mailed back to your return addresscertified_return_receipt $14.27

Prices are for one page, black and white, to a US address. They are what each piece costs us, with no markup and no monthly fee, and the proof shows the exact price of your letter before anything is spent. Full pricing.

How the balance works

A person adds funds once by card, $10 to $500 at a time, on a Stripe page: add_payment_method returns the link. From then on send_letter takes each letter's price from the balance and mails it, with no page to open.

When the balance does not cover a letter, send_letter mails nothing and charges nothing. Its answer carries pay_url, a page where a person pays for that one letter by card, and setup_url, the page that adds funds. The proof stays good for seven days, and the same call mails it after either payment.

What we ran, and what we did not

Both forms are Anthropic's documented ones, for the MCP connector and for MCP in the Agent SDK, read on November 25, 2026.

That day we ran the Agent SDK (version 0.3.332) against this server's code with the options above. Its first message named the server connected and listed the eight tools, with a key and without one. It called none, because that takes a model and we used none. Claude Code 2.1.332 connected the same way, by the command on the developer page.

The connector form was not run by us with a live key. We did run five other client libraries against this server's code that day, the OpenAI Agents SDK's and the AI SDK's among them: with a key each listed the eight tools and called them, and without a key each still listed them and a call answered with how to make one.

From Claude itself

Mail from the Claude app or Claude Code needs no API. The setup page has the steps for each, and Send physical mail from Claude Code walks through one letter.

Related

Give your agent Mailsnail

From your own code, or an agent with nobody at the keyboard: one call returns an API key, with no sign-up.

bash
curl -X POST "https://api.mailsnail.dev/v1/accounts?ref=claude-api-physical-mail"

Checking an address and making a proof are free. A person adds funds once by card, and each letter then takes its price from that balance: from $1.21. The five calls →

From an app that speaks MCP: add one URL and sign in. Nothing to install and no key to handle. In Claude Code:

Claude Code
claude mcp add -t http mailsnail https://api.mailsnail.dev/mcp

Then run /mcp and choose Authenticate. In Claude Desktop or ChatGPT, add https://api.mailsnail.dev/mcp as a custom connector. Cursor and other JSON-config clients take:

mcp.json
{
  "mcpServers": {
    "mailsnail": {
      "url": "https://api.mailsnail.dev/mcp"
    }
  }
}

A one-page letter is from $1.21, and preview_letter shows the proof and exact price before anything is charged. Setup for every app →

See also