Fluxmail is a self-hosted MCP server that connects AI agents to your email. It runs on your machine or a server you control, talks to Gmail through a Google OAuth app that you own, and gives any MCP client the same tools to read, search, draft, send, and organize mail over stdio or Streamable HTTP.
This guide takes you from nothing to a working setup: install the CLI, create Google credentials, connect Gmail, and register the server with your agent.
What you need
- Node.js 20.19 or newer
- A Google account
- An MCP client such as Claude Code, Claude Desktop, ChatGPT, Codex, Cursor, Gemini CLI, Hermes, or VS Code
1. Install Fluxmail
npm install -g fluxmail
Check that your shell can find it:
which fluxmail
Keep that path handy. Some desktop apps start with a limited PATH; if your client cannot find fluxmail, use the absolute path returned by this command.
2. Create Google OAuth credentials
Fluxmail talks to Gmail through your own Google Cloud OAuth app, so the API quota and the consent screen are yours.
- Open Google Cloud Console and create or select a project.
- Go to APIs & Services → Library and enable the Gmail API.
- Configure the OAuth consent screen. Choose External, then add yourself and anyone else who will connect an account as test users. Testing mode is fine for self-hosting; Google does not require verification for up to 100 test users.
- Go to Credentials → Create credentials → OAuth client ID.
- Choose Web application and add these authorized redirect URIs:
http://localhost:8976/oauth/callback(used byfluxmail accounts add gmail)<your FLUXMAIL_PUBLIC_URL>/auth/google/callback(only if you use the server-hosted flow on a remote deployment)
Fluxmail requests the full https://mail.google.com/ scope because its email API supports permanent deletion, which Gmail's narrower scopes do not allow.
While your consent screen is in Google's "Testing" status, refresh tokens expire seven days after they are issued, even if Fluxmail uses them during that window. When a token expires, find the account ID with fluxmail accounts list, then reconnect it:
fluxmail accounts add gmail --reauthorize <account-id>
To avoid the seven-day expiry, publish the consent screen to "In production" for long-lived tokens.
3. Run Fluxmail and connect Gmail
There are two ways to run the server. Pick one.
Option A: local process (stdio)
The shortest path for personal use on one machine.
# Store your Google credentials once; they live in ~/.fluxmail/config.env
fluxmail config set GOOGLE_CLIENT_ID <your-client-id>.apps.googleusercontent.com
fluxmail config set GOOGLE_CLIENT_SECRET <your-client-secret>
# Connect your Gmail (opens a browser consent flow)
fluxmail accounts add gmail
Option B: Docker (Streamable HTTP server)
For a shared or remote deployment. The image is published to GitHub Container Registry as ghcr.io/churichard/fluxmail-mcp for amd64 and arm64.
mkdir fluxmail && cd fluxmail
curl -fsSLO https://raw.githubusercontent.com/churichard/fluxmail-mcp/main/docker-compose.yml
curl -fsSL https://raw.githubusercontent.com/churichard/fluxmail-mcp/main/.env.example -o .env
# Fill in GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET in .env
docker compose up -d
# Create an API key (shown once). Name it after the client that will use it, e.g. "laptop".
docker compose exec fluxmail fluxmail apikey create --name laptop
# Connect your Gmail: prints a consent URL; open it in your browser
docker compose exec fluxmail fluxmail accounts add gmail
4. Connect your agent
Follow the subsection matching how you ran Fluxmail in step 3.
Option A: stdio clients
Every client launches the same command: fluxmail stdio. Your Google credentials come from fluxmail config set, so the snippets need no environment variables. Two notes:
- Desktop apps sometimes launch with a minimal
PATHand fail to findfluxmail(common with nvm installs). If that happens, use the absolute path fromwhich fluxmailas the command. - If you skipped
fluxmail config set, addGOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETto the client's env settings instead.
Claude Code
claude mcp add fluxmail -- fluxmail stdio
Claude Desktop
Add to claude_desktop_config.json (Settings → Developer → Edit Config):
{
"mcpServers": {
"fluxmail": {
"command": "fluxmail",
"args": ["stdio"]
}
}
}
ChatGPT / Codex app
Open Settings → Plugins → MCPs → Add server, then enter:
- Name:
Fluxmail - Type:
STDIO - Command to launch:
fluxmail - Argument:
stdio
If the app cannot find fluxmail, use the absolute path from which fluxmail as the command. Save, then restart the app so it picks up the change.
Codex CLI
codex mcp add fluxmail -- fluxmail stdio
Or in ~/.codex/config.toml:
[mcp_servers.fluxmail]
command = "fluxmail"
args = ["stdio"]
Cursor
Add to ~/.cursor/mcp.json (or .cursor/mcp.json in a project):
{
"mcpServers": {
"fluxmail": {
"command": "fluxmail",
"args": ["stdio"]
}
}
}
Hermes
Add to ~/.hermes/config.yaml, then run /reload-mcp (or use the dashboard at hermes dashboard):
mcp_servers:
fluxmail:
command: 'fluxmail'
args: ['stdio']
Gemini CLI
Add to ~/.gemini/settings.json:
{
"mcpServers": {
"fluxmail": {
"command": "fluxmail",
"args": ["stdio"]
}
}
}
VS Code (Copilot agent mode)
Add to .vscode/mcp.json in a workspace, or run "MCP: Add Server" from the command palette:
{
"servers": {
"fluxmail": {
"type": "stdio",
"command": "fluxmail",
"args": ["stdio"]
}
}
}
Other stdio clients
Register fluxmail as the command with stdio as its argument, in whatever shape your client's config uses.
Option B: Streamable HTTP clients
Every client connects to http://localhost:8977/mcp (or your deployed URL) and authenticates with the header Authorization: Bearer fmk_..., using the API key from step 3.
Claude Code
claude mcp add --transport http fluxmail http://localhost:8977/mcp \
--header "Authorization: Bearer fmk_..."
ChatGPT / Codex app
Open Settings → Plugins → MCPs → Add server, then enter:
- Name:
Fluxmail - Type:
Streamable HTTP - URL:
http://localhost:8977/mcp - Header name:
Authorization - Header value:
Bearer fmk_...
Save, then restart the app so it picks up the change.
Codex CLI
Add to ~/.codex/config.toml:
[mcp_servers.fluxmail]
url = "http://localhost:8977/mcp"
http_headers = { Authorization = "Bearer fmk_..." }
Cursor
Add to ~/.cursor/mcp.json (or .cursor/mcp.json in a project):
{
"mcpServers": {
"fluxmail": {
"url": "http://localhost:8977/mcp",
"headers": { "Authorization": "Bearer fmk_..." }
}
}
}
Hermes
Add to ~/.hermes/config.yaml, then run /reload-mcp:
mcp_servers:
fluxmail:
url: 'http://localhost:8977/mcp'
headers:
Authorization: 'Bearer fmk_...'
Gemini CLI
Add to ~/.gemini/settings.json:
{
"mcpServers": {
"fluxmail": {
"httpUrl": "http://localhost:8977/mcp",
"headers": { "Authorization": "Bearer fmk_..." }
}
}
}
VS Code (Copilot agent mode)
Add to .vscode/mcp.json in a workspace, or run "MCP: Add Server" from the command palette:
{
"servers": {
"fluxmail": {
"type": "http",
"url": "http://localhost:8977/mcp",
"headers": { "Authorization": "Bearer fmk_..." }
}
}
}
ChatGPT chats (developer mode)
The ChatGPT / Codex app entry above configures Codex inside the ChatGPT app. Developer-mode apps used from regular ChatGPT chats have a separate setup.
ChatGPT cannot connect directly to localhost. For a local Docker server, use OpenAI's Secure MCP Tunnel instead of exposing the server to the public internet. You can also deploy Fluxmail at a public HTTPS URL.
ChatGPT connectors support OAuth or no authentication; they cannot send Fluxmail's static bearer API key. Until Fluxmail supports MCP OAuth, run it with FLUXMAIL_AUTH=none only behind the secure tunnel or a network boundary you control. Then enable developer mode (Settings → Apps → Advanced Settings) and create an app pointing at your /mcp URL.
MCP OAuth support, which would remove this limitation, is on the roadmap.
Other HTTP clients
Point the client at the /mcp URL and send Authorization: Bearer fmk_.... Clients that cannot set an authorization header are not compatible with API-key mode; use a trusted network with FLUXMAIL_AUTH=none instead.
Once it's connected, ask your agent something like "What's the latest email from my bank?" to confirm it works.
Next steps
- See Tools for the full tool set your agent can call.
- See Configuration for environment variables.
- See CLI reference for every
fluxmailcommand. - See Teams & plans for members, shared mailboxes, and paid-plan licensing.
- See Architecture for where your data lives and how Fluxmail is built.