Guide
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 Director, Site Reliability Engineering
Reviewed by Hazik
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.
Step 1: 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, 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.
# 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 whoamiOn Windows or for shell-script and Go installs, see the getting started guide.
Replace YOUR_NYLAS_API_KEY with the key from the Nylas dashboard. According to the Nylas MCP documentation, 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, 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.
# Install MCP for Claude Code
nylas mcp install --assistant claude-codeAfter 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 guide.
Step 2b: 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.
# Install MCP for Cursor
nylas mcp install --assistant cursorAfter 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:
{
"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. This skips the local CLI proxy entirely. The Nylas MCP docs cover both methods.
Step 2c: 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, 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.
# Add Nylas as an MCP server (STDIO)
codex mcp add nylas -- nylas mcp serveThis adds a [mcp_servers.nylas] entry to ~/.codex/config.toml. The resulting config looks like this:
# ~/.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.
# ~/.codex/config.toml
[mcp_servers.nylas]
url = "https://mcp.us.nylas.com"
bearer_token_env_var = "NYLAS_API_KEY"# 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.
# 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 --jsonFor building structured tool definitions around shell commands, see Build an LLM Agent with Email Tools.
Step 2d: 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.
# 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 nylasOnce 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 guide. New to OpenClaw? Start with the OpenClaw CLI setup guide.
Comparison: email setup 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 | ~/.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. 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
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)
- 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 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_draftstep 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 logoutto disconnect, ornylas auth listto see connected accounts.
For full audit logging of every action your AI agents take with email, see the 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 -- containment rules that block risky outbound and quiet auto-reply loops at the policy layer
- AI Agent Email Access via MCP -- full MCP deep-dive with all 16 tools, regional endpoints, and timezone handling
- ChatGPT Gmail Connector vs MCP -- compare hosted ChatGPT apps, custom MCP apps, and local CLI MCP
- MCP Email Server Security Checklist -- least privilege, token boundaries, webhook verification, and write controls
- MCP vs API for AI Agents -- benchmarks and a decision matrix for choosing MCP, direct API, or skills
- Build an LLM Agent with Email Tools -- subprocess patterns for custom agents in Python and TypeScript
- Why AI Agents Need Email -- authentication, OTP, audit trails, and multi-threaded conversations
- Audit AI Agent Activity -- track every action Claude Code, Copilot, and MCP agents execute
- Create an AI Agent Email Identity -- give the agent its own managed
provider=nylasinbox instead of borrowing yours - Full command reference -- every flag, subcommand, and example
- Nylas MCP documentation -- official server setup and API reference