Email for a CrewAI agent
Give the agent its own inbox in one call, then add Mailgi's MCP server to its mcps list. No wrapper code: three tools, one config object.
To give a CrewAI agent email, register an address with one POST to Mailgi, then pass MCPServerHTTP(url="https://api.mailgi.xyz/mcp") with the key as a Bearer header in the agent's mcps list. Filter it to mail_send, mail_list and mail_get, and the agent can receive verification codes, answer mail and write to people from its own address, with no OAuth and no shared human inbox.
Give the agent an address
One call, no signup form. Do this once per agent and keep the key in your secrets store.
Register
The response carries the address and an API key that is shown exactly once.
An MCP client can also do this itself: register_agent is one of the tools that work with no key. The key still has to reach your config once, so for a server-side agent the one-off call below is simpler.
# Once, outside the agent: give it an address and keep the key
curl -s -X POST https://api.mailgi.xyz/v1/agents/register \
-H "Content-Type: application/json" -d '{"label":"my-agent"}'
# => {"emailAddress":"buzzing-falcon@mailgi.xyz","apiKey":"amb_..."}
export MAILGI_API_KEY=amb_... # shown once: store it
Connect it natively
CrewAI speaks MCP itself since 1.0, so the hosted server plugs straight into the agent. Nothing to host, no tool functions to write.
The agent
MCPServerHTTP uses Streamable HTTP, which is what Mailgi serves. The key goes in as an ordinary header.
The server exposes 67 tools: domains, keys, webhooks, billing. The filter keeps the model to the three it needs; add mail_move or mail_delete if it should file or clean up.
CrewAI prefixes each tool with the server's host, so the model sees api_mailgi_xyz_mcp_mail_send. The filter takes the plain names.
The connection, filter and tool calls were run against the live API with CrewAI 1.15. The agent uses whichever LLM your CrewAI is configured for.
# pip install crewai
import os
from crewai import Agent, Crew, Task
from crewai.mcp import MCPServerHTTP
from crewai.mcp.filters import create_static_tool_filter
mailgi = MCPServerHTTP(
url="https://api.mailgi.xyz/mcp",
headers={"Authorization": f"Bearer {os.environ['MAILGI_API_KEY']}"},
tool_filter=create_static_tool_filter(
allowed_tool_names=["mail_send", "mail_list", "mail_get"]),
)
agent = Agent(
role="Mail agent",
goal="Read and answer email sent to your own address",
backstory="You have your own email address. Never invent a message id.",
mcps=[mailgi],
)
task = Task(
description="Check the inbox and summarise anything new.",
expected_output="A short summary of new mail.",
agent=agent,
)
print(Crew(agents=[agent], tasks=[task]).kickoff())
What the tools can't do yet
Better to know before the model tries.
No search, no threads
There is no search parameter; mail_list pages newest first and the model matches messages itself. Replies are new messages with “Re:” in the subject.
No attachments
Send links instead. Incoming attachments are not exposed.
Mail to strangers is metered
Sending to other @mailgi.xyz agents is free; to outside addresses it costs $0.0005 per recipient plus $0.02 the first time you write to a new address. With no balance, a send comes back as a tool result starting “HTTP 402” with the top-up link, not as an exception, so the agent can pass the link on.
Questions, answered
01How do I give a CrewAI agent an email address?
Register one with a single POST to https://api.mailgi.xyz/v1/agents/register, then add MCPServerHTTP(url="https://api.mailgi.xyz/mcp", headers={"Authorization": "Bearer <key>"}) to the agent's mcps list. No OAuth or human signup is needed.
02Do I need crewai-tools or MCPServerAdapter?
No. Since CrewAI 1.0 an Agent takes MCP servers directly in mcps. MCPServerAdapter from crewai-tools still works if you are on an older setup.
03Can a CrewAI agent receive verification codes?
Yes. Once it has its own address it can use mail_list and mail_get to find the code. Poll every few seconds after triggering the signup; most codes arrive within seconds.
04What does it cost?
Registering and receiving are free, and so is mail between Mailgi agents. Mail to outside addresses costs $0.0005 per recipient plus $0.02 the first time an agent writes to a new address, from a prepaid balance.
One POST to start.
No signup form, no OAuth, no card to start. Receiving is free.
Open the dashboard →