An MCP (Model Context Protocol) server that provides read-only access to your Gmail account. It exposes email subjects, senders, labels, categories, and full email content to LLM-powered tools like VS Code Copilot and Claude Desktop.
gmail_get_profile— Get your Gmail profile info (email, total messages)gmail_list_labels— List all labels with message/unread countsgmail_list_emails— List emails with optional Gmail search query and label filters (metadata only)gmail_search_emails— Search emails using Gmail query syntax (metadata only)gmail_get_email— Get the full content (text + HTML body) of a specific email by IDgmail_list_newsletters— List emails with the "Newsletter" label, with full content. Supports filtering by date, unread status, sender, subject, or any Gmail query.
- Node.js 18+ installed
- A Google Cloud project with the Gmail API enabled
- OAuth 2.0 Desktop credentials (
credentials.json)
- Go to Google Cloud Console
- Click Select a project → New Project
- Name it (e.g. "Gmail MCP Server") → Create
- In the sidebar, go to APIs & Services → Library
- Search for Gmail API
- Click Gmail API → Enable
- Go to APIs & Services → OAuth consent screen
- Choose User type:
- Internal (if using Google Workspace — recommended, no verification needed)
- External (for personal Gmail — will be in "Testing" mode, limited to test users you add)
- Fill in:
- App name:
Gmail MCP Server - User support email: your email
- Developer contact email: your email
- App name:
- On the Scopes page, click Add or Remove Scopes and add:
https://www.googleapis.com/auth/gmail.readonly - Save and continue through the remaining steps
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Application type: Desktop app
- Name:
Gmail MCP Server(or anything) - Click Create
- Click Download JSON — save this file as
credentials.jsonin the project root
# Install dependencies
npm install
# Build the TypeScript project
npm run buildnpm startOn the first run, the server will:
- Open your browser to Google's OAuth consent screen
- Ask you to sign in and grant read-only Gmail access
- Redirect back to
http://localhost:3000/oauth2callback - Save the token to
~/.gmail-mcp/tokens.json
Subsequent runs will reuse the saved token automatically.
Add to your .vscode/mcp.json in the workspace (or user settings):
{
"servers": {
"gmail": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/gmail-mcp/dist/index.js"],
"env": {
"GMAIL_CREDENTIALS_PATH": "/ABSOLUTE/PATH/TO/credentials.json"
}
}
}
}Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"gmail": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/gmail-mcp/dist/index.js"],
"env": {
"GMAIL_CREDENTIALS_PATH": "/ABSOLUTE/PATH/TO/credentials.json"
}
}
}
}npx @modelcontextprotocol/inspector node dist/index.js| Variable | Default | Description |
|---|---|---|
GMAIL_CREDENTIALS_PATH |
./credentials.json |
Path to the OAuth credentials JSON file |
GMAIL_TOKEN_PATH |
~/.gmail-mcp/tokens.json |
Where to store the OAuth refresh token |
GMAIL_MAX_RESULTS |
100 |
Default max results for list/search (max 100) |
This server uses a single read-only scope:
https://www.googleapis.com/auth/gmail.readonly
This grants read access to:
- Email messages (metadata + full body content)
- Labels and categories
- User profile
- Threads
It does NOT allow sending, deleting, or modifying any emails.
MIT