Skip to content
Back to search

Gmail-MCP-Server

A Model Context Protocol (MCP) server for Gmail integration in Claude Desktop with auto authentication support. This server enables AI assistants to manage Gmail through natural language interactions.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/gongrzhe--gmail-mcp-server/badge.svg)](/listings/gongrzhe--gmail-mcp-server)

HTML

<a href="/listings/gongrzhe--gmail-mcp-server"><img src="/api/listings/gongrzhe--gmail-mcp-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Installing via Smithery

To install Gmail AutoAuth for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@gongrzhe/server-gmail-autoauth-mcp):

npx -y @smithery/cli install @gongrzhe/server-gmail-autoauth-mcp --client claude

Installing Manually

1. Create a Google Cloud Project and obtain credentials:

a. Create a Google Cloud Project: - Go to [Google Cloud Console](https://console.cloud.google.com/) - Create a new project or select an existing one - Enable the Gmail API for your project

b. Create OAuth 2.0 Credentials: - Go to "APIs & Services" > "Credentials" - Click "Create Credentials" > "OAuth client ID" - Choose either "Desktop app" or "Web application" as application type - Give it a name and click "Create" - For Web application, add `http://localhost:3000/oauth2callback` to the authorized redirect URIs - Download the JSON file of your client's OAuth keys - Rename the key file to `gcp-oauth.keys.json`

2. Run Authentication:

You can authenticate in two ways:

a. Global Authentication (Recommended):

   # First time: Place gcp-oauth.keys.json in your home directory's .gmail-mcp folder
   mkdir -p ~/.gmail-mcp
   mv gcp-oauth.keys.json ~/.gmail-mcp/

   # Run authentication from anywhere
   npx @gongrzhe/server-gmail-autoauth-mcp auth

b. Local Authentication:

   # Place gcp-oauth.keys.json in your current directory
   # The file will be automatically copied to global config
   npx @gongrzhe/server-gmail-autoauth-mcp auth

The authentication process will: - Look for `gcp-oauth.keys.json` in the current directory or `~/.gmail-mcp/` - If found in current directory, copy it to `~/.gmail-mcp/` - Open your default browser for Google authentication - Save credentials as `~/.gmail-mcp/credentials.json`

> **Note**: > - After successful authentication, credentials are stored globally in `~/.gmail-mcp/` and can be used from any directory > - Both Desktop app and Web application credentials are supported > - For Web application credentials, make sure to add `http://localhost:3000/oauth2callback` to your authorized redirect URIs

3. Configure in Claude Desktop:

{
  "mcpServers": {
    "gmail": {
      "command": "npx",
      "args": [
        "@gongrzhe/server-gmail-autoauth-mcp"
      ]
    }
  }
}

Docker Support

If you prefer using Docker:

1. Authentication:

docker run -i --rm \
  --mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json \
  -v mcp-gmail:/gmail-server \
  -e GMAIL_OAUTH_PATH=/gcp-oauth.keys.json \
  -e "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json" \
  -p 3000:3000 \
  mcp/gmail auth

2. Usage:

{
  "mcpServers": {
    "gmail": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "mcp-gmail:/gmail-server",
        "-e",
        "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json",
        "mcp/gmail"
      ]
    }
  }
}

Cloud Server Authentication

For cloud server environments (like n8n), you can specify a custom callback URL during authentication:

npx @gongrzhe/server-gmail-autoauth-mcp auth https://gmail.gongrzhe.com/oauth2callback

Setup Instructions for Cloud Environment

1. **Configure Reverse Proxy:** - Set up your n8n container to expose a port for authentication - Configure a reverse proxy to forward traffic from your domain (e.g., `gmail.gongrzhe.com`) to this port

2. **DNS Configuration:** - Add an A record in your DNS settings to resolve your domain to your cloud server's IP address

3. **Google Cloud Platform Setup:** - In your Google Cloud Console, add your custom domain callback URL (e.g., `https://gmail.gongrzhe.com/oauth2callback`) to the authorized redirect URIs list

