Launch-Free 3 months Builder plan-
Pixel art lobster working at a computer terminal with email — manage agent email inbox cli tool

how to manage your agent's email inbox from the command line

CLI tools let you manage agent email inboxes without a GUI. Here's what works, what breaks, and the fastest way to get your agent reading and sending email.

8 min read
Ian Bussières
Ian BussièresCTO & Co-founder

Raf Camlet's viral post on building a Gmail CLI for Claude Code kicked off a wave of developers piping their inbox through the terminal. The idea is compelling: skip the browser, let your agent triage email, summarize newsletters, archive thousands of messages in seconds. The post got tens of thousands of reads and a flood of GitHub stars. But buried in the setup instructions are six OAuth scopes, a Google Cloud project, a service account JSON file, and a consent screen that expires every seven days in test mode.

That's a lot of infrastructure for "let the agent read my email."

CLI tools for managing agent email have come a long way since the days of mutt and alpine. In 2026, the real question isn't whether you can manage an agent's email from the command line. It's whether you should be managing your personal Gmail from a CLI, or giving your agent its own inbox that it controls from the start.

This article walks through both approaches, the tradeoffs of each, and why agent-first email infrastructure is eating the DIY CLI approach for most use cases.

The Gmail CLI approach (and where it breaks down)#

The Camlet-style setup works like this: you create a Google Cloud project, enable the Gmail API, generate OAuth credentials, build a Node.js wrapper around the Gmail REST API, and expose it to your coding agent as a set of shell commands. Your agent can then run something like gmail search "from:stripe subject:invoice" and get structured output.

For personal inbox triage, this is genuinely useful. You can have Claude Code archive 3,000 unread newsletters in a single session. You can build custom filters that are smarter than Gmail's built-in rules. You can pipe email content into other tools.

But the moment you try to use this pattern for an autonomous agent (one that needs its own email identity, not yours), the problems stack up fast:

OAuth tokens expire. Google's OAuth tokens have a 7-day expiry for apps in "testing" mode. Publishing the app requires a review process that takes weeks. Your agent works perfectly on Monday and silently fails on the following Tuesday because the refresh token died.

Scope creep is a security risk. Giving an agent gmail.modify scope means it can delete your emails, not just the agent's messages. There's no way to restrict a Gmail CLI to "only this agent's correspondence" because Gmail doesn't have that concept. It's your whole inbox or nothing.

You're sharing an identity. When your agent sends email through your Gmail, it sends as you. Recipients see your name, your address, your reply history. If the agent makes a mistake (sends a duplicate, replies to the wrong thread, uses a weird tone), it looks like you made that mistake.

Rate limits hit different for automation. Gmail's API allows roughly 250 quota units per second per user. A single messages.list call costs 5 units. An agent that polls every 30 seconds, processes attachments, and sends replies can burn through that quota in minutes, especially during batch operations.

None of this means the Gmail CLI approach is bad. For your inbox, managed by you with agent assistance, it's a great tool. The problem is that developers keep reaching for it when what they actually need is agent-owned email, and those are two very different things.

What agent-owned email actually looks like#

An agent that owns its own inbox doesn't authenticate against your personal account. It provisions an address, receives mail at that address, and sends from it. No shared credentials, no token refresh dances, no risk of accidentally archiving your mortgage documents.

Here's the practical difference. With a Gmail CLI, your agent runs:

gmail send --to client@example.com --subject "Invoice" --body "Attached."

The email arrives from you@gmail.com. The recipient replies to you. The agent has to filter your entire inbox to find the response.

With agent-owned email, the agent provisions its own address and works from there:

import { LobsterMail } from '@lobsterkit/lobstermail';

const lm = await LobsterMail.create();
const inbox = await lm.createSmartInbox({ name: 'Invoice Bot' });
// inbox.address → invoice-bot@lobstermail.ai

await inbox.send({
  to: 'client@example.com',
  subject: 'Invoice #1042',
  body: 'Your invoice is attached.',
});

const replies = await inbox.receive();

The email arrives from invoice-bot@lobstermail.ai. Replies go back to that address. The agent's inbox contains only its own correspondence. No filtering needed, no scope conflicts, no OAuth.

CLI tools that actually work for agent email#

If you want command-line control over your agent's email (and you should, because GUIs are terrible for automation), here are the options that hold up in practice.

LobsterMail's MCP server#

The MCP (Model Context Protocol) server gives any compatible agent email tools without writing code. Claude Code, Cursor, Windsurf, and other MCP-compatible tools can use it directly. Your agent gets create_inbox, send_email, receive_emails, and list_inboxes as callable tools.

Setup is one line in your MCP config:

{
  "mcpServers": {
    "lobstermail": {
      "command": "npx",
      "args": ["-y", "@lobsterkit/lobstermail-mcp"]
    }
  }
}

No API keys to paste. No OAuth flow. The agent self-provisions on first use. If you're using Claude Code or Cursor, this is the fastest path from "I want my agent to have email" to "my agent has email."

If you want your agent handling email right now, and paste them into your agent. It takes about 90 seconds.

AgentMail CLI#

AgentMail offers a CLI tool (agentmail-cli) and SDKs in Python, TypeScript, and Go. It's the other major player in agent-specific email. Their approach is similar: API-first, programmatic inbox management, built-in SPF/DKIM/DMARC. The main difference is that AgentMail requires you to sign up, grab an API key, and pass it to the CLI manually. It works, but there's a human in the loop for that first provisioning step.

