Guides

An email API for AI agents: MCP tools and scoped keys

What an agent needs from an email API: every method as a tool, a key that limits it, a way to check a call before it runs, and a log of what it did.

4 min read

In short

  • OpenSend has an MCP server built in, at /v1/mcp. Each method of the API is one tool.
  • The key is the credential and the limit: an agent is offered the tools its key may use, and no others.
  • A call can be sent as a check first. The key and the input are tested, and nothing runs.
  • Every tool call is in the logs, with the name of the tool and its error.
  • The assistant in the console uses the same tools, and a change waits for you to confirm it.

Why an agent needs more than a REST API

More and more email is set up by an agent on behalf of a person: add the domain, write the template, send the test, read why it bounced. An agent can call a REST API, and it will guess at it the way a person would without the docs.

What it needs is what the Model Context Protocol gives it: a list of the tools it may use, the input each one takes, and whether a tool only reads or changes something. And you need three things from the API in return: a limit on what the agent may do, a way to try before it acts, and a record afterwards.

Connecting a client

The MCP server is part of the API, at /v1/mcp. It speaks MCP over HTTP and takes the key in the Authorization header, like every other request. There is no OAuth step. Most clients need the address and that header, and nothing else:

JSON
{  "mcpServers": {    "opensend": {      "type": "http",      "url": "https://api.opensend.sh/v1/mcp",      "headers": {        "Authorization": "Bearer os_..."      }    }  }}

The agents page has the exact entry for each client, from Claude Code and Cursor to the ones that run in their own cloud.

One tool for each method

A tool is named after its method: emails.send is emails_send, and apiKeys.create is api_keys_create. Its input is the input of the method. Nobody wrote the tools by hand, so they cannot fall behind the API: a method is declared once, and that one declaration is its REST endpoint, its SDK method and its tool.

  • Each tool says whether it only reads, whether it destroys something and whether it reaches outside the workspace, as sending does.
  • The answer holds the result as data and as text, for clients that read only text.
  • A refused call says why, with the code the REST API answers with, so a program can branch on it.

The key decides

An agent asks for its tools and gets the ones its key may use. A call the key may not make is refused.

  • A sending key sees only the few tools a sender needs.
  • One domain. A sending key can be held to a single domain.
  • Revoking. Remove the key and the agent is cut off.

Give an agent a key of its own, never yours. Then its work is easy to find in the logs and easy to stop.

Check a call before it runs

An agent that is not sure can send the same call as a check. The server tests that the key may use the tool and that the input is valid, runs nothing, and answers. An input that would be refused comes back as the same error a real call gives.

This is an addition of OpenSend and not a part of MCP. The server names it when a client connects, so a client can look before it relies on it. The MCP page of the docs shows both calls.

See what the agent did

Every request a key makes is listed in the logs, and a tool call shows the name of the tool and, when it failed, the reason. Filter the list by the key you gave the agent and you have its whole history.

The assistant plays by the same rules

The console has an agent of its own, and it is a client of the same server with the same tools. It differs in one way: it runs as you, so it waits for you.

  • A tool that only reads runs straight away.
  • A change is checked and comes back as one card. Nothing has happened yet, and confirming runs the change with no model involved.
  • A token, a secret, a hash or a password in an answer is hidden before the model reads it.
  • It is told that what a tool returns is data. Received mail and contact names are written by strangers.

How the assistant works has a page of its own.

What an agent cannot do

Closing a workspace is not a tool, so a mistake of a model cannot wipe one. It answers only to the signed-in owner, who types the name of the workspace.

The server speaks the protocol versions 2025-06-18, 2025-03-26, 2024-11-05. It has tools only: no resources and no prompts. It works the same when you host OpenSend yourself, because it is part of the API.

Sources

  1. Model Context Protocol, Model Context Protocol

More from the blog

Send your first email in a few minutes.

Create a key and send, or clone the repository and run it yourself.