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 Gmail, Outlook, Exchange, Yahoo, iCloud, and IMAP. One authentication, 16 tools, every provider.

By Caleb Geene

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, 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

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

# Or use the shell script (macOS / Linux / WSL)
curl -fsSL https://cli.nylas.com/install.sh | bash

# Windows (PowerShell)
irm https://cli.nylas.com/install.ps1 | iex

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

# Verify the connection
nylas auth whoami

Replace YOUR_NYLAS_API_KEY with the key from step 1. 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. One command writes the config and sets tool permissions:

# 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 guide.

Step 2b: Give Cursor an email address

Cursor supports MCP the same way. One command:

# 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:

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

Codex CLI supports MCP servers natively. According to the OpenAI Codex MCP documentation, 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

# 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:

# ~/.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:

# ~/.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. This works as a fallback if you prefer not to use MCP:

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

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.

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

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

# Discover connected accounts
openclaw nylas discover

# Verify
openclaw plugins list

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 guide. New to OpenClaw? Start with the OpenClaw CLI setup guide.

Comparison: email setup across AI coding agents

AI Coding AgentIntegrationSetup CommandConfig File
Claude CodeMCP (STDIO)nylas mcp install --assistant claude-code~/.claude.json
CursorMCP (STDIO or HTTP)nylas mcp install --assistant cursor~/.cursor/mcp.json
OpenAI Codex CLIMCP (STDIO or HTTP)codex mcp add nylas -- nylas mcp serve~/.codex/config.toml
WindsurfMCP (STDIO)nylas mcp install --assistant windsurfWindsurf config
OpenClawPluginopenclaw plugins install @nylas/openclaw-nylas-pluginOpenClaw 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

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

Next steps