MCP Agent Mail (open source)#

Jeff Dicklesworth's mcp_agent_mail is an interesting open-source project that adds a mail-like coordination layer for multi-agent workflows. It's built on FastMCP, Git, and SQLite, which means it runs locally with no external dependencies. The catch: it's designed for inter-agent messaging, not for sending and receiving real email on the internet. Think of it as internal Slack for your agents, not an inbox that can receive a Stripe webhook notification.

The DIY SMTP approach#

You can always spin up Postfix, configure DNS records, set up DKIM signing, build an IMAP interface, and write your own CLI wrapper. Some developers do this. It works. It also takes a weekend of setup, ongoing maintenance, and the kind of DNS debugging that makes you question your career choices. If you enjoy that sort of thing, more power to you. For everyone else, it's a distraction from the thing you're actually building.

Choosing the right tool for your use case#

The decision tree is simpler than it looks:

"I want my coding agent to help me manage my personal inbox." → Build a Gmail CLI. Raf's tutorial is solid. You keep full control of your own email, and the agent acts as an assistant, not an autonomous actor.

"I want my agent to have its own email address for signups, notifications, or client communication." → Use agent-first infrastructure. The agent shouldn't be borrowing your identity. It needs its own address, its own inbox, its own send reputation.

"I want multiple agents to coordinate with each other via messages." → Look at mcp_agent_mail for internal coordination, and give each externally-facing agent its own real inbox for anything that touches the outside world.

"I want CLI control over agent inboxes." → MCP is the answer. It gives your agent (and you, through the agent) full command-line-style control over inbox creation, email sending, and message retrieval. No GUI required.

The real shift happening here#

A year ago, the idea of an AI agent having its own email felt weird. Today, it feels obvious. The Gmail CLI wave proved that developers want their agents handling email. The next step is recognizing that agents shouldn't be squatting in human inboxes to do it.

The CLI isn't going away. If anything, command-line control over email is becoming more relevant as agents become the primary users. But the infrastructure underneath needs to match. An agent that can hatch its own inbox, send authenticated email, and receive replies without touching a single human credential is a fundamentally different thing than a Python script that wraps the Gmail API.

If you're building an agent that interacts with the outside world, give it the right tools. Your inbox will thank you.


Frequently asked questions

What is a CLI tool for managing agent email?

A CLI (command-line interface) tool lets you or your agent create inboxes, send emails, receive messages, and manage email workflows from the terminal. No graphical interface needed. Tools like LobsterMail's MCP server and AgentMail's CLI both offer this.

Can I use a Gmail CLI for my AI agent's email?

You can, but your agent will send email as you and share your inbox. OAuth tokens expire frequently in testing mode, and there's no way to isolate the agent's correspondence from your personal email. It works for personal inbox triage but not for autonomous agent email.

What is MCP and how does it relate to agent email?

MCP (Model Context Protocol) is a standard that lets AI agents call external tools. LobsterMail's MCP server gives compatible agents (Claude Code, Cursor, Windsurf) email tools like create_inbox and send_email without writing code. See the MCP server guide for details.

Do I need an API key to use LobsterMail from the command line?

No. LobsterMail's SDK and MCP server auto-provision a free account on first use. No API key, no signup form, no human in the loop. The token is stored locally and reused automatically.

Is LobsterMail free?

Yes, the free tier includes 1 inbox and 1,000 emails per month at $0 with no credit card required. The Builder plan at $9/month adds up to 10 inboxes and 5,000 emails/month. See pricing for the full breakdown.

Can my agent create multiple email inboxes from the CLI?

Yes. On the free plan your agent gets one inbox. The Builder plan ($9/month) supports up to 10. Each inbox gets its own address and isolated message store, so different agents or workflows don't cross-contaminate.

What's the difference between agent-owned email and a Gmail wrapper?

A Gmail wrapper gives your agent access to your inbox with your identity. Agent-owned email gives the agent its own address (like my-agent@lobstermail.ai) with isolated storage and independent send reputation. The agent never touches your personal email.

Does LobsterMail handle SPF, DKIM, and DMARC automatically?

Yes. All three authentication protocols are configured automatically for @lobstermail.ai addresses. If you use a custom domain, LobsterMail provides the DNS records you need.

Can I use LobsterMail with Claude Code or Cursor?

Yes. Add the MCP server to your tool's config and your agent gets email tools immediately. No SDK installation needed for MCP-compatible tools. See the integrations guide for setup instructions.

How does LobsterMail protect agents from prompt injection in emails?

Every incoming email gets an injection risk score. The agent can check this score before processing email content, filtering out messages that contain suspicious prompt injection patterns. See the security docs for how scoring works.

Can I use a custom domain with LobsterMail instead of @lobstermail.ai?

Yes. Custom domains are available on paid plans. You add DNS records that LobsterMail provides, and your agent sends from agent@yourdomain.com instead. See custom domains.

What happens if my agent's email gets rate-limited?

LobsterMail's free tier allows 1,000 emails/month. Builder allows 5,000/month with up to 500 sends per day. If you hit the limit, sends are queued or rejected depending on your plan. You won't get your domain blacklisted because limits are enforced before sending.

Related posts