OpenAI Agents SDK + Physical Mail
Connect Mailsnail to the OpenAI Agents SDK as a stdio MCP server. Code snippet, gotchas, and a practical autonomous-mail example.
· Updated
Two ways in
If you want mail from ChatGPT itself, you don't need the SDK: add https://api.mailsnail.dev/mcp as a connector and sign in. See Send a letter from ChatGPT.
For a headless agent built on the Agents SDK, there's no person around to click a sign-in page, so run the open-source server yourself against your own Click2Mail or Lob account. Your provider bills you directly.
Wire-up (self-hosted)
from agents import Agent, MCPServerStdio
mail = MCPServerStdio(
name="mailsnail",
params={
"command": "npx",
"args": ["-y", "mailsnail"],
"env": {
"MAIL_PROVIDER": "click2mail",
"CLICK2MAIL_USERNAME": "your-username",
"CLICK2MAIL_PASSWORD": "your-password",
},
},
)
agent = Agent(
name="Mailer",
instructions="You can send physical mail via the Mailsnail MCP server.",
mcp_servers=[mail],
)
That's it — the agent now has the mail tools available alongside whatever else it can do.
A practical example
A classic loop: a CRM webhook fires when a deal closes, the agent drafts a personalized thank-you letter to the buyer, and send_letter puts it in the mail. The whole sequence is one tool-using turn for the agent.
response = await agent.run(
"A new deal closed: contact_id=c_42. Mail them a thank-you note."
)
The agent fetches the contact, drafts a letter, and calls send_letter. You get back an id it can poll later via get_letter.
Gotchas
- The server runs over stdio via
npx, so Node.js 18+ must be installed wherever your agent process runs. - By default the server is in dry-run mode and won't actually mail anything — set
MAIL_MCP_ALLOW_LIVE=1(and a spend cap) when you're ready to print. - The agent SDK's tool-use loop occasionally retries. Make sure your prompts make it obvious that one piece per request is the intended behavior.
Wire Mailsnail into your agent
Add one URL and sign in. Nothing to install and no API key. In Claude Code:
claude mcp add -t http mailsnail https://api.mailsnail.dev/mcpThen 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:
{
"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
Send Physical Mail from Claude Code
Wire Mailsnail into Claude Code with one command and your agent can drop letters in the mail. End-to-end setup, tool reference, and a worked example.
MCP Server for Direct Mail
Mailsnail is the Model Context Protocol server that lets any MCP agent send physical letters and certified mail. Connection details, tool list, and pricing.
Send Letters from Cursor
Cursor's MCP support means your IDE-resident agent can take real-world actions. Here's how to wire Mailsnail in so Cursor can put a letter in the mail.