Gmail

com.pulsemcp由 pulsemcp.com 發布v0.4.12更新於 Oct 24, 2026

MCP server for Gmail with OAuth2 (personal) and service account (Workspace) support.

已驗證STDIO僅桌面效率與工作流溝通與協作

概覽

AI 產生的概覽

一個本機 MCP 伺服器,把 AI 助理連接到 Gmail,讓它能列出、搜尋、讀取、加標籤、撰寫草稿和寄送郵件。

可以做什麼
列出、讀取和搜尋郵件會話與草稿,支援標籤、日期篩選和 Gmail 查詢語法。變更郵件狀態和標籤:標示為已讀或未讀、加星號、封存、新增或移除標籤。建立、更新和刪除草稿郵件,包括回覆既有會話。直接寄送新郵件或回覆,也可寄送既有草稿。
適用情境
適合讓助理整理收件匣、依寄件者或主旨尋找郵件、準備草稿或寄送回覆,而不必切換到郵件用戶端。適用於個人 Gmail 帳戶,或可授予所需權限的 Google Workspace 組織。
執行需求
透過 npx 在本機執行,需要 Node.js。需要個人帳戶的 OAuth2 憑證(GMAIL_OAUTH_CLIENT_ID、GMAIL_OAUTH_CLIENT_SECRET、GMAIL_OAUTH_REFRESH_TOKEN,透過一次性瀏覽器設定取得),或具備網域委派權限的 Workspace 服務帳戶(GMAIL_SERVICE_ACCOUNT_CLIENT_EMAIL、GMAIL_SERVICE_ACCOUNT_PRIVATE_KEY、GMAIL_IMPERSONATE_EMAIL)。須在 Google Cloud 中啟用 Gmail API。
安裝前請注意
它會保存長期有效的憑證:OAuth 重新整理權杖或可模擬信箱的服務帳戶私密金鑰。預設啟用全部工具群組,包括寄送;可用 GMAIL_ENABLED_TOOLGROUPS 限制,例如設為 readonly。寫入和寄送操作會改動真實信箱資料並向外部收件者寄信,啟用前請先確認。郵件內容會傳送到所設定 Google 帳戶的 API。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Gmail,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Gmail Workspace MCP Server

An MCP (Model Context Protocol) server that provides Gmail integration for AI assistants. Supports both personal Gmail accounts (via OAuth2) and Google Workspace accounts (via service account with domain-wide delegation).

Features

  • List Email Conversations: Retrieve emails with label filtering
  • Get Email Details: Fetch full email content including body and attachments info
  • Search Emails: Search using Gmail's powerful query syntax
  • Manage Emails: Mark as read/unread, star/unstar, archive, apply labels
  • Create Drafts: Compose draft emails with reply support
  • Send Emails: Send new emails or replies, directly or from drafts
  • Two Auth Methods: OAuth2 for personal accounts, Service Account for Google Workspace

Installation

bash
npm install gmail-workspace-mcp-server

Or run directly with npx:

bash
npx gmail-workspace-mcp-server

Authentication

This server supports two authentication modes. Choose the one that matches your account type.

Option 1: OAuth2 (Personal Gmail Accounts)

Use this for personal @gmail.com accounts or any Google account without Workspace admin access.

Prerequisites
  1. Go to Google Cloud Console
  2. Create or select a project
  3. Enable the Gmail API
  4. Configure the OAuth consent screen:
    • Choose External user type
    • Add yourself as a test user
    • Publish the app (click "Publish" on the consent screen) to prevent refresh tokens from expiring every 7 days. No full Google verification is needed for personal use.
  5. Create OAuth 2.0 credentials:
    • Choose Desktop app as the application type
    • Important: Create new credentials after publishing the app
  6. Copy the Client ID and Client Secret
Getting a Refresh Token

Run the built-in setup command:

bash
npx gmail-workspace-mcp-server oauth-setup <client_id> <client_secret>

You can also pass credentials via environment variables:

bash
GMAIL_OAUTH_CLIENT_ID=... GMAIL_OAUTH_CLIENT_SECRET=... npx gmail-workspace-mcp-server oauth-setup

Port conflict? If port 3000 is already in use, specify a different port:

bash
PORT=3001 npx gmail-workspace-mcp-server oauth-setup <client_id> <client_secret>

Desktop app credentials automatically allow http://localhost redirects on any port, so no additional Google Cloud Console configuration is needed.

