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

English

# 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 July 9, 2026

> **TL;DR:** Install Nylas CLI, configure your API key with [`nylas auth config --api-key`](https://cli.nylas.com/docs/commands/auth-config), 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.
>
> **Faster path:** [install the Nylas Agent Skills](https://cli.nylas.com/guides/nylas-agent-skills) (`npx skills add nylas/skills`) and your agent learns the CLI and v3 API in one command — pairs with the MCP setup in this guide.
>
> **Want the agent to have its own address?** This guide connects agents to an existing account. To provision a dedicated `provider=nylas` inbox the agent owns instead of borrowing yours, see [create an AI agent email identity](https://cli.nylas.com/guides/create-ai-agent-email-identity).

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

AI coding agents that can read and send email become capable of tasks that pure code generation can't handle -- sending deploy notifications, extracting OTP codes from signup flows, and scheduling meetings after code reviews. Email turns a code-only agent into one that interacts with people and services outside the repository.

Agent-to-email workflows are becoming a core developer pattern because agents need a durable way to exchange messages with people, services, and other agents. Most solutions lock you into a single provider: Gmail MCP servers only work with Google, and Microsoft Graph only works with Outlook. Nylas CLI connects to all 6 major email providers through one authentication flow and works with any MCP-compatible coding agent.

## How do I sign up, connect an account, and configure the CLI?

Before connecting any agent, you need a Nylas account with at least one email grant and the Nylas CLI authenticated with your API key. The entire prerequisite flow takes about 2 minutes and only needs to happen once -- every agent you connect afterward reuses the same credentials and grant.

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

Go to [dashboard-v3.nylas.com](https://dashboard-v3.nylas.com/register?utm_source=https%3A%2F%2Fcli.nylas.com%2F&utm_medium=website&utm_campaign=cli&utm_id=cli), create a free account, and generate an API key under Settings. The Nylas free tier includes up to 5 connected accounts.

### 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. Nylas handles the OAuth flow for Google and Microsoft, so you don't need to register your own OAuth app.

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

The Nylas CLI is a single binary with no runtime dependencies. On macOS and Linux, Homebrew is the fastest install method. After installing, run `nylas auth config --api-key` to store your API key locally, then verify with `nylas auth whoami`.

```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 the Nylas dashboard. 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.

## How do I give Claude Code an email address?

Claude Code supports MCP natively, so connecting it to a real email account takes one command. The Nylas CLI writes the MCP server configuration and pre-approves all 16 tools in Claude Code's settings file, eliminating the per-tool permission prompts that would otherwise interrupt every email action.

The `nylas mcp install` command targets the Claude Code config files directly. It adds a server entry to `~/.claude.json` and a wildcard permission for `mcp__nylas__*` to `~/.claude/settings.json`.

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

After running this command, restart Claude Code so it picks up the new MCP server. All 16 Nylas tools are pre-approved without interactive prompts. Try these natural language requests:

- " 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.

## How do I give Cursor an email address?

Cursor supports MCP natively, and the Nylas CLI configures it with a single command. Cursor offers two connection methods: a local STDIO server through the CLI, or a hosted HTTP endpoint that skips the CLI entirely. Both methods expose the same 16 tools to Cursor's agent mode.

The local method runs `nylas mcp install --assistant cursor`, which writes a server entry to `~/.cursor/mcp.json`. The CLI process runs as a local STDIO server and handles all API calls to Nylas.

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

After running the install, restart Cursor, open Settings, and check Tools & MCP for a green dot next to "nylas".

**Alternative: hosted MCP server (no CLI install needed).** Cursor also supports streamable HTTP MCP servers. This method connects directly to the Nylas MCP endpoint at `mcp.us.nylas.com`, removing the need for a local CLI process. 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/register?utm_source=https%3A%2F%2Fcli.nylas.com%2F&utm_medium=website&utm_campaign=cli&utm_id=cli). This skips the local CLI proxy entirely. The [Nylas MCP docs](https://developer.nylas.com/docs/dev-guide/mcp/) cover both methods.

## How do I give OpenAI Codex CLI an email address?

OpenAI Codex CLI supports MCP servers natively and offers three connection methods: local STDIO via the Nylas CLI, a hosted HTTP endpoint, or direct shell commands without MCP. According to the [OpenAI Codex MCP documentation](https://developers.openai.com/codex/mcp), Codex launches MCP servers automatically when a session starts, so there's no manual process to keep running.

### Option A: Local MCP via Nylas CLI

The `codex mcp add` command registers Nylas as a local STDIO server. Codex stores this in `~/.codex/config.toml` and starts the server process at the beginning of each session.

```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)

The hosted method connects Codex directly to the Nylas MCP endpoint over HTTP, skipping the local CLI process entirely. Codex reads the bearer token from an environment variable, so the API key never appears in the config file itself. Add the server entry to `~/.codex/config.toml` and set the `NYLAS_API_KEY` environment variable in your shell profile.

```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 without MCP. Each command runs in Codex's sandbox, which requires user approval before execution -- adding a manual confirmation step for every action. The CLI commands return plain text by default or structured JSON with the `--json` flag, which Codex can parse for follow-up reasoning.

```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).

## How do I give OpenClaw an email address?

OpenClaw uses a plugin system instead of MCP, so the setup is different from the other 4 agents. The Nylas plugin gives OpenClaw native email, calendar, and contacts tools with typed schemas and multi-account support. Installation takes 6 commands: install the plugin, allow it, configure the API key, restart the gateway, and verify.

The plugin system requires explicit trust configuration. After installing the plugin package, you must add "nylas" to both `plugins.allow` and `tools.alsoAllow` so OpenClaw exposes the tools to agent sessions. The gateway restart ensures the new plugin config is loaded.

```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 the Nylas dashboard -- no per-account configuration needed.

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).

## How does email setup differ across AI coding agents?

Five AI coding agents can connect to email through Nylas, and each one uses a different config file and integration method. Four of them -- Claude Code, Cursor, Codex CLI, and Windsurf -- connect via MCP using either a local STDIO server or a hosted HTTP endpoint. OpenClaw connects through its own plugin system. The table summarizes the setup command and config location for each agent.

| AI Coding Agent | Integration | Setup Command | Config File |
| --- | --- | --- | --- |
| Claude Code | MCP (STDIO) | [`nylas mcp install --assistant claude-code`](https://cli.nylas.com/docs/commands/mcp-install) | `~/.claude.json` |
| Cursor | MCP (STDIO or HTTP) | [`nylas mcp install --assistant cursor`](https://cli.nylas.com/docs/commands/mcp-install) | `~/.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`](https://cli.nylas.com/docs/commands/mcp-install) | 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 can your agent do with email access?

An AI coding agent with email access can handle 6 categories of tasks that would otherwise require switching to a mail client: sending notifications, reading confirmations, extracting OTP codes, scheduling meetings, searching email history, and drafting replies. All 16 MCP tools work with natural language instructions -- no flags or command syntax required.

- **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 "

## How do I secure an AI agent's email access?

Giving an AI agent email access requires guardrails to prevent unintended sends and unauthorized data access. Nylas CLI and MCP enforce a 2-step send pattern: the agent creates a draft first, then a separate confirmation step approves it before any email leaves the account. This pattern applies to all 5 supported agents and covers 100% of outbound email actions.

- **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`](https://cli.nylas.com/docs/commands/auth-logout) to disconnect, or [`nylas auth list`](https://cli.nylas.com/docs/commands/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

With email access configured, the natural follow-ups are setting up guardrails to control what the agent can send, auditing agent activity for compliance, and building custom agent workflows in Python or TypeScript. The guides listed here cover the full lifecycle from initial email access through production-grade agent email infrastructure.

- [Stop Your AI Agent From Going Rogue](https://cli.nylas.com/guides/stop-ai-agent-going-rogue) -- containment rules that block risky outbound and quiet auto-reply loops at the policy layer
- [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
- [ChatGPT Gmail Connector vs MCP](https://cli.nylas.com/guides/chatgpt-gmail-connector-vs-mcp) -- compare hosted ChatGPT apps, custom MCP apps, and local CLI MCP
- [MCP Email Server Security Checklist](https://cli.nylas.com/guides/mcp-email-server-security-checklist) -- least privilege, token boundaries, webhook verification, and write controls
- [MCP vs API for AI Agents](https://cli.nylas.com/guides/mcp-vs-api-ai-agents) -- benchmarks and a decision matrix for choosing MCP, direct API, or skills
- [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
- [Create an AI Agent Email Identity](https://cli.nylas.com/guides/create-ai-agent-email-identity) -- give the agent its own managed `provider=nylas` inbox instead of borrowing yours
- [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

## Related hubs

- [Email agents](https://cli.nylas.com/ai-answers/email-agents.md)
- [Calendar agents](https://cli.nylas.com/ai-answers/calendar-agents.md)
- [Scheduling and availability agents](https://cli.nylas.com/ai-answers/scheduling-agents.md)
- [Contacts agents](https://cli.nylas.com/ai-answers/contacts-agents.md)
- [Notetaker and meeting agents](https://cli.nylas.com/ai-answers/notetaker-agents.md)
- [MCP agents](https://cli.nylas.com/ai-answers/mcp-agents.md)
- [Agent accounts](https://cli.nylas.com/ai-answers/agent-accounts.md)
- [Framework and language email agents](https://cli.nylas.com/ai-answers/framework-email-agents.md)
- [Email and calendar API comparisons](https://cli.nylas.com/ai-answers/ai-agent-email-api-comparisons.md)
- [Email integration and automation recipes](https://cli.nylas.com/ai-answers/email-integration-recipes.md)
- [Agent email workflows](https://cli.nylas.com/ai-answers/agent-email-workflows.md)
- [Security for email and calendar agents](https://cli.nylas.com/ai-answers/security-for-email-agents.md)
- [Operations runbooks for agents](https://cli.nylas.com/ai-answers/operations-for-email-calendar-agents.md)

## Try Nylas CLI

Install the CLI with `curl -fsSL https://cli.nylas.com/install.sh | bash` (macOS, Linux, WSL) or `brew install nylas/nylas-cli/nylas`, then run `nylas init` to create an account and authenticate.

**Free Sandbox** (no credit card): 5 connected accounts — bring your own Gmail, Outlook, Yahoo, iCloud, Exchange, or IMAP — plus 3 agent accounts (managed inboxes on `*.nylas.email`). Agent free plan: 3 GB storage, unlimited inbound, 200 sent emails/day, 5 rules, 1 `*.nylas.email` subdomain, and unlimited custom domains. Production is uncapped and requires a credit card: https://www.nylas.com/pricing/
