概览
What is MCP Gmail Server?
It is an MCP (Model Context Protocol) server for Gmail that exposes tools like list_unread and search_emails over the MCP protocol. It handles OAuth2 authentication with Google and is designed for integration with MCP clients such as Open WebUI.
How to use MCP Gmail Server?
Install dependencies with uv, place OAuth2 credentials in secrets/credentials.json, then run with uv run gmail-server. Alternatively, expose via mcpo using uvx mcpo --port 8000 --api-key "your-api-key" -- uv run gmail-server. Use any MCP‑compliant client to invoke the tools.
Key features of MCP Gmail Server
list_unreadtool to retrieve unread Gmail message snippets.search_emailstool to search by Gmail query.- Seamless OAuth2 flow with token caching.
- Asyncio‑based server compatible with MCP clients.
- Can be wrapped with
mcpofor HTTP/OpenAPI endpoints.
Use cases of MCP Gmail Server
- Quickly check unread emails through an AI assistant.
- Search for specific emails by sender or subject.
- Integrate Gmail functionality into Open WebUI workflows.
- Deploy as a containerized service using Docker.
FAQ from MCP Gmail Server
What tools does the server provide?
Two tools: list_unread (returns unread email snippets) and search_emails (returns emails matching a Gmail query).
What are the prerequisites?
Python 3.13 or newer, uv package manager, a Google account, and access to Google Cloud Console for Gmail API credentials.
How do I set up Gmail API credentials?
Create a project in Google Cloud Console, enable the Gmail API, configure an OAuth consent screen with your email as a test user, create an OAuth client ID for a desktop app, and place the downloaded JSON as secrets/credentials.json.
How do I run the server?
Run uv run gmail-server directly, or expose via mcpo with uvx mcpo --port 8000 --api-key "your-api-key" -- uv run gmail-server. The first run will prompt OAuth authorization in the browser.
Where are OAuth tokens stored?
A cached token is automatically saved to secrets/token.json after the first authorization, so subsequent runs do not require re‑authentication.