This will open your browser for Google sign-in and print the refresh token. You only need to do this once — the refresh token does not expire (as long as the OAuth consent screen is published).

Environment Variables (OAuth2)
VariableRequiredDescription
GMAIL_OAUTH_CLIENT_IDYesOAuth2 client ID from Google Cloud Console
GMAIL_OAUTH_CLIENT_SECRETYesOAuth2 client secret
GMAIL_OAUTH_REFRESH_TOKENYesRefresh token from the setup script
GMAIL_ENABLED_TOOLGROUPSNoComma-separated list of tool groups (default: all)
Claude Desktop Configuration (OAuth2)
json
{  "mcpServers": {    "gmail": {      "command": "npx",      "args": ["gmail-workspace-mcp-server"],      "env": {        "GMAIL_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",        "GMAIL_OAUTH_CLIENT_SECRET": "your-client-secret",        "GMAIL_OAUTH_REFRESH_TOKEN": "your-refresh-token"      }    }  }}

Option 2: Service Account (Google Workspace)

Use this for Google Workspace organizations where a domain admin can grant domain-wide delegation.

Prerequisites
  1. Go to Google Cloud Console
  2. Create or select a project
  3. Enable the Gmail API
  4. Create a service account with domain-wide delegation enabled
  5. In Google Workspace Admin Console, grant the service account access to the following scopes:
    • https://www.googleapis.com/auth/gmail.readonly (read emails)
    • https://www.googleapis.com/auth/gmail.modify (modify labels)
    • https://www.googleapis.com/auth/gmail.compose (create drafts)
    • https://www.googleapis.com/auth/gmail.send (send emails)
  6. Download the JSON key file
Environment Variables (Service Account)
VariableRequiredDescription
GMAIL_SERVICE_ACCOUNT_CLIENT_EMAILYesService account email address
GMAIL_SERVICE_ACCOUNT_PRIVATE_KEYYesService account private key (PEM format)
GMAIL_IMPERSONATE_EMAILYesEmail address to impersonate
GMAIL_ENABLED_TOOLGROUPSNoComma-separated list of tool groups to enable (default: all groups)

You can find the client_email and private_key values in your service account JSON key file.

Claude Desktop Configuration (Service Account)
json
{  "mcpServers": {    "gmail": {      "command": "npx",      "args": ["gmail-workspace-mcp-server"],      "env": {        "GMAIL_SERVICE_ACCOUNT_CLIENT_EMAIL": "[email protected]",        "GMAIL_SERVICE_ACCOUNT_PRIVATE_KEY": "-----BEGIN PRIVATE KEY-----\nMIIE...\n-----END PRIVATE KEY-----",        "GMAIL_IMPERSONATE_EMAIL": "[email protected]"      }    }  }}

Note: For the private key, you can either:

  1. Use the key directly with \n for newlines (as shown above)
  2. Set the environment variable from a shell that preserves newlines

Tool Groups

The server supports three tool groups for permission-based access control:

GroupTools IncludedRisk Level
readonlylist_email_conversations, get_email_conversation, search_email_conversations, list_draft_emailsLow
readwriteAll readonly tools + change_email_conversation, upsert_draft_emailMedium
readwrite_externalAll readwrite tools + send_emailHigh

By default, all tool groups are enabled. To restrict access, set the GMAIL_ENABLED_TOOLGROUPS environment variable:

bash
# Read-only access (no write/send capabilities)GMAIL_ENABLED_TOOLGROUPS=readonly
# Read and write, but no external sendingGMAIL_ENABLED_TOOLGROUPS=readwrite
# Full access including sending emails (default)GMAIL_ENABLED_TOOLGROUPS=readwrite_external

Security Note: The send_email tool is in a separate readwrite_external group because it can send emails externally, which carries higher risk than internal operations like modifying labels or creating drafts.

Available Tools

list_email_conversations

List email conversations from Gmail with optional filtering.

Parameters:

  • count (number, optional): Number of emails to return (default: 10, max: 100)
  • labels (string, optional): Comma-separated label IDs to filter by (default: "INBOX")
  • sort_by (string, optional): Sort order - "recent" (newest first) or "oldest" (default: recent)
  • after (string, optional): Only return emails after this datetime, exclusive (ISO 8601 UTC, e.g., "2024-01-15T14:30:00Z")
  • before (string, optional): Only return emails before this datetime, exclusive (ISO 8601 UTC, e.g., "2024-01-15T14:30:00Z")

Example:

json
{  "count": 20,  "labels": "INBOX,STARRED",  "after": "2024-01-15T00:00:00Z",  "before": "2024-01-20T23:59:59Z"}

get_email_conversation

Retrieve the full content of a specific email by its ID.

Parameters:

  • email_id (string, required): The unique identifier of the email

Example:

json
{  "email_id": "18abc123def456"}

search_email_conversations

Search emails using Gmail's powerful query syntax.

Parameters:

  • query (string, required): Gmail search query (e.g., "from:[email protected]", "is:unread", "subject:meeting")
  • count (number, optional): Maximum results to return (default: 10, max: 100)

Example:

json
{  "query": "from:[email protected] is:unread",  "count": 20}

change_email_conversation

Modify email labels and status (read/unread, starred, archived).

Parameters:

  • email_id (string, required): The email ID to modify
  • status (string, optional): "read", "unread", or "archived"
  • is_starred (boolean, optional): Star or unstar the email
  • labels (string, optional): Comma-separated labels to add
  • remove_labels (string, optional): Comma-separated labels to remove

Example:

json
{  "email_id": "18abc123def456",  "status": "read",  "is_starred": true}

list_draft_emails

List draft emails from Gmail with optional thread filtering.

Parameters:

  • count (number, optional): Maximum number of drafts to return (default: 10, max: 100)
  • thread_id (string, optional): Filter drafts by conversation thread ID

Example:

json
{  "thread_id": "18abc123def456"}

upsert_draft_email

Create, update, or delete a draft email. Optionally as a reply to an existing conversation.

Parameters:

  • draft_id (string, optional): ID of an existing draft to update or delete (omit to create a new draft)
  • delete (boolean, optional): Set to true to delete the draft specified by draft_id. All other parameters are ignored when deleting
  • to (string, required for create/update): Recipient email address
  • subject (string, required for create/update): Email subject
  • plaintext_body (string): Plain text body content (at least one of plaintext_body or html_body required for create/update)
  • html_body (string): HTML body content for rich text formatting (at least one of plaintext_body or html_body required for create/update)
  • cc (string, optional): CC recipients
  • bcc (string, optional): BCC recipients
  • thread_id (string, optional): Thread ID for replies
  • reply_to_email_id (string, optional): Email ID to reply to (sets References/In-Reply-To headers)

For create/update: at least one of plaintext_body or html_body must be provided. If both are provided, a multipart email is sent with both versions.

Example (create new draft):

json
{  "to": "[email protected]",  "subject": "Meeting Follow-up",  "plaintext_body": "Thanks for the meeting today!"}

Example (update existing draft):

json
{  "draft_id": "r123456789",  "to": "[email protected]",  "subject": "Meeting Follow-up (revised)",  "html_body": "<p>Thanks for the meeting today! Check out <a href=\"https://example.com/notes\">the notes</a>.</p>"}

Example (delete a draft):

json
{  "draft_id": "r123456789",  "delete": true}

send_email

Send an email directly or from an existing draft.

Parameters:

  • to (string, conditional): Recipient email (required unless sending from draft)
  • subject (string, conditional): Email subject (required unless sending from draft)
  • plaintext_body (string): Plain text body content (at least one of plaintext_body or html_body required, unless sending a draft)
  • html_body (string): HTML body content for rich text formatting (at least one of plaintext_body or html_body required, unless sending a draft)
  • cc (string, optional): CC recipients
  • bcc (string, optional): BCC recipients
  • from_draft_id (string, optional): Send an existing draft by ID
  • thread_id (string, optional): Thread ID for replies
  • reply_to_email_id (string, optional): Email ID to reply to

Example (plain text email):

json
{  "to": "[email protected]",  "subject": "Hello",  "plaintext_body": "This is a test email."}

Example (HTML email):

json
{  "to": "[email protected]",  "subject": "Hello",  "html_body": "<p>Check out <a href=\"https://example.com\">our website</a> for more details.</p>"}

Example (send draft):

json
{  "from_draft_id": "r123456789"}

Development

Setup

bash
# Install dependenciesnpm run install-all
# Buildnpm run build
# Run in development modenpm run dev

Testing

bash
# Run functional testsnpm test
# Run integration testsnpm run test:integration
# Run manual tests (requires credentials)npm run test:manual

License

MIT

來源:experimental/gmail/README.md,提交 0ed34de

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.4.12最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分