New: the MailCraft MCP server is live — connect your AI agent in one line. Connect your agent →
AI agents

OpenAI Codex

Codex is OpenAI’s coding agent. Connect MailCraft and Codex can send email, manage contacts and set up automations while it works on your code.

Prerequisites

  • Codex CLI (or the Codex IDE extension) installed
  • A MailCraft API key with the scopes you want the agent to have — create one under Settings → API keys.

Setup

  1. 1

    Set your API key

    Export it from your shell profile (~/.zshrc, ~/.bashrc, …) so it never sits in the config file:

    terminal
    export MAILCRAFT_API_KEY="sk_live_your_api_key"
  2. 2

    Add the server

    Edit ~/.codex/config.toml:

    ~/.codex/config.toml
    [mcp_servers.mailcraft]
    url = "https://mcp.mailcraft.host"
    bearer_token_env_var = "MAILCRAFT_API_KEY"

    Codex reads the bearer token from the named environment variable, so the key is never written to disk.

  3. 3

    Restart Codex

    Start a new Codex session to load the configuration.

  4. 4

    Verify the connection

    Run /mcp to confirm mailcraft is connected, then ask:

    codex
    List all my MailCraft domains

Example prompts

Once connected, try asking OpenAI Codex:

  • Hook up a MailCraft webhook handler for email.bounced in this app
  • Show me the last five emails that failed and why
  • Create a "Trial ending" template and a draft campaign for my trial users segment

See every tool the agent can use in the MCP server reference.