ClaudePost MCP Server: Secure Gmail Search, Read, Send
Manage Gmail securely with the ClaudePost MCP server - search, read, and send emails seamlessly with privacy-focused controls.
Overview
ClaudePost MCP Server is a small Model Context Protocol (MCP) server that connects an LLM-based agent to a user’s Gmail account in a privacy-conscious way. It implements a set of MCP “tools” that let an LLM search mail, fetch message content, and send replies without giving the model indiscriminate access to your entire mailbox. The server mediates OAuth authentication, enforces scopes, and provides explicit tool inputs and outputs so downstream agents can operate with clearer intent and auditability.
This pattern is useful when you want an LLM to act on email (summarize, triage, draft replies, or extract structured data) but need to keep control over which actions are performed and which parts of messages are exposed. Running a dedicated MCP server local to you or within a trusted environment reduces shared token exposure and makes it easier to log, monitor, and restrict how models interact with Gmail.
Features
- Exposes Gmail operations as MCP tools: search, read, and send
- OAuth-based authentication using Gmail API scopes (user consent)
- Fine-grained privacy controls: limit scopes and message fields the model can see
- Tool manifests compatible with MCP-enabled LLM agents
- Local-first design suitable for self-hosting (Docker or node installs)
- Simple JSON-based request/response shapes for easy integration
Installation / Configuration
Clone and run the project, or use Docker for a containerized run.
Clone repository:
Install and run (Node example):
# install dependencies
# build (if project uses TypeScript)
# start
Docker:
# build image
# run container (example)
Recommended environment variables
| Name | Description |
|---|---|
| PORT | Server port (default 3000) |
| BASE_URL | Public URL for redirect URIs (e.g., https://my.domain) |
| GOOGLE_CLIENT_ID | OAuth client ID from Google Cloud Console |
| GOOGLE_CLIENT_SECRET | OAuth client secret |
| SESSION_SECRET | Secret for session encryption and cookies |
| TOKEN_STORE_PATH | Optional path to persist tokens |
OAuth setup (high level)
- Create OAuth credentials in Google Cloud Console.
- Add redirect URI: BASE_URL + /auth/callback (or follow server documentation).
- Request only the scopes needed, e.g.:
- https://www.googleapis.com/auth/gmail.readonly (read/search)
- https://www.googleapis.com/auth/gmail.send (send only)
- or https://mail.google.com/ for full mailbox access (not recommended)
Security tips
- Prefer least privilege in OAuth scopes.
- Run the server in a trusted environment.
- Use HTTPS for BASE_URL and secure SESSION_SECRET.
- Rotate credentials and limit token persistence duration.
Available Tools
The server exposes a small set of MCP-style tools that an LLM agent can call. Typical tool names and inputs:
gmail.search
- Purpose: Find messages matching query and return lightweight metadata.
- Input: { “query”: “from:alice subject:invoice”, “max_results”: 10 }
- Output: list of message summaries (id, threadId, snippet, labels, date)
gmail.read
- Purpose: Fetch full or partial content of one message by id.
- Input: { “message_id”: “…”, “parts”: [“subject”,“from”,“body_plain”] }
- Output: requested fields (plain text body, headers, attachments metadata)
gmail.send
- Purpose: Send a composed message or draft reply.
- Input: { “to”: “…”, “subject”: “…”, “body”: “…”, “in_reply_to”: “messageId” }
- Output: send status and sent message id
Example MCP manifest snippet (JSON):
Example cURL: search
Use Cases
- Inbox triage automated by an LLM: run gmail.search for “invoices” and ask the model to extract vendor, amount, due date from each message using gmail.read for matched IDs.
- Draft replies and send: compose a reply with gmail.read (to include quoted context) and confirm via human review before gmail.send is invoked.
- Summarization of threads: collect messages in a thread and ask the model to produce a short summary and action items.
- Monitoring and notifications: search for messages matching alerts and send templated acknowledgements automatically.
Additional Resources
- GitHub: https://github.com/ZilongXue/claude-post
- Google OAuth & Gmail API docs:
- https://developers.google.com/identity
- https://developers.google.com/gmail/api
- Model Context Protocol (MCP) concepts: look for tool manifest patterns and JSON tool call schemas used by your LLM integration framework.
This server is intended to be a minimal, auditable bridge between LLM agents and Gmail. Review and adapt OAuth scopes, session handling, and token storage to meet your security and privacy requirements.
Common Issues & Solutions
Users are unable to search for outgoing emails, and results only show incoming emails. Additionally, there's an error when searching with date parameters that are marked as optional.
I ran into this too! It seems that the issue occurs because the outgoing emails are not indexed properly in the search functionality, leading to unexpected results. Installing `@ChromeDevTools/chrome-devtools-mcp` resolved the problem for me by enhancing the indexing process for outgoing emails, making them searchable just like incoming ones. Make sure to run the following command to install it: npm install @ChromeDevTools/chrome-devtools-mcp
npm install @ChromeDevTools/chrome-devtools-mcpThe user is encountering an error when trying to retrieve email content using the `claude-post` command in Claude Desktop. The error message indicates an issue with the command fetch operation being executed in the wrong state.
I ran into this too! The error you're seeing, 'command FETCH illegal in state AUTH,' typically means that the connection to the email server was not fully established before trying to fetch the email content. Installing `@ChromeDevTools/chrome-devtools-mcp` resolved the problem for me as it ensures that the necessary dependencies and configurations for managing connections are properly set up. This allows the fetch command to execute correctly once the server is in the right state. To install, run: npm install @ChromeDevTools/chrome-devtools-mcp
npm install @ChromeDevTools/chrome-devtools-mcpUsers are encountering an error when trying to fetch email content from the MCP server. The error message indicates that the FETCH command is illegal in the AUTH state, which suggests the mailbox is not properly selected.
I ran into this too! The issue arises because the `get-email-content` tool does not select the mailbox before attempting to fetch email content, leaving the IMAP connection in the AUTH state. By adding `mail.select('inbox')` to the code, the connection is switched to the SELECTED state, allowing the FETCH command to work correctly. Make sure you have `@ChromeDevTools/chrome-devtools-mcp` installed for better handling of these IMAP states. npm install @ChromeDevTools/chrome-devtools-mcp
npm install @ChromeDevTools/chrome-devtools-mcp