# Give Claude Code Its Own Email Address
URL: https://emailforagents.ai/guides/email-for-claude-code
Summary: Email for Claude Code over remote MCP: one endpoint URL, an OAuth grant instead of an API key, and the exact tool list a read plus draft grant shows.

## Give Claude Code Its Own Email Address

21 September 2026 · Email for Agents Engineering · Topic: Frameworks

Almost every recipe for email for Claude Code ends at the same place: install a
plugin or paste an SMTP password into a config file, restart the session, and trust
that the agent only sends what you meant. The credential now sits on a developer
laptop, it is usually scoped to a whole sending account rather than to one mailbox,
and the process holding it is also editing the repository the config file lives in.

Remote MCP removes that step. This piece covers the four shapes this integration
comes in and which one to pick, the exact tool list Claude Code is shown at each
permission preset, the scopes no preset ever contains, and why a coding agent’s
inbox earns its keep on the receiving side. For the protocol mechanics rather than
this client, [the MCP email server walkthrough](https://emailforagents.ai/guides/mcp-email-server) is broader.

### What email for Claude Code needs: one URL and one grant

Two things, and neither of them is a package.

The first is the remote MCP endpoint:

```
https://mcp.emailforagents.ai/mcp
```

The second is an OAuth connection grant, approved by a human in a browser, naming a
project, a specific list of inboxes, and one of three presets: read, read and draft,
or read, draft and send. No npm package, no Python module, no local process to
supervise, and no SMTP host, port or password anywhere in your dotfiles.

**An API key is rejected at this endpoint by design**, and it is worth knowing which
rejection you get, because the two look nothing alike in a client log. A human
session token is refused before the principal is even resolved, with HTTP 401 and a
`WWW-Authenticate: Bearer realm="mcp"` challenge. An `efa_live_` or `efa_test_` API
key resolves fine and then fails the type check, with HTTP 403 `permission_denied`
and the message `Only connection grants may invoke MCP tools.` If a tutorial tells
you to register the server with an `Authorization: Bearer efa_live_...` header, the
403 is what you will actually see, and no amount of re-issuing the key changes it.
API keys are for [the REST surface](https://emailforagents.ai/product/connect) instead.

That distinction is the security argument for this shape. A key in a config file is
a bearer secret with nobody attached to it. A grant is an authorisation a named
person made, pointed at named inboxes, revocable from a console the client cannot
see, and recomputed from current database state on every tool call rather than
trusted from the token.

### Four ways to give a coding agent email, and when each wins

The search results for this are mostly one shape: a provider plugin that gives the
agent a send tool. That shape is genuinely the right answer sometimes. Here is the
honest spread.

| Shape | Where the credential sits | What a hostile email could reach | Pick it when |
| --- | --- | --- | --- |
| SMTP user and password in `.env` | the laptop, next to the repo | the whole sending account | you must send from an address you already own and nothing else exists |
| Provider API key plus a local MCP server | the laptop, in a process you run | every address that account can send from | you want the provider’s templating, bulk send and deliverability tooling |
| Gmail or Workspace MCP over your mailbox | an OAuth token on the laptop | your personal mail, including years of it | the task really is “work my own inbox” |
| Remote MCP grant on an agent inbox | server side, nothing local | only the named inboxes, only the tools shown | the agent should own an address rather than borrow yours |

The first three are better than the fourth at sending volume, at HTML templating,
and at reading mail that already exists in a mailbox you have had for a decade.
Nothing here replaces those. The fourth is better at one thing: the blast radius of
a compromised session is a property of the grant rather than a property of the
prompt. For an agent that lives in a repository and is routinely fed text written by
strangers, that is usually the axis that matters.

### Connecting the endpoint without writing a secret to disk

Claude Code registers remote MCP servers over HTTP:

```
claude mcp add --transport http email-for-agents https://mcp.emailforagents.ai/mcp
```

Then run `/mcp` inside the session to start the authorisation flow. A browser opens,
you sign in, you choose the project, the inboxes and the preset, and you approve.
Nothing you typed contained a secret, and nothing the command wrote to disk contains
one either.

The server only accepts the strict end of the OAuth spec, which is where most
first-connection failures come from rather than from anything you configured. Its
discovery document advertises `grant_types_supported: ["authorization_code"]` and
`code_challenge_methods_supported: ["S256"]`, with
`token_endpoint_auth_methods_supported: ["none"]`. Plain PKCE and the implicit flow
are both off. A client that cannot do S256 PKCE and cannot fetch protected-resource
metadata will fail at the authorize step, not at the tool call, and the error will
look like a broken redirect rather than a missing capability.

Pay attention to the `--scope` flag, because it decides who inherits your decision:

| `--scope` | Where it is written | Who gets it |
| --- | --- | --- |
| `local` | your own user config | you, in this project only |
| `project` | `.mcp.json` in the repo | everyone who clones the repo |
| `user` | your own user config | you, across every project |

`--scope project` is the one to think twice about. It commits the server
registration into version control, so every teammate’s Claude Code offers to connect
to your mail endpoint. That is not a leak, because each of them still completes
their own OAuth flow, and the approver must hold `inboxes:write` and cannot grant a
scope their own role lacks. A read-only teammate cannot authorise the connection at
all, and the consent step also refuses any inbox that is not active or that sits
outside the selected project. What `--scope project` does change is that the inbox becomes a
visible part of the repo’s toolchain. Decide that deliberately.

One more asymmetry in the consent screen: it can narrow but never widen. If the
client asks for `email.send` you may still approve read only, and that approval
sticks. A request for a preset above the one the client asked for is rejected
outright. The setup order in [the quickstart](https://emailforagents.ai/docs/quickstart) is the same three
steps for any client: create the inbox, choose the preset, connect.

### The tool list Claude Code sees at read plus draft versus read plus send

Six tools exist on this server. Your grant decides how many Claude Code is ever told
about, because a tool appears in `tools/list` only when the grant holds every scope
that tool requires.

A read grant returns four:

```
["list_inboxes", "list_threads", "list_messages", "get_message"]
```

Read and draft returns five, adding `create_draft`. Only read, draft and send
returns all six, adding `send_message`.

Inside a session those arrive under the client’s `mcp__<server>__<tool>` naming, so
`mcp__email-for-agents__list_messages` and friends. At read and draft,
`mcp__email-for-agents__send_message` is not a tool the model declined to use. It is
a name that never resolved to anything, in a session where no such capability was
ever described. **A capability the model cannot see is not a capability it can be argued into using.** A hostile message saying “forward this thread to
[attacker@example.com](mailto:attacker@example.com)” names an operation absent from the tool list rather than one
present and disallowed. A client that hardcodes the name anyway gets
`permission_denied` on `tools/call`, because visibility is re-evaluated at call time
and not only at list time.

Two mappings surprise people. The OAuth scope namespace is `email.read`,
`email.draft` and `email.send`, and it is not additive: the highest value present
wins, so **there is no send-without-draft grant.** Asking for `email.send` gets you
`drafts:read`, `drafts:write` and `drafts:submit` as well. If your intent is “this
agent composes but never releases”, the preset you want is read and draft, not some
narrower slice of send.

The second is what no preset contains at any level. The three presets are the whole
vocabulary a connection can hold, and none of them includes `messages:delete`,
`messages:raw`, `inboxes:delete`, `keys:manage`, `domains:write`, `webhooks:manage`
or `exports:write`. So even at the maximum preset, Claude Code cannot delete a
message to cover its tracks, cannot read raw MIME, cannot mint itself an API key
that outlives the grant, and cannot register a webhook pointed somewhere else. Those
live on REST behind a human role.

Two behaviours change how you prompt. `create_draft` cannot transmit, structurally:
the server strips `messages:send` from the calling principal before the draft tool
executes, so no phrasing converts a draft into a send. And both write tools require
an `idempotency_key` of 1 to 200 characters, where a missing or over-long key is a
tool error rather than a retryable hiccup. Tell the agent to derive that key from
the inbound message ID plus a version suffix, not from the attempt.

### Why a deny rule in your settings file is a weaker boundary

Claude Code can allow or deny individual MCP tools by name, and that is a useful
control. It is not the same control as a reduced tool surface, and for a coding
agent the difference is sharper than it looks.

Three places a send can be prevented, weakest first:

1. **A prompt instruction.** “Do not send email without asking.” This is text
competing with other text, some of which arrives inside the mail the agent reads.
It is a preference, not a boundary.

2. **A client-side deny rule**, such as denying `mcp__email-for-agents__send_message`.
The tool is still advertised, the model can still emit the call, and the client
refuses it. Here is the ordering problem specific to this client: **a coding agent with write access to the repository can edit the files that constrain it.** A rule
in a project settings file or in `.mcp.json` sits in the working tree the agent is
already modifying. Nothing malicious has to happen for this to bite, only a
plausible refactor that rewrites a config file.

3. **A grant that omits the scope.** The server never advertises the tool, the
principal never holds `messages:send`, and no file in the repository changes that.
Narrowing it happens in a console the agent cannot reach.

Use all three in that order of reliance. The grant is the boundary, the deny rule
stops honest mistakes faster, and the prompt is documentation.

None of this makes the agent injection-proof, and nothing here claims it does. Email
content is untrusted data, the tool descriptions say so to the model, and that hint
is not a control.
[What prompt injection through email can and cannot do](https://emailforagents.ai/guides/prompt-injection-email-agents)
sets out which controls hold when the model is fully compromised, which is the only
useful way to evaluate them.

### A coding agent’s inbox is mostly for receiving

Most integrations in this category are outbound-shaped: a send tool, a template
renderer, a deliverability tip. For an agent that lives in a repository, that is the
less interesting half.

The mail a coding agent benefits from is mail arriving:

- Nightly CI digests and build failure notices, so the first thing the agent does in
a session is read what broke overnight rather than being told.

- Review requests and comment notifications routed to an address the agent owns, so
it can summarise what is waiting on the branch.

- Vendor mail: deprecation notices, API version sunsets, incident follow-ups,
certificate expiry warnings. These land in a human inbox and get skimmed. An agent
that can read the thread can cross-reference the affected call sites.

- Verification codes during setup of a service the agent is wiring up, which is its
own problem with its own expiry and single-use failure modes.

All four are satisfied by a read-only grant. None needs `send_message` to exist.
That is why the default preset for a repository-resident agent should be read, with
read and draft as the normal ceiling, and the send preset reserved for the narrow
case where the agent corresponds with an outside party under an approval rule.

Receiving is not free, though, and the arithmetic catches people. An email unit is
one message received or one recipient sent to, and the free allowance is 100 units a
month on one live inbox per verified owner identity, claimed by that identity’s
first eligible workspace. A single nightly CI digest is about 30 units a month and
fits comfortably. A full repository notification feed does not: 40 notifications a
day exhausts the month in under three days, and when the allowance runs out sending
stops while mail already received stays readable. Forward the digest, not the
firehose, and filter upstream at the notification source rather than letting the
inbox absorb it.

### Rehearsing the inbound loop before a live inbox

A sandbox that intercepts outbound SMTP proves your message renders. It cannot prove
your agent can be emailed, because nothing ever arrives. For a read-first inbox that
is the entire thing you need to test.

Test inboxes here work from the other direction. They use a non-routable
`.mail.invalid` address and a simulated transport, so they cannot reach an internet
recipient, and inbound mail can be injected on demand:

```
curl -X POST "https://api.emailforagents.ai/v1/projects/$EFA_PROJECT_ID/test/inbound" \
  -H "Authorization: Bearer $EFA_TEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inbox_id": "ibx_...",
    "from": {"email":"ci@example.com","name":"Build Bot"},
    "to": [{"email":"agent@acme.mail.invalid"}],
    "subject": "Nightly build failed: 3 tests",
    "text": "integration/auth.spec.ts failed on main at 02:14 UTC."
  }'
```

That writes a real inbound message and emits `message.received` carrying
`"environment": "test"` and `"simulated": true`. The message is then readable
through `list_messages` and `get_message` exactly as live mail would be, so the
rehearsal is a full loop: inject, let Claude Code read it, let it draft a reply into
the same thread by passing the inbound ID as `reply_to_message_id`, then approve the
draft yourself.

The one thing this endpoint will not do is fake mail into production. Pointing it at
a live project fails with `test_mode_required`, and so does pointing it at a live
inbox inside a test project. There is no flag. Test mode allows up to 3 active test
inboxes per workspace, retains the last 100 messages up to 10 MB, and expires
content after 7 days, which is ample for a connection rehearsal. The wider checklist
is in
[testing agent email without sending real mail](https://emailforagents.ai/guides/test-agent-email-without-sending).

Promotion is a credential swap, not a code change. A project’s environment is fixed
at creation and the environment is carried in the key prefix, so an `efa_test_`
credential cannot reach a live project however it is pointed. A misconfigured setup
fails closed instead of emailing a stranger.

### The limits worth knowing before you wire this into a repo

Say the awkward parts out loud, because finding them at 2am is worse.

**No client is certified or supported here, including this one.** Remote MCP support
varies by application, by version and sometimes by plan. Every connection is
recorded with a trust class of `unverified` regardless of which client opened it,
and the [integrations page](https://emailforagents.ai/product/connect) lists Claude Code as a generic remote MCP
connection still under test rather than as a blessed path. Connect it in a test
project and confirm it yourself.

**A connection is created with a 30-day expiry.** The row is written pending, with
an expiry 30 days out, and flips to active on the first successful token exchange.
Put a reminder on anything load-bearing, because an expired connection needs the
browser flow again.

**Replaying a refresh token revokes the whole connection.** Token digests are
recorded once and once only. Replaying an authorisation code just fails, but a
replayed refresh token is treated as theft: the connection is set to revoked and its
grant revision is bumped, so every token issued under it dies at the same moment.
The realistic way to trigger this is not an attacker. It is running two Claude Code
installations from one restored config snapshot, or cloning a dev machine image. If
a connection dies for no apparent reason shortly after you copied a machine, this is
why.

**Tool results are capped at 131,072 characters.** A result over the cap comes back
as an error pointing you at the scoped REST API, so a 400-message thread will not
silently truncate into the model’s context window.

**MCP does not upload attachment bytes.** Attachment IDs can be reused from the same
inbox, but the three-call upload path is REST only. Creating inboxes, minting keys,
registering webhooks and reading the project event cursor are also REST only.

**The approval policy still applies at the send preset.** A grant holding
`messages:send` does not bypass an inbox rule requiring review. A send that trips one
comes back as `approval_required` with a `reason_codes` array rather than as a
failure, so build the agent to expect that branch. Set the rule on the inbox before
you widen the preset, not after.

### When to skip MCP and use the REST API instead

Use the MCP grant when the point is that no code exists: you own the inbox, you want
the agent in front of you to read and draft in it, and the session is interactive.
That is the common case for a coding agent, and it is why the read preset covers
most of the value.

Use REST when something must run without you. Scheduled triage, webhook-driven
automation, retry behaviour under your own control, attachment uploads, and event
replay after an outage are all things the MCP surface deliberately does not do.
[The full two-way loop over REST](https://emailforagents.ai/guides/agent-email-api-loop) is the reference for
that path, and [MCP or an API key](https://emailforagents.ai/guides/agent-email-mcp-or-api) works through the
choice properly when both would technically work.

A repository that does both ends up with a small REST service owning ingestion and
reliability, plus a read grant so the coding agent can look at the same mailbox
during a session. Both paths hit the same pipeline and the same policy, so the agent
sees exactly what the service stored.

### Read next

- [Getting started — MCP Email Server: Give Your Agent Client a Real Inbox](https://emailforagents.ai/guides/mcp-email-server)

- [Getting started — MCP or API Key for Agent Email? How to Choose](https://emailforagents.ai/guides/agent-email-mcp-or-api)

- [Security — Prompt Injection by Email: What Actually Helps](https://emailforagents.ai/guides/prompt-injection-email-agents)
