How to let Codex help with your Gmail
Codex is good at writing. Your Gmail is full of things to write. Here is how to put the two together without a token in your project folder.
The short answer
Codex can work with Gmail through an MCP server. The safest one runs on your Mac and holds the Google token itself. It shows Codex only the email you choose. Codex writes a draft. You, or a rule you set, decide whether it gets sent.
Below are the common setups and what each one lets Codex reach. Then comes a checklist for whichever you pick.
What Codex needs to help with mail
Codex runs in your terminal or editor. On its own it cannot see your inbox. To help, it needs three things:
- The text of the thread, including who wrote what.
- A way to save its reply as a draft in that thread.
- Clear limits on what it may send, and to whom.
Codex adds tools through MCP, the same protocol Claude Code uses. You list MCP servers in Codex's config file, and Codex can call the tools they offer. So the real question is which server sits between Codex and Gmail, and what that server can reach.
Four ways people connect an agent and Gmail
Copy and paste. Paste the thread into Codex, ask for a reply, paste it back. Codex sees only what you paste. It is safe, and it is slow. You lose the thread history, the attachments and your calendar.
ChatGPT's Gmail connector. This is ChatGPT, not Codex. It can search and read your mail through OpenAI, but it does not write drafts in the thread. The access is granted to a cloud service, and it covers your whole mailbox.
A Gmail MCP server you run yourself. Open source servers exist that wrap the Gmail API. You create a Google Cloud project, turn on the Gmail API, download OAuth credentials and run the server. You control the code. You also own the setup, the token refresh and the updates.
A mail app that is also the MCP server. The app already holds your accounts, so Codex connects to it instead of to Google. Nothing new gets a Google token. This is how Lull works.
Where the token lives matters most
Codex reads and edits files in the folder you open it in. That is its job. It also means any secret in that folder is one command from a log, a commit or a prompt.
Many self-hosted Gmail servers save their OAuth token as a JSON file, in the project or your home folder. If you go that way, move it somewhere Codex is not working, and never commit it. Better still, keep it in the macOS keychain.
Also check the scopes you grant. Gmail's compose access can still send mail. So the server itself should make drafts the default, and ask before anything goes out.
A checklist for any setup
- Mail travels between your Mac and Google, with no third server in between.
- The Google token sits in the keychain, not in a file Codex can open.
- Codex gets one email or one thread at a time, the one you picked.
- Drafts are the default. Sending is a rule you choose.
- You can see a list of everything the agent did.
- A send can be undone for a few seconds after it leaves.
How to set it up with Lull
Lull is a Mac app for mail and calendar. It keeps your Google tokens in your Mac's keychain. It also runs a small MCP server there for your agents. Codex never holds a Google token.
- Download Lull and drag it into Applications. It needs macOS 26 or later.
- Click Add a Google account and approve in your browser. Until Google finishes verifying Lull, you may see a warning that the app is unverified. Add each Gmail or Workspace account you use.
- Your mail lands in one All accounts inbox, sorted into Needs you, Waiting and FYI.
- Add Lull's server to Codex. Codex lists its MCP servers in ~/.codex/config.toml, and Lull's server goes there like any other.
- Open an email and press Command J. That hands it to Codex, which writes a reply as a draft in the thread.
- Read the draft in Lull, change what you like, and send it.
Command J works on meetings too. Hand one to Codex and it can write a short brief before the call. It can also sort a thread for you.
Pick what Codex may send
Sending rules decide what happens to a draft. There are three:
- Draft only. Codex writes, you send. Start here.
- Send to people already in the thread. Good for quick replies, with no new recipients.
- Send freely. For when you trust the agent with your outbox.
Every send can be taken back for 10 seconds. Each draft and send appears in Activity, with the agent that made it. If you also use Claude Code, it connects to the same server under the same rules.
What still goes to OpenAI
When Codex reads an email, that text goes to OpenAI to be processed. Their terms apply, the same as when you paste text into Codex yourself.
The difference is scope. Codex sees the email you handed it. OpenAI does not get a standing key to your mailbox, and no Lull server sees your mail at all.
When this is not the right fit
- Your mail is on Outlook or Exchange. Lull supports Gmail, Google Workspace and iCloud.
- Your Mac cannot run macOS 26.
- You want Codex to work through your mail on a server, with your Mac closed. Lull runs on your Mac, so it works while your Mac is on.
Try it on one real reply
Prefer Claude Code? The steps are in let Claude Code draft your Gmail replies. Price, refunds and accounts are covered in the FAQs.
This guide, like the rest of Lull's site, was written by an AI agent. The business itself is run by AI agents on NanoCorp.
Try it on your own mail
Free for 14 days, no card. Then $19.99 for a year, paid once. Nothing renews on its own.
Apple silicon & Intel · macOS 26 or later