gmail-mcp-server
Reads unread emails from the inbox and creates threaded draft replies in Gmail, without sending any email automatically.
Can be extended to fetch style guides and templates from Google Docs as external context for drafting replies.
Can be extended to query a Notion database as external context for reply guidance and templates.
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., "@gmail-mcp-serverCheck my unread emails and summarize the most important ones."
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.
Gmail MCP Server
A Model Context Protocol server that lets an AI assistant (Claude Desktop, Claude API, etc.) read unread Gmail messages and create threaded draft replies — without ever sending email automatically.
What this server does
Tool | Description |
| Returns up to 50 unread inbox messages: sender, subject, date, body, and IDs |
| Saves a threaded draft reply in Gmail Drafts (user must send manually) |
| (Stretch goal) Returns a style guide, templates, and knowledge-base snippets to guide better replies |
The server communicates with Claude Desktop over stdio using the MCP JSON-RPC protocol. It never sends email — only creates drafts.
Related MCP server: Gmail MCP Server
Prerequisites
Python 3.10+
A Google account
Claude Desktop installed
Quick start
1. Clone and install
git clone <this-repo>
cd gmail-mcp-server
bash scripts/setup.sh
source .venv/bin/activate2. Set up Gmail API credentials
Follow the detailed guide in docs/gmail_api_setup.md.
Summary:
Create a Google Cloud project.
Enable the Gmail API.
Configure the OAuth consent screen (External, test mode is fine).
Add scopes:
gmail.readonly+gmail.compose.Create an OAuth 2.0 Desktop App credential.
Download
credentials.json→ place in project root.
3. Authenticate
python scripts/auth_check.pyA browser window opens. Sign in and approve access. token.pickle is saved.
4. Test the server manually
# Start the server (press Ctrl-C to stop)
gmail-mcpThe server waits for JSON-RPC on stdin. You can send a test message:
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | gmail-mcp5. Configure Claude Desktop
Edit claude_desktop_config.json (see docs/claude_desktop_config.md):
{
"mcpServers": {
"gmail": {
"command": "/absolute/path/to/.venv/bin/python",
"args": ["-m", "gmail_mcp_server.server"],
"cwd": "/absolute/path/to/gmail-mcp-server",
"env": {
"GMAIL_CREDENTIALS_PATH": "/absolute/path/to/credentials.json",
"GMAIL_TOKEN_PATH": "/absolute/path/to/token.pickle"
}
}
}
}Restart Claude Desktop. The gmail tools will appear automatically.
Example Claude prompts
Check my unread emails and tell me which ones need urgent attention.I have an unread email about a refund request. Draft a polite reply
using our style guide, then save it as a draft.Fetch my 5 newest unread emails. For each one, tell me the sender,
subject, and a one-sentence summary.Use get_reply_context to see our templates, then create a draft reply
to the meeting invite email.Project structure
gmail-mcp-server/
├── src/
│ └── gmail_mcp_server/
│ ├── __init__.py
│ ├── server.py # MCP server entry point & tool definitions
│ ├── auth.py # OAuth 2.0 credential management
│ ├── gmail_tools.py # Gmail API logic (read emails, create drafts)
│ └── context.py # Stretch-goal: style guide, templates, KB search
├── context/
│ ├── style_guide.md # Writing style guide (edit to match your voice)
│ ├── templates.json # Reply templates
│ └── knowledge_base/ # .md/.txt files Claude can search
├── scripts/
│ ├── setup.sh # One-time environment setup
│ └── auth_check.py # OAuth flow + credential verification
├── docs/
│ ├── mcp_concepts.md # How MCP tools work (detailed explanation)
│ ├── gmail_api_setup.md # Step-by-step Google Cloud setup
│ └── claude_desktop_config.md # Claude Desktop config + example prompts
├── pyproject.toml
├── .env.example
└── .gitignoreHow MCP tools work (summary)
MCP tools are callable functions that an LLM can invoke via JSON-RPC:
Discovery — Claude calls
tools/list; the server returns tool names, descriptions, and JSON Schemas for their arguments.Decision — The LLM decides which tool to call based on the description and the user's request.
Invocation — Claude calls
tools/callwith the tool name and arguments.Result — The server returns a
TextContentblock (JSON string) that Claude reads and incorporates into its response.
See docs/mcp_concepts.md for a full explanation with
sequence diagrams and annotated code.
Stretch goal: external context
The get_reply_context tool pulls in:
Style guide (
context/style_guide.md) – tone, structure, phrases to use/avoid.Templates (
context/templates.json) – starting points for common reply types.Knowledge base (
context/knowledge_base/) – searched by keyword.
To connect real cloud sources:
Google Docs – enable the Docs API, add
documents.readonlyscope, fetch document content viadocs.documents().get().Notion – install
notion-client, query a database with your integration token.Vector search – replace
search_knowledge_base()incontext.pywithchromadborhnswlibfor semantic search over larger document sets.
Security notes
credentials.jsonandtoken.pickleare in.gitignore— never commit them.The server only requests
gmail.readonlyandgmail.composescopes.No email is ever sent automatically;
create_draft_replyonly callsdrafts.create, notmessages.send.The OAuth consent screen is in "Testing" mode by default — only you can authenticate.
Troubleshooting
Problem | Fix |
Tools don't appear in Claude Desktop | Check |
| Download from Google Cloud Console and place in project root |
| Add your email to Test Users in OAuth consent screen |
| Delete |
Empty email body | Email may be HTML-only; |
For more, see docs/gmail_api_setup.md.
License
MIT
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
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/ktsenapathy/gmail-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server