Source: https://cli.nylas.com/guides/give-ai-agent-email-address

# Give Your AI Coding Agent an Email Address

AI coding agents can write code, debug tests, and refactor files — but they can't send a deploy notification, read a confirmation email, or check a calendar invite. Nylas CLI gives Claude Code, Cursor, OpenAI Codex CLI, and OpenClaw access to a real email account across 6 providers — Gmail, Outlook, Exchange, Yahoo, iCloud, and IMAP. One authentication, 16 MCP tools, setup in under 2 minutes per agent.

Written by [Caleb Geene](https://cli.nylas.com/authors/caleb-geene) Director, Site Reliability Engineering

Reviewed by [Hazik](https://cli.nylas.com/authors/hazik)

Updated April 24, 2026

> **TL;DR:** Install Nylas CLI, configure your API key with `nylas auth config --api-key`, then connect each agent via MCP. Claude Code, Cursor, and Codex CLI all support MCP natively. OpenClaw uses a plugin. Setup takes about 2 minutes per tool.

## Why give an AI coding agent an email address?

According to a March 2026 TechCrunch report, AgentMail raised $6 million to build email infrastructure for AI agents -- a sign that agent-to-email is becoming a core developer workflow. The use cases are practical: your agent sends a deploy notification to the team, reads an OTP from a signup flow, or schedules a meeting after a code review.

Most solutions lock you into a single provider. Gmail MCP servers only work with Google. Microsoft Graph only works with Outlook. Nylas CLI connects to all 6 major email providers through one authentication flow, and it works with any MCP-compatible coding agent.

## Step 1: Sign up, connect an account, and configure the CLI

Every tool in this guide connects to email through Nylas CLI. Three steps, done once:

### 1. Sign up for Nylas and create an API key

Go to [dashboard-v3.nylas.com](https://dashboard-v3.nylas.com/), create a free account, and generate an API key under Settings.

### 2. Connect at least one email account under Grants

In the Nylas dashboard, go to Grants and connect a Gmail, Outlook, Exchange, Yahoo, iCloud, or IMAP account. This is the email address your AI agent will use.

### 3. Install Nylas CLI and configure your API key

```bash
# Install (macOS / Linux)
brew install nylas/nylas-cli/nylas

# Configure your API key
nylas auth config --api-key YOUR_NYLAS_API_KEY

# Verify the connection
nylas auth whoami
```

On Windows or for shell-script and Go installs, see the [getting started guide](https://cli.nylas.com/guides/getting-started).

Replace `YOUR_NYLAS_API_KEY` with the key from step 1. According to the [Nylas MCP documentation](https://developer.nylas.com/docs/dev-guide/mcp/), this gives your agent access to 16 email, calendar, and contacts tools across all 6 providers.

## Step 2a: Give Claude Code an email address

Claude Code supports MCP natively. One command writes the config and sets tool permissions:

```bash
# Install MCP for Claude Code
nylas mcp install --assistant claude-code
```

This writes an MCP server entry to `~/.claude.json` and adds `mcp__nylas__*` to `~/.claude/settings.json` so all 16 Nylas tools are pre-approved without interactive prompts. Restart Claude Code, then try:

- " Read my latest 5 emails "
- " Send an email to alice@example.com about the deploy "
- " Check my calendar for tomorrow "

For the full MCP deep-dive -- available tools, regional endpoints, timezone handling -- see the [AI Agent Email Access via MCP](https://cli.nylas.com/guides/ai-agent-email-mcp) guide.

## Step 2b: Give Cursor an email address

Cursor supports MCP the same way. One command:

```bash
# Install MCP for Cursor
nylas mcp install --assistant cursor
```

This writes to `~/.cursor/mcp.json`. Restart Cursor, open Settings, and check Tools & MCP for a green dot next to "nylas".

**Alternative: hosted MCP server (no CLI install needed).** You can also connect Cursor directly to the Nylas MCP server over HTTP. Add this to `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "nylas": {
      "type": "streamable-http",
      "url": "https://mcp.us.nylas.com",
      "headers": {
        "Authorization": "Bearer YOUR_NYLAS_API_KEY"
      }
    }
  }
}
```

Replace `YOUR_NYLAS_API_KEY` with your API key from the [Nylas dashboard](https://dashboard-v3.nylas.com/). This skips the local CLI proxy entirely. The [Nylas MCP docs](https://developer.nylas.com/docs/dev-guide/mcp/) cover both methods.

## Step 2c: Give OpenAI Codex CLI an email address

Codex CLI supports MCP servers natively. According to the [OpenAI Codex MCP documentation](https://developers.openai.com/codex/mcp), you can add MCP servers as STDIO or streamable HTTP servers. Codex launches them automatically when a session starts.

### Option A: Local MCP via Nylas CLI

```bash
# Add Nylas as an MCP server (STDIO)
codex mcp add nylas -- nylas mcp serve
```

This adds a `[mcp_servers.nylas]` entry to `~/.codex/config.toml`. The resulting config looks like this:

```toml
# ~/.codex/config.toml
[mcp_servers.nylas]
command = "nylas"
args = ["mcp", "serve"]
```

### Option B: Hosted MCP server (no CLI install)

Connect directly to the Nylas MCP server over HTTP. Add this to `~/.codex/config.toml`:

```toml
# ~/.codex/config.toml
[mcp_servers.nylas]
url = "https://mcp.us.nylas.com"
bearer_token_env_var = "NYLAS_API_KEY"
```

```bash
# Set the environment variable
export NYLAS_API_KEY="your-api-key-here"
```

### Option C: Shell commands (no MCP)

Codex can also run Nylas CLI commands directly in its sandboxed shell. This works as a fallback if you prefer not to use MCP:

```bash
# Read recent emails
nylas email list --limit 10

# Search for specific emails
nylas email search "deploy notification"

# Send an email
nylas email send --to alice@example.com --subject "Deploy complete" --body "v2.4.1 is live."

# JSON output for structured parsing
nylas email list --limit 5 --json
```

For building structured tool definitions around shell commands, see [Build an LLM Agent with Email Tools](https://cli.nylas.com/guides/build-email-agent-cli).

## Step 2d: Give OpenClaw an email address

OpenClaw uses a plugin system instead of MCP. The Nylas plugin gives your OpenClaw assistant native email, calendar, and contacts tools with typed schemas and multi-account support.

```bash
# Install the Nylas plugin
openclaw plugins install @nylas/openclaw-nylas-plugin

# Trust the plugin and expose its tools to agent sessions
openclaw config set 'plugins.allow' '["nylas"]'
openclaw config set 'tools.alsoAllow' '["nylas"]'

# Configure your API key
openclaw config set 'plugins.entries.nylas.config.apiKey' 'YOUR_NYLAS_API_KEY'

# Restart the gateway so plugin config is reloaded
openclaw gateway restart

# Verify the plugin can see your connected accounts
openclaw plugins list
openclaw run "List my connected email accounts" --plugin nylas
```

Once installed, OpenClaw can send email, read threads, manage calendar events, and search contacts through natural language. The plugin auto-discovers all connected email accounts from your Nylas dashboard.

Full setup details are in the [Install the OpenClaw Nylas Plugin](https://cli.nylas.com/guides/install-openclaw-nylas-plugin) guide. New to OpenClaw? Start with the [OpenClaw CLI setup guide](https://cli.nylas.com/guides/openclaw-cli-setup).

## Comparison: email setup across AI coding agents

| AI Coding Agent | Integration | Setup Command | Config File |
| --- | --- | --- | --- |
| Claude Code | MCP (STDIO) | `nylas mcp install --assistant claude-code` | `~/.claude.json` |
| Cursor | MCP (STDIO or HTTP) | `nylas mcp install --assistant cursor` | `~/.cursor/mcp.json` |
| OpenAI Codex CLI | MCP (STDIO or HTTP) | `codex mcp add nylas -- nylas mcp serve` | `~/.codex/config.toml` |
| Windsurf | MCP (STDIO) | `nylas mcp install --assistant windsurf` | Windsurf config |
| OpenClaw | Plugin | `openclaw plugins install @nylas/openclaw-nylas-plugin` | OpenClaw plugin registry |

All five agents get the same 16 email, calendar, and contacts tools. MCP agents (Claude Code, Cursor, Codex, Windsurf) connect through the [Nylas MCP server](https://developer.nylas.com/docs/dev-guide/mcp/). OpenClaw connects through its plugin system. Every method supports all 6 email providers: Gmail, Outlook, Exchange, Yahoo, iCloud, and IMAP.

## What your agent can do with email access

Once connected, your AI coding agent has a working email address. Here are tasks it can handle:

- **Send a deploy notification** -- " Email the team that v2.4.1 is live on production "
- **Read a confirmation email** -- " Check my inbox for the AWS signup confirmation "
- **Extract an OTP code** -- " Get the 6-digit verification code from my latest email " (see [Email as Identity for AI Agents](https://cli.nylas.com/guides/email-as-identity-for-ai-agents))
- **Schedule a meeting** -- " Book a 30-minute call with alice@company.com next Tuesday at 2pm "
- **Search email history** -- " Find all emails about the Q4 contract and summarize the key decisions "
- **Draft a reply** -- " Draft a response to Sarah's budget question with the updated numbers "

## Security and access control

Giving an AI agent email access is a trust decision. Nylas CLI and MCP include guardrails:

- **Send confirmation required.** MCP tools require a `confirm_send_draft` step before any email is actually sent. Your agent creates a draft first, then you approve it.
- **Local credential storage.** Nylas CLI stores OAuth tokens on your machine. They don't leave your system unless you run a command.
- **Sandboxed execution.** Codex CLI runs shell commands in a sandbox with user approval for each action.
- **Revoke anytime.** Run `nylas auth logout` to disconnect, or `nylas auth list` to see connected accounts.

For full audit logging of every action your AI agents take with email, see the [Audit AI Agent Activity](https://cli.nylas.com/guides/audit-ai-agent-activity) guide.

## Next steps

- [AI Agent Email Access via MCP](https://cli.nylas.com/guides/ai-agent-email-mcp) -- full MCP deep-dive with all 16 tools, regional endpoints, and timezone handling
- [Build an LLM Agent with Email Tools](https://cli.nylas.com/guides/build-email-agent-cli) -- subprocess patterns for custom agents in Python and TypeScript
- [Why AI Agents Need Email](https://cli.nylas.com/guides/why-ai-agents-need-email) -- authentication, OTP, audit trails, and multi-threaded conversations
- [Audit AI Agent Activity](https://cli.nylas.com/guides/audit-ai-agent-activity) -- track every action Claude Code, Copilot, and MCP agents execute
- [Full command reference](https://cli.nylas.com/docs/commands) -- every flag, subcommand, and example
- [Nylas MCP documentation](https://developer.nylas.com/docs/dev-guide/mcp/) -- official server setup and API reference
