On this page
- What an MCP server is, and what makes one remote
- One Streamable HTTP endpoint, kept stateless
- MCP OAuth: Sign in with Mailr instead of API keys
- MCP tool annotations: say honestly what each tool does
- Prepare, then send: the pattern behind every send
- Reuse the API’s own code
- What we’d tell anyone building a remote MCP server
- Remote MCP server questions
What an MCP server is, and what makes one remote
The Model Context Protocol (MCP) is how an AI app talks to outside tools. The app (the host) runs a client for each server it connects to, and each server offers tools the model can call, with a name, a description and an input schema. A local server is a program the app starts on your machine and talks to over standard input and output. A remote server is a web service the app reaches over HTTP, so adding one is just pasting a URL, and the same server works in every app that supports MCP.
For a product like a direct mail API, remote was the only sensible choice: people already have a Mailr account, so the server should run where the account lives and sign them in to it, not ask them to install anything.
One Streamable HTTP endpoint, kept stateless
- One URL. Everything goes to
POST https://mailr.dev/mcpand comes back as JSON. No long-lived connection, no server-side session. - Stateless. Each request carries its own token and everything it needs, which suits a serverless host. Anything that must outlive a request, like a draft mailing, is stored in the database.
- Two protocol eras on one endpoint. Streamable HTTP replaced the older HTTP+SSE transport in the 2025-03-26 version of the spec, and the current version, 2026-07-28, dropped sessions and the
initializehandshake. We answer both the current version and the old handshake, so clients on either side of the change connect. - Origin checks. Browser requests are accepted only from Mailr’s own site and the AI apps’ sites; anything else gets a 403.
MCP OAuth: Sign in with Mailr instead of API keys
We didn’t want people pasting API keys into a chat. So the server is protected by OAuth, and every AI app finds its way to the sign-in from the server itself:
# 1. A call without a token gets a 401 that says where to sign in:
curl -i -X POST https://mailr.dev/mcp
# HTTP/2 401
# www-authenticate: Bearer resource_metadata="https://mailr.dev/.well-known/oauth-protected-resource/mcp", scope="mail"
# 2. That metadata names the authorization server:
curl https://mailr.dev/.well-known/oauth-protected-resource
# 3. And the authorization server lists its endpoints, PKCE method and registration options:
curl https://mailr.dev/.well-known/oauth-authorization-server- Discovery. A request without a token gets a 401 whose header points to the protected-resource metadata (RFC 9728), which names the authorization server and its own metadata (RFC 8414).
- Registration. The app identifies itself with a Client ID Metadata Document, an https URL describing it, or registers on the fly with Dynamic Client Registration (RFC 7591). The 2026-07-28 spec prefers metadata documents and marks Dynamic Client Registration deprecated, but Cursor, for one, still documents only registration, so we keep both.
- The sign-in. Authorization code with PKCE, S256 only. The person picks which Mailr account the app may use and allows it.
- Tokens bound to this server. The resource is bound into the grant (RFC 8707) and checked on every use. Access tokens last an hour; refresh tokens last 90 days and change on every use, and an old one used again ends the grant.
- Revocable. Each connection shows in the dashboard under Developers › Connected apps, where it can be cut off or kept to test mail. Secrets are stored only as hashes.
MCP tool annotations: say honestly what each tool does
Each tool carries hints about its behavior, and AI apps use them to decide what to ask before. ChatGPT treats any tool not marked read-only as a write action that needs confirmation; Codex’s writes mode prompts for the same set; Claude lets people allow tools one by one. So the hints matter:
// A tool that only reads: clients can run it without asking.
{ "name": "prepare_mail",
"annotations": { "readOnlyHint": true, "destructiveHint": false, "idempotentHint": true, "openWorldHint": false } }
// A tool that acts in the world and can spend money: clients should ask first.
{ "name": "send_prepared",
"annotations": { "readOnlyHint": false, "destructiveHint": true, "idempotentHint": true, "openWorldHint": true } }Of Mailr’s 13 tools, the ones that read or prepare are marked read-only. send_prepared is marked destructive and idempotent, and verify_addresses is marked as acting too, because a live address check costs money. Left out, the spec’s defaults assume the worst: not read-only, destructive, not idempotent. And the spec tells clients to treat annotations from untrusted servers as untrusted, so they’re hints for the app’s prompts, not guarantees; the server still enforces every rule itself.
Prepare, then send: the pattern behind every send
drf_8f2c91$106.80proof linkPerson approves $106.80send_prepared, once- Prepare tools only read.
prepare_mail,prepare_printandprepare_live_from_testcheck the request, price it on the account’s plan and save it as a draft for 24 hours, returning its id, the total and a proof link. Nothing is created or charged. - One send tool.
send_preparedsends a draft exactly as prepared. The draft id is its idempotency key, so a model that retries can’t mail twice. - The exact total. A live draft also needs
confirm_totalequal to the draft’s total, so the person’s OK is on a specific dollar amount, not on “go ahead”. - Test first. Test mode is the default, free and never printed, so the first run of anything costs nothing.
- A person in the loop. The spec says there should always be a human who can deny a tool call. The exact total is how we make that approval mean something.
Reuse the API’s own code
Every tool calls the same functions as Mailr’s REST API: validation, prices, balances, idempotency and the rules about mail waiting on payment. There’s no second implementation to drift, and a fix to the API is a fix to the MCP server. If you’re putting an MCP server in front of an existing API, that’s the one choice we’d insist on.
What we’d tell anyone building a remote MCP server
- Use OAuth for anything personal. API keys in a chat window get pasted into the wrong places.
- Split reading from acting. Give the model tools that check and price freely, and one narrow tool that acts.
- Make the person approve a number. For anything that spends money, have the send tool repeat back the exact amount.
- Write descriptions for the model. Say what each tool costs, what it can’t do, and what to call next.
- Test in every client. Claude, ChatGPT and the coding agents each read the spec a little differently; see Claude connectors, ChatGPT MCP, Claude Code MCP, Codex MCP, Cursor MCP, VS Code MCP and Gemini MCP.
Remote MCP server questions
What is a remote MCP server?
An MCP server that runs on the internet and is reached by URL over HTTP, instead of a program started on your own computer. ChatGPT, Claude and coding agents connect to it the same way, so users add it without installing anything.
Does a remote MCP server need OAuth?
If its tools read or change a person's own data, yes in practice: it's how the AI app gets access for one person without anyone pasting an API key, and Claude's directory asks for OAuth on tools that act on a user's account.
Can a remote MCP server be stateless?
Ours is. Every request carries its token and everything it needs, which suits a serverless host. Drafts live in the database, not in a session.
How do AI apps know which tools are safe to run?
From the tool annotations, such as readOnlyHint and destructiveHint. ChatGPT, Claude and Codex use them to decide what to ask before, so mark them honestly.
Can I try Mailr's MCP server?
Yes. Add https://mailr.dev/mcp in your AI app, sign in with a Mailr account, and send test mail: it's free and never prints.