mail-mcp-custom
Provides tools for listing, reading, searching, and sending emails through the Gmail API, enabling AI agents to manage email communications.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mail-mcp-customlist my unread emails from yesterday"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mail-mcp-custom
Custom mail MCP server for local use with opencode, without Composio. The current provider is Gmail.
Project Map
src/server.ts: MCP stdio entry point for OpenCode and MCP tool registrationsrc/web.ts: local Express server for the browser UI and local/api/*routessrc/config.ts: environment configuration, OAuth settings, token path, UI path, and Gmail scopessrc/providers/gmail/oauth.ts: local Google OAuth browser flowsrc/providers/gmail/token-store.ts: local OAuth token persistencesrc/providers/gmail/gmail.ts: Gmail API client helperssrc/providers/llm/openai-compatible.ts: local OpenAI-compatible LLM client for email summariesui/: static browser UI served bysrc/web.tsdoc/: architecture notes and OpenCode configuration
Related MCP server: Gmail Plugin MCP Server
Entry Points
MCP server for OpenCode:
npm run devLocal browser UI:
npm run webType-check:
npm run checkBuild:
npm run build
Documentation Maintenance
When code changes affect behavior, setup, commands, environment variables, MCP tools, web routes, security assumptions, or limitations, update the relevant docs in the same change. Check README.md, AGENTS.md, doc/architecture-diagram.md, doc/opencode-configuration.md, and .env.example before finishing.
Included Features
Local Google OAuth for a single user
Token persistence in
data/gmail-token.jsonBasic MCP tools:
list_emailsread_emailsearch_emailssend_email
Optional local web UI for listing, searching, reading, sending, and moving messages to Gmail Trash
Local AI summary for emails received today through an OpenAI-compatible endpoint
Capability Matrix
Capability | MCP Tool | Web UI/API |
List messages |
|
|
Search messages |
|
|
Read message |
|
|
Send message |
|
|
Move to trash | Not exposed |
|
Summarize today's inbox | Not exposed |
|
Google Cloud Setup
Create a project in Google Cloud.
Enable the
Gmail API.Configure the
OAuth consent screen.Create an
OAuth Client IDof typeWeb application.Add this redirect URI:
http://127.0.0.1:4010/oauth/callbackLocal Setup
Copy
.env.exampleto.env.Fill in the Google OAuth values.
Run:
npm install
npm run devOn the first run, your browser opens for Google authentication.
Local Web UI
Run the browser UI with:
npm run webThen open:
http://127.0.0.1:4020The UI serves files from ui/ and exposes local-only API routes from src/web.ts.
Optional environment settings:
WEB_HOST=127.0.0.1
WEB_PORT=4020
UI_PATH=./uiTrash actions move messages to Gmail Trash. They do not permanently delete mail.
Local AI Summaries
The web UI can summarize emails received today with a local OpenAI-compatible LLM. The browser calls src/web.ts, and the server calls the configured local LLM endpoint.
Default local LLM settings:
LOCAL_LLM_BASE_URL=http://127.0.0.1:1234/v1
LOCAL_LLM_API_KEY=local
LOCAL_LLM_MODEL=qwen/qwen3.5-9b
LOCAL_LLM_TIMEOUT_MS=180000
LOCAL_LLM_MAX_TOKENS=4096The summary flow searches Gmail for today's inbox messages, reads each message, truncates long bodies, sends the summary prompt to the local LLM, and filters the visible message list to the summarized messages.
Initial Scopes
gmail.readonlygmail.sendgmail.modify
gmail.modify is required for moving messages to Trash from the local web UI.
OpenCode Config
The OpenCode configuration for this project is documented separately in doc/opencode-configuration.md.
Current Limitations
Single local user only
Plain text email sending only
No attachments
Trash support only moves messages to Gmail Trash; permanent delete is not implemented
AI summaries currently support only the
local_llmprovider; OpenCode provider switching is planned but not wired yetNo custom refresh-token logic outside the Google client
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cosmingherghe/mail-mcp-custom'
If you have feedback or need assistance with the MCP directory API, please join our Discord server