4. **Run Authentication:**

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 745 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Gmail AutoAuth MCP Server
  2. A Model Context Protocol (MCP) server for Gmail integration in Claude Desktop with auto authentication support. This server enables AI assistants to manage Gmail through natural language interactions.
  3. ![](https://badge.mcpx.dev?type=server 'MCP Server')
  4. [![smithery badge](https://smithery.ai/badge/@gongrzhe/server-gmail-autoauth-mcp)](https://smithery.ai/server/@gongrzhe/server-gmail-autoauth-mcp)
  5. ## Features
  6. - Send emails with subject, content, **attachments**, and recipients
  7. - **Full attachment support** - send and receive file attachments
  8. - **Download email attachments** to local filesystem
  9. - Support for HTML emails and multipart messages with both HTML and plain text versions
  10. - Full support for international characters in subject lines and email content
  11. - Read email messages by ID with advanced MIME structure handling
  12. - **Enhanced attachment display** showing filenames, types, sizes, and download IDs
  13. - Search emails with various criteria (subject, sender, date range)
  14. - **Comprehensive label management with ability to create, update, delete and list labels**
  15. - List all available Gmail labels (system and user-defined)
  16. - List emails in inbox, sent, or custom labels
  17. - Mark emails as read/unread
  18. - Move emails to different labels/folders
  19. - Delete emails
  20. - **Batch operations for efficiently processing multiple emails at once**
  21. - Full integration with Gmail API
  22. - Simple OAuth2 authentication flow with auto browser launch
  23. - Support for both Desktop and Web application credentials
  24. - Global credential storage for convenience
  25. ## Installation & Authentication
  26. ### Installing via Smithery
  27. To install Gmail AutoAuth for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@gongrzhe/server-gmail-autoauth-mcp):
  28. ```bash
  29. npx -y @smithery/cli install @gongrzhe/server-gmail-autoauth-mcp --client claude
  30. ```
  31. ### Installing Manually
  32. 1. Create a Google Cloud Project and obtain credentials:
  33. a. Create a Google Cloud Project:
  34. - Go to [Google Cloud Console](https://console.cloud.google.com/)
  35. - Create a new project or select an existing one
  36. - Enable the Gmail API for your project
  37. b. Create OAuth 2.0 Credentials:
  38. - Go to "APIs & Services" > "Credentials"
  39. - Click "Create Credentials" > "OAuth client ID"
  40. - Choose either "Desktop app" or "Web application" as application type
  41. - Give it a name and click "Create"
  42. - For Web application, add `http://localhost:3000/oauth2callback` to the authorized redirect URIs
  43. - Download the JSON file of your client's OAuth keys
  44. - Rename the key file to `gcp-oauth.keys.json`
  45. 2. Run Authentication:
  46. You can authenticate in two ways:
  47. a. Global Authentication (Recommended):
  48. ```bash
  49. # First time: Place gcp-oauth.keys.json in your home directory's .gmail-mcp folder
  50. mkdir -p ~/.gmail-mcp
  51. mv gcp-oauth.keys.json ~/.gmail-mcp/
  52. # Run authentication from anywhere
  53. npx @gongrzhe/server-gmail-autoauth-mcp auth
  54. ```
  55. b. Local Authentication:
  56. ```bash
  57. # Place gcp-oauth.keys.json in your current directory
  58. # The file will be automatically copied to global config
  59. npx @gongrzhe/server-gmail-autoauth-mcp auth
  60. ```
  61. The authentication process will:
  62. - Look for `gcp-oauth.keys.json` in the current directory or `~/.gmail-mcp/`
  63. - If found in current directory, copy it to `~/.gmail-mcp/`
  64. - Open your default browser for Google authentication
  65. - Save credentials as `~/.gmail-mcp/credentials.json`
  66. > **Note**:
  67. > - After successful authentication, credentials are stored globally in `~/.gmail-mcp/` and can be used from any directory
  68. > - Both Desktop app and Web application credentials are supported
  69. > - For Web application credentials, make sure to add `http://localhost:3000/oauth2callback` to your authorized redirect URIs
  70. 3. Configure in Claude Desktop:
  71. ```json
  72. {
  73. "mcpServers": {
  74. "gmail": {
  75. "command": "npx",
  76. "args": [
  77. "@gongrzhe/server-gmail-autoauth-mcp"
  78. ]
  79. }
  80. }
  81. }
  82. ```
  83. ### Docker Support
  84. If you prefer using Docker:
  85. 1. Authentication:
  86. ```bash
  87. docker run -i --rm \
  88. --mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json \
  89. -v mcp-gmail:/gmail-server \
  90. -e GMAIL_OAUTH_PATH=/gcp-oauth.keys.json \
  91. -e "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json" \
  92. -p 3000:3000 \
  93. mcp/gmail auth
  94. ```
  95. 2. Usage:
  96. ```json
  97. {
  98. "mcpServers": {
  99. "gmail": {
  100. "command": "docker",
  101. "args": [
  102. "run",
  103. "-i",
  104. "--rm",
  105. "-v",
  106. "mcp-gmail:/gmail-server",
  107. "-e",
  108. "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json",
  109. "mcp/gmail"
  110. ]
  111. }
  112. }
  113. }
  114. ```
  115. ### Cloud Server Authentication
  116. For cloud server environments (like n8n), you can specify a custom callback URL during authentication:
  117. ```bash
  118. npx @gongrzhe/server-gmail-autoauth-mcp auth https://gmail.gongrzhe.com/oauth2callback
  119. ```
  120. #### Setup Instructions for Cloud Environment
  121. 1. **Configure Reverse Proxy:**
  122. - Set up your n8n container to expose a port for authentication
  123. - Configure a reverse proxy to forward traffic from your domain (e.g., `gmail.gongrzhe.com`) to this port
  124. 2. **DNS Configuration:**
  125. - Add an A record in your DNS settings to resolve your domain to your cloud server's IP address
  126. 3. **Google Cloud Platform Setup:**
  127. - In your Google Cloud Console, add your custom domain callback URL (e.g., `https://gmail.gongrzhe.com/oauth2callback`) to the authorized redirect URIs list
  128. 4. **Run Authentication:**
  129. ```bash
  130. npx @gongrzhe/server-gmail-autoauth-mcp auth https://gmail.gongrzhe.com/oauth2callback
  131. ```
  132. 5. **Configure in your application:**
  133. ```json
  134. {
  135. "mcpServers": {
  136. "gmail": {
  137. "command": "npx",
  138. "args": [
  139. "@gongrzhe/server-gmail-autoauth-mcp"
  140. ]
  141. }
  142. }
  143. }
  144. ```
  145. This approach allows authentication flows to work properly in environments where localhost isn't accessible, such as containerized applications or cloud servers.
  146. ## Available Tools
  147. The server provides the following tools that can be used through Claude Desktop:
  148. ### 1. Send Email (`send_email`)
  149. Sends a new email immediately. Supports plain text, HTML, or multipart emails **with optional file attachments**.
  150. Basic Email:
  151. ```json
  152. {
  153. "to": ["recipient@example.com"],
  154. "subject": "Meeting Tomorrow",
  155. "body": "Hi,\n\nJust a reminder about our meeting tomorrow at 10 AM.\n\nBest regards",
  156. "cc": ["cc@example.com"],
  157. "bcc": ["bcc@example.com"],
  158. "mimeType": "text/plain"
  159. }
  160. ```
  161. **Email with Attachments:**
  162. ```json
  163. {
  164. "to": ["recipient@example.com"],
  165. "subject": "Project Files",
  166. "body": "Hi,\n\nPlease find the project files attached.\n\nBest regards",
  167. "attachments": [
  168. "/path/to/document.pdf",
  169. "/path/to/spreadsheet.xlsx",
  170. "/path/to/presentation.pptx"
  171. ]
  172. }
  173. ```
  174. HTML Email Example:
  175. ```json
  176. {
  177. "to": ["recipient@example.com"],
  178. "subject": "Meeting Tomorrow",
  179. "mimeType": "text/html",
  180. "body": "<html><body><h1>Meeting Reminder</h1><p>Just a reminder about our <b>meeting tomorrow</b> at 10 AM.</p><p>Best regards</p></body></html>"
  181. }
  182. ```
  183. Multipart Email Example (HTML + Plain Text):
  184. ```json
  185. {
  186. "to": ["recipient@example.com"],
  187. "subject": "Meeting Tomorrow",
  188. "mimeType": "multipart/alternative",
  189. "body": "Hi,\n\nJust a reminder about our meeting tomorrow at 10 AM.\n\nBest regards",
  190. "htmlBody": "<html><body><h1>Meeting Reminder</h1><p>Just a reminder about our <b>meeting tomorrow</b> at 10 AM.</p><p>Best regards</p></body></html>"
  191. }
  192. ```
  193. ### 2. Draft Email (`draft_email`)
  194. Creates a draft email without sending it. **Also supports attachments**.
  195. ```json
  196. {
  197. "to": ["recipient@example.com"],
  198. "subject": "Draft Report",
  199. "body": "Here's the draft report for your review.",
  200. "cc": ["manager@example.com"],
  201. "attachments": ["/path/to/draft_report.docx"]
  202. }
  203. ```
  204. ### 3. Read Email (`read_email`)
  205. Retrieves the content of a specific email by its ID. **Now shows enhanced attachment information**.
  206. ```json
  207. {
  208. "messageId": "182ab45cd67ef"
  209. }
  210. ```
  211. **Enhanced Response includes attachment details:**
  212. ```
  213. Subject: Project Files
  214. From: sender@example.com
  215. To: recipient@example.com
  216. Date: Thu, 19 Jun 2025 10:30:00 -0400
  217. Email body content here...
  218. Attachments (2):
  219. - document.pdf (application/pdf, 245 KB, ID: ANGjdJ9fkTs-i3GCQo5o97f_itG...)
  220. - spreadsheet.xlsx (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, 89 KB, ID: BWHkeL8gkUt-j4HDRp6o98g_juI...)
  221. ```
  222. ### 4. **Download Attachment (`download_attachment`)**
  223. **NEW**: Downloads email attachments to your local filesystem.
  224. ```json
  225. {
  226. "messageId": "182ab45cd67ef",
  227. "attachmentId": "ANGjdJ9fkTs-i3GCQo5o97f_itG...",
  228. "savePath": "/path/to/downloads",
  229. "filename": "downloaded_document.pdf"
  230. }
  231. ```
  232. Parameters:
  233. - `messageId`: The ID of the email containing the attachment
  234. - `attachmentId`: The attachment ID (shown in enhanced email display)
  235. - `savePath`: Directory to save the file (optional, defaults to current directory)
  236. - `filename`: Custom filename (optional, uses original filename if not provided)
  237. ### 5. Search Emails (`search_emails`)
  238. Searches for emails using Gmail search syntax.
  239. ```json
  240. {
  241. "query": "from:sender@example.com after:2024/01/01 has:attachment",
  242. "maxResults": 10
  243. }
  244. ```
  245. ### 6. Modify Email (`modify_email`)
  246. Adds or removes labels from emails (move to different folders, archive, etc.).
  247. ```json
  248. {
  249. "messageId": "182ab45cd67ef",
  250. "addLabelIds": ["IMPORTANT"],
  251. "removeLabelIds": ["INBOX"]
  252. }
  253. ```
  254. ### 7. Delete Email (`delete_email`)
  255. Permanently deletes an email.
  256. ```json
  257. {
  258. "messageId": "182ab45cd67ef"
  259. }
  260. ```
  261. ### 8. List Email Labels (`list_email_labels`)
  262. Retrieves all available Gmail labels.
  263. ```json
  264. {}
  265. ```
  266. ### 9. Create Label (`create_label`)
  267. Creates a new Gmail label.
  268. ```json
  269. {
  270. "name": "Important Projects",
  271. "messageListVisibility": "show",
  272. "labelListVisibility": "labelShow"
  273. }
  274. ```
  275. ### 10. Update Label (`update_label`)
  276. Updates an existing Gmail label.
  277. ```json
  278. {
  279. "id": "Label_1234567890",
  280. "name": "Urgent Projects",
  281. "messageListVisibility": "show",
  282. "labelListVisibility": "labelShow"
  283. }
  284. ```
  285. ### 11. Delete Label (`delete_label`)
  286. Deletes a Gmail label.
  287. ```json
  288. {
  289. "id": "Label_1234567890"
  290. }
  291. ```
  292. ### 12. Get or Create Label (`get_or_create_label`)
  293. Gets an existing label by name or creates it if it doesn't exist.
  294. ```json
  295. {
  296. "name": "Project XYZ",
  297. "messageListVisibility": "show",
  298. "labelListVisibility": "labelShow"
  299. }
  300. ```
  301. ### 13. Batch Modify Emails (`batch_modify_emails`)
  302. Modifies labels for multiple emails in efficient batches.
  303. ```json
  304. {
  305. "messageIds": ["182ab45cd67ef", "182ab45cd67eg", "182ab45cd67eh"],
  306. "addLabelIds": ["IMPORTANT"],
  307. "removeLabelIds": ["INBOX"],
  308. "batchSize": 50
  309. }
  310. ```
  311. ### 14. Batch Delete Emails (`batch_delete_emails`)
  312. Permanently deletes multiple emails in efficient batches.
  313. ```json
  314. {
  315. "messageIds": ["182ab45cd67ef", "182ab45cd67eg", "182ab45cd67eh"],
  316. "batchSize": 50
  317. }
  318. ```
  319. ### 14. Create Filter (`create_filter`)
  320. Creates a new Gmail filter with custom criteria and actions.
  321. ```json
  322. {
  323. "criteria": {
  324. "from": "newsletter@company.com",
  325. "hasAttachment": false
  326. },
  327. "action": {
  328. "addLabelIds": ["Label_Newsletter"],
  329. "removeLabelIds": ["INBOX"]
  330. }
  331. }
  332. ```
  333. ### 15. List Filters (`list_filters`)
  334. Retrieves all Gmail filters.
  335. ```json
  336. {}
  337. ```
  338. ### 16. Get Filter (`get_filter`)
  339. Gets details of a specific Gmail filter.
  340. ```json
  341. {
  342. "filterId": "ANe1Bmj1234567890"
  343. }
  344. ```
  345. ### 17. Delete Filter (`delete_filter`)
  346. Deletes a Gmail filter.
  347. ```json
  348. {
  349. "filterId": "ANe1Bmj1234567890"
  350. }
  351. ```
  352. ### 18. Create Filter from Template (`create_filter_from_template`)
  353. Creates a filter using pre-defined templates for common scenarios.
  354. ```json
  355. {
  356. "template": "fromSender",
  357. "parameters": {
  358. "senderEmail": "notifications@github.com",
  359. "labelIds": ["Label_GitHub"],
  360. "archive": true
  361. }
  362. }
  363. ```
  364. ## Filter Management Features
  365. ### Filter Criteria
  366. You can create filters based on various criteria:
  367. | Criteria | Example | Description |
  368. |----------|---------|-------------|
  369. | `from` | `"sender@example.com"` | Emails from a specific sender |
  370. | `to` | `"recipient@example.com"` | Emails sent to a specific recipient |
  371. | `subject` | `"Meeting"` | Emails with specific text in subject |
  372. | `query` | `"has:attachment"` | Gmail search query syntax |
  373. | `negatedQuery` | `"spam"` | Text that must NOT be present |
  374. | `hasAttachment` | `true` | Emails with attachments |
  375. | `size` | `10485760` | Email size in bytes |
  376. | `sizeComparison` | `"larger"` | Size comparison (`larger`, `smaller`) |
  377. ### Filter Actions
  378. Filters can perform the following actions:
  379. | Action | Example | Description |
  380. |--------|---------|-------------|
  381. | `addLabelIds` | `["IMPORTANT", "Label_Work"]` | Add labels to matching emails |
  382. | `removeLabelIds` | `["INBOX", "UNREAD"]` | Remove labels from matching emails |
  383. | `forward` | `"backup@example.com"` | Forward emails to another address |
  384. ### Filter Templates
  385. The server includes pre-built templates for common filtering scenarios:
  386. #### 1. From Sender Template (`fromSender`)
  387. Filters emails from a specific sender and optionally archives them.
  388. ```json
  389. {
  390. "template": "fromSender",
  391. "parameters": {
  392. "senderEmail": "newsletter@company.com",
  393. "labelIds": ["Label_Newsletter"],
  394. "archive": true
  395. }
  396. }
  397. ```
  398. #### 2. Subject Filter Template (`withSubject`)
  399. Filters emails with specific subject text and optionally marks as read.
  400. ```json
  401. {
  402. "template": "withSubject",
  403. "parameters": {
  404. "subjectText": "[URGENT]",
  405. "labelIds": ["Label_Urgent"],
  406. "markAsRead": false
  407. }
  408. }
  409. ```
  410. #### 3. Attachment Filter Template (`withAttachments`)
  411. Filters all emails with attachments.
  412. ```json
  413. {
  414. "template": "withAttachments",
  415. "parameters": {
  416. "labelIds": ["Label_Attachments"]
  417. }
  418. }
  419. ```
  420. #### 4. Large Email Template (`largeEmails`)
  421. Filters emails larger than a specified size.
  422. ```json
  423. {
  424. "template": "largeEmails",
  425. "parameters": {
  426. "sizeInBytes": 10485760,
  427. "labelIds": ["Label_Large"]
  428. }
  429. }
  430. ```
  431. #### 5. Content Filter Template (`containingText`)
  432. Filters emails containing specific text and optionally marks as important.
  433. ```json
  434. {
  435. "template": "containingText",
  436. "parameters": {
  437. "searchText": "invoice",
  438. "labelIds": ["Label_Finance"],
  439. "markImportant": true
  440. }
  441. }
  442. ```
  443. #### 6. Mailing List Template (`mailingList`)
  444. Filters mailing list emails and optionally archives them.
  445. ```json
  446. {
  447. "template": "mailingList",
  448. "parameters": {
  449. "listIdentifier": "dev-team",
  450. "labelIds": ["Label_DevTeam"],
  451. "archive": true
  452. }
  453. }
  454. ```
  455. ### Common Filter Examples
  456. Here are some practical filter examples:
  457. **Auto-organize newsletters:**
  458. ```json
  459. {
  460. "criteria": {
  461. "from": "newsletter@company.com"
  462. },
  463. "action": {
  464. "addLabelIds": ["Label_Newsletter"],
  465. "removeLabelIds": ["INBOX"]
  466. }
  467. }
  468. ```
  469. **Handle promotional emails:**
  470. ```json
  471. {
  472. "criteria": {
  473. "query": "unsubscribe OR promotional"
  474. },
  475. "action": {
  476. "addLabelIds": ["Label_Promotions"],
  477. "removeLabelIds": ["INBOX", "UNREAD"]
  478. }
  479. }
  480. ```
  481. **Priority emails from boss:**
  482. ```json
  483. {
  484. "criteria": {
  485. "from": "boss@company.com"
  486. },
  487. "action": {
  488. "addLabelIds": ["IMPORTANT", "Label_Boss"]
  489. }
  490. }
  491. ```
  492. **Large attachments:**
  493. ```json
  494. {
  495. "criteria": {
  496. "size": 10485760,
  497. "sizeComparison": "larger",
  498. "hasAttachment": true
  499. },
  500. "action": {
  501. "addLabelIds": ["Label_LargeFiles"]
  502. }
  503. }
  504. ```
  505. ## Advanced Search Syntax
  506. The `search_emails` tool supports Gmail's powerful search operators:
  507. | Operator | Example | Description |
  508. |----------|---------|-------------|
  509. | `from:` | `from:john@example.com` | Emails from a specific sender |
  510. | `to:` | `to:mary@example.com` | Emails sent to a specific recipient |
  511. | `subject:` | `subject:"meeting notes"` | Emails with specific text in the subject |
  512. | `has:attachment` | `has:attachment` | Emails with attachments |
  513. | `after:` | `after:2024/01/01` | Emails received after a date |
  514. | `before:` | `before:2024/02/01` | Emails received before a date |
  515. | `is:` | `is:unread` | Emails with a specific state |
  516. | `label:` | `label:work` | Emails with a specific label |
  517. You can combine multiple operators: `from:john@example.com after:2024/01/01 has:attachment`
  518. ## Advanced Features
  519. ### **Email Attachment Support**
  520. The server provides comprehensive attachment functionality:
  521. - **Sending Attachments**: Include file paths in the `attachments` array when sending or drafting emails
  522. - **Attachment Detection**: Automatically detects MIME types and file sizes
  523. - **Download Capability**: Download any email attachment to your local filesystem
  524. - **Enhanced Display**: View detailed attachment information including filenames, types, sizes, and download IDs
  525. - **Multiple Formats**: Support for all common file types (documents, images, archives, etc.)
  526. - **RFC822 Compliance**: Uses Nodemailer for proper MIME message formatting
  527. **Supported File Types**: All standard file types including PDF, DOCX, XLSX, PPTX, images (PNG, JPG, GIF), archives (ZIP, RAR), and more.
  528. ### Email Content Extraction
  529. The server intelligently extracts email content from complex MIME structures:
  530. - Prioritizes plain text content when available
  531. - Falls back to HTML content if plain text is not available
  532. - Handles multi-part MIME messages with nested parts
  533. - **Processes attachments information (filename, type, size, download ID)**
  534. - Preserves original email headers (From, To, Subject, Date)
  535. ### International Character Support
  536. The server fully supports non-ASCII characters in email subjects and content, including:
  537. - Turkish, Chinese, Japanese, Korean, and other non-Latin alphabets
  538. - Special characters and symbols
  539. - Proper encoding ensures correct display in email clients
  540. ### Comprehensive Label Management
  541. The server provides a complete set of tools for managing Gmail labels:
  542. - **Create Labels**: Create new labels with customizable visibility settings
  543. - **Update Labels**: Rename labels or change their visibility settings
  544. - **Delete Labels**: Remove user-created labels (system labels are protected)
  545. - **Find or Create**: Get a label by name or automatically create it if not found
  546. - **List All Labels**: View all system and user labels with detailed information
  547. - **Label Visibility Options**: Control how labels appear in message and label lists
  548. Label visibility settings include:
  549. - `messageListVisibility`: Controls whether the label appears in the message list (`show` or `hide`)
  550. - `labelListVisibility`: Controls how the label appears in the label list (`labelShow`, `labelShowIfUnread`, or `labelHide`)
  551. These label management features enable sophisticated organization of emails directly through Claude, without needing to switch to the Gmail interface.
  552. ### Batch Operations
  553. The server includes efficient batch processing capabilities:
  554. - Process up to 50 emails at once (configurable batch size)
  555. - Automatic chunking of large email sets to avoid API limits
  556. - Detailed success/failure reporting for each operation
  557. - Graceful error handling with individual retries
  558. - Perfect for bulk inbox management and organization tasks
  559. ## Security Notes
  560. - OAuth credentials are stored securely in your local environment (`~/.gmail-mcp/`)
  561. - The server uses offline access to maintain persistent authentication
  562. - Never share or commit your credentials to version control
  563. - Regularly review and revoke unused access in your Google Account settings
  564. - Credentials are stored globally but are only accessible by the current user
  565. - **Attachment files are processed locally and never stored permanently by the server**
  566. ## Troubleshooting
  567. 1. **OAuth Keys Not Found**
  568. - Make sure `gcp-oauth.keys.json` is in either your current directory or `~/.gmail-mcp/`
  569. - Check file permissions
  570. 2. **Invalid Credentials Format**
  571. - Ensure your OAuth keys file contains either `web` or `installed` credentials
  572. - For web applications, verify the redirect URI is correctly configured
  573. 3. **Port Already in Use**
  574. - If port 3000 is already in use, please free it up before running authentication
  575. - You can find and stop the process using that port
  576. 4. **Batch Operation Failures**
  577. - If batch operations fail, they automatically retry individual items
  578. - Check the detailed error messages for specific failures
  579. - Consider reducing the batch size if you encounter rate limiting
  580. 5. **Attachment Issues**
  581. - **File Not Found**: Ensure attachment file paths are correct and accessible
  582. - **Permission Errors**: Check that the server has read access to attachment files
  583. - **Size Limits**: Gmail has a 25MB attachment size limit per email
  584. - **Download Failures**: Verify you have write permissions to the download directory
  585. ## Contributing
  586. Contributions are welcome! Please feel free to submit a Pull Request.
  587. ## Running evals
  588. The evals package loads an mcp client that then runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command. Full documentation can be found [here](https://www.mcpevals.io/docs).
  589. ```bash
  590. OPENAI_API_KEY=your-key npx mcp-eval src/evals/evals.ts src/index.ts
  591. ```
  592. ## License
  593. MIT
  594. ## Support
  595. If you encounter any issues or have questions, please file an issue on the GitHub repository.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.