personal-gmail-mcp
Enables managing Gmail inbox and Google Calendar through MCP, with tools for email operations and calendar events.
README
personal-gmail-mcp
A Model Context Protocol server that exposes a personal Gmail (consumer Google account) inbox and calendar to MCP clients like Claude Desktop. Talks to the Gmail and Google Calendar APIs over HTTPS, uses a local loopback OAuth flow, and stores tokens in the OS keyring.
Sibling to personal-outlook-mcp; same design (local stdio, keyring-backed tokens, you bring your own OAuth client), different provider. Tools are prefixed gmail_*.
Status: functional. Auth (loopback OAuth + keyring token cache), 12 mail tools, and 7 calendar tools are in place and verified against a live account. Not yet published to npm — install from source for now (see below).
Why keyring + bring-your-own-client
Every Gmail MCP server we surveyed stores OAuth tokens as a plaintext JSON file in your home directory. This one stores them in the OS keyring (macOS Keychain / Windows Credential Manager / Linux Secret Service) via @napi-rs/keyring, and runs entirely locally — your mail never passes through anyone else's servers.
Google setup (required, ~5 minutes, free)
You must create your own Google Cloud OAuth client.
- Go to https://console.cloud.google.com → create a project.
- APIs & Services → Library → enable both Gmail API and Google Calendar API.
- APIs & Services → OAuth consent screen:
- User type: External.
- Add your own Google account as a test user.
- Publish the app ("In production"). You can leave it unverified for personal use (you'll click through an "unverified app" warning at sign-in).
- ⚠️ This step matters: an app left in "Testing" status issues refresh tokens that expire after 7 days — you'd have to re-auth every week. Publishing to production (even unverified) gives long-lived refresh tokens.
- APIs & Services → Credentials → Create credentials → OAuth client ID → application type Desktop app. Copy the Client ID and Client secret.
cp .env.example .envand fill inGOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET.
The required scopes are requested at sign-in; you consent at the browser prompt:
| Scope | Used for |
|---|---|
https://mail.google.com/ |
full mailbox read/modify/send |
.../auth/calendar.events |
event read/create/update/cancel/respond |
.../auth/calendar.calendarlist.readonly |
enumerating your calendars (gmail_calendar_list_calendars) |
.../auth/userinfo.email + openid |
identifying the signed-in account |
Changing the scope list invalidates the cached token — re-run
npm run whoamito re-consent.
First run (loopback auth)
npm install
npm run build
npm run whoami
whoami opens your browser to Google's consent page (the URL is also printed to stderr if the browser doesn't open). After you approve, a throwaway 127.0.0.1 listener captures the redirect, exchanges the code, and stores the token set in the OS keyring under service personal-gmail-mcp. It then prints your Gmail profile as JSON. Subsequent runs refresh silently.
To sign out (forget the cached token):
node -e "import('./dist/auth.js').then(m => m.signOut())"
MCP client integration
Point your MCP client (Claude Desktop or similar) at the built server. Until
this is published to npm, use the from-source form with an absolute path to
dist/index.js:
{
"mcpServers": {
"personal-gmail": {
"command": "node",
"args": ["/absolute/path/to/personal-gmail-mcp/dist/index.js"],
"env": {
"GOOGLE_CLIENT_ID": "<YOUR-CLIENT-ID>",
"GOOGLE_CLIENT_SECRET": "<YOUR-CLIENT-SECRET>"
}
}
}
}
If your
nodeis managed by a version manager (nvm, mise, asdf), use the absolute path to the node binary (e.g.which node) — MCP clients launch with a minimalPATHand won't resolve a barenode.
Once published to npm, the simpler npx form works:
{
"command": "npx",
"args": ["-y", "@jaingxyz/personal-gmail-mcp"],
"env": { "GOOGLE_CLIENT_ID": "...", "GOOGLE_CLIENT_SECRET": "..." }
}
Run npm run whoami from a terminal once to seed the keyring before
launching the client — the browser/consent step can't be surfaced from inside
the app (stderr is swallowed), so the MCP server only does silent refresh and
will report Re-authentication required if the cache is empty or stale.
Tools
All tools are prefixed gmail_* (mail) or gmail_calendar_* (calendar) so a
multi-account setup can coexist.
| Tool | Purpose |
|---|---|
gmail_list_labels |
List labels (system + custom) with unread/total counts. |
gmail_list_recent |
Newest-first messages in a label. Supports unreadOnly, cursor paging. |
gmail_search |
Search with Gmail query syntax (from:, subject:, has:attachment, newer_than:). |
gmail_read |
Fetch one message with decoded body (text preferred, html fallback). |
gmail_mark_read |
Mark read/unread (toggles the UNREAD label). |
gmail_modify_labels |
Add/remove labels (remove INBOX to archive, add STARRED, etc.). |
gmail_delete |
Trash (recoverable) by default; hardDelete=true is permanent. |
gmail_untrash |
Restore a message from Trash. |
gmail_send |
Send a new email immediately. |
gmail_reply |
Reply in-thread by message id; replyAll=true for all recipients. |
gmail_create_draft |
Create a draft without sending; returns a draftId. |
gmail_send_draft |
Send a previously created draft. |
gmail_calendar_list_calendars |
List calendars with editability. |
gmail_calendar_list_events |
Events in a time range (recurring series expanded). |
gmail_calendar_read_event |
Full event details incl. attendees and recurrence. |
gmail_calendar_create_event |
Create an event; optional Google Meet link and invites. |
gmail_calendar_update_event |
Update subject/time/location/description/attendees. |
gmail_calendar_cancel_event |
Delete an event; notifies attendees when you organize it. |
gmail_calendar_respond_to_invite |
accept / tentativelyAccept / decline an invite. |
Calendar event times use { dateTime, timeZone } where dateTime is local
form (no offset) and timeZone is an IANA name. Output times default to
America/Los_Angeles; override with PERSONAL_GMAIL_TZ.
How it differs from the Outlook server
| Outlook (Graph) | Gmail | |
|---|---|---|
| Auth flow | MSAL device code | Loopback / installed-app (Google forbids device code for Gmail) |
| Mail container | Folders | Labels (INBOX, SENT, DRAFT, TRASH, custom) |
| Search | Graph $search (KQL) |
Gmail query syntax (from: subject: has:attachment newer_than:) |
| Send | JSON message | base64url RFC-2822 MIME |
| Soft delete | move to Deleted Items | trash / untrash |
| Calendar | same Graph API | separate Google Calendar API + scope |
License
AGPL-3.0-or-later. See LICENSE.
Acknowledgements
Built with assistance from Claude (Anthropic). Architecture and final review remain the human author's responsibility.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。