Gmail MCP Server

Gmail MCP Server

mcp-gmail-server•bygemacjr

A Java MCP server that connects to Gmail and exposes tools for searching emails by query and reading full email content over Stdio.

License: MIT License•Runtime: Awaiting documentation review•Category: communication social

WHAT IT DOES

  • •Searches Gmail emails by topic, sender, or date using Gmail query syntax.
  • •Reads full email content including subject, sender, and body by message ID.
  • •Communicates with Claude Desktop via Stdio and JSON-RPC 2.0.
  • •Authenticates via OAuth2 with the gmail.readonly scope and persists tokens locally.

BEST FOR

  • •Querying and summarizing emails about specific topics or deadlines through natural language in Claude Desktop.
  • •Finding emails from a particular sender about a subject.
  • •Opening and reading a specific email by its ID.

ABOUT MCP-GMAIL-SERVER

Gmail MCP Server is cataloged as an MCP server attributed to gemacjr. A Java MCP server that connects to Gmail and exposes tools for searching emails by query and reading full email content over Stdio. It is categorized under communication social. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Gmail MCP Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

What Gmail permissions does the server request?

It uses the gmail.readonly scope, providing read-only access to Gmail.

How many search results does a search return?

Search results are limited to 10 emails to respect Gmail API rate limits.

How does the server communicate with Claude Desktop?

It runs in Stdio mode using JSON-RPC 2.0 to respond to MCP requests.

上游原版 README

在 GitHub 查看同一版本原文

README.md · bbc3ae053b9d · 采集于 2026-11-13 12:15:27 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Gmail MCP Server

A Java-based Model Context Protocol (MCP) server that integrates with Gmail to enable natural language email queries via Claude Desktop. The server exposes tools to search emails by topic (e.g., "project deadlines") and read email content, using the Gmail API with secure OAuth2 authentication.

Features

  • Search Emails: Find emails by topic, sender, or date using Gmail's query syntax (e.g., from:alice budget).
  • Read Emails: Retrieve full email content (subject, sender, body) by ID.
  • Secure Authentication: Uses OAuth2 with gmail.readonly scope for minimal access.
  • MCP Integration: Communicates with Claude Desktop via Stdio using JSON-RPC 2.0.
  • Robust Design: Includes error handling, logging, and input validation for production readiness.

Prerequisites

  • Java 17: Ensure JDK 17 is installed (java --version).
  • Maven: For dependency management (mvn --version).
  • Google Cloud Project: With Gmail API enabled and OAuth2 credentials.
  • Claude Desktop: Installed and configured for MCP (available from Anthropic).
  • Operating System: Tested on Windows, macOS, and Linux.

Setup Instructions

1. Create Google Cloud Credentials

  1. Go to the Google Cloud Console.
  2. Create a new project (e.g., "Gmail MCP Server").
  3. Enable the Gmail API:
    • Navigate to APIs & Services > Library.
    • Search for "Gmail API" and click Enable.
  4. Create OAuth 2.0 credentials:
    • Go to APIs & Services > Credentials > Create Credentials > OAuth 2.0 Client IDs.
    • Select Desktop app as the application type.
    • Name the client (e.g., "Gmail MCP Client").
    • Download the credentials.json file.
  5. Add http://localhost to authorized redirect URIs:
    • In Credentials, edit the OAuth 2.0 Client ID and add http://localhost under Authorized redirect URIs.

2. Clone or Set Up the Project

  1. Clone the repository (or create a new Maven project):
    git clone <repository-url>
    cd gmail-mcp-server
    
    Alternatively, create a new Maven project and copy the provided files:
    • src/main/java/com/swiftbeard/gmailmcp/GmailMcpServer.java
    • pom.xml
    • src/main/resources/credentials.json (from Google Cloud)
    • src/main/resources/logback.xml
  2. Place credentials.json in src/main/resources/.
  3. Verify the project structure:
    gmail-mcp-server/
    ├── pom.xml
    ├── src/
    │   ├── main/
    │   │   ├── java/
    │   │   │   └── com/swiftbeard/gmailmcp/
    │   │   │       └── GmailMcpServer.java
    │   │   ├── resources/
    │   │   │   ├── credentials.json
    │   │   │   └── logback.xml
    

3. Build the Project

  1. Install dependencies and build the project:
    mvn clean install
    
  2. The build will generate a shaded JAR: target/gmail-mcp-server-1.0-SNAPSHOT.jar.

4. Run the Server

  1. Start the server:
    java -jar target/gmail-mcp-server-1.0-SNAPSHOT.jar
    
  2. On first run, the server opens a browser for OAuth2 authentication:
    • Log in with your Gmail account.
    • Grant permission for the app to read emails (uses gmail.readonly scope).
    • Tokens are saved to ~/.gmail-mcp/tokens for subsequent runs.
  3. The server runs in Stdio mode, waiting for MCP requests from Claude Desktop.

5. Configure Claude Desktop

  1. Install Claude Desktop from Anthropic’s website.
  2. Locate or create the MCP configuration file (e.g., ~/.cursor/mcp.json or Claude’s settings file).
  3. Add the Gmail MCP server configuration:
    {
      "mcpServers": {
        "gmail": {
          "command": "java",
          "args": ["-jar", "/full/path/to/gmail-mcp-server-1.0-SNAPSHOT.jar"]
        }
      }
    }
    
    Replace /full/path/to/gmail-mcp-server-1.0-SNAPSHOT.jar with the absolute path to your JAR file (e.g., /home/user/gmail-mcp-server/target/gmail-mcp-server-1.0-SNAPSHOT.jar).
  4. Save the file and restart Claude Desktop.

6. Test the Integration

  1. Open Claude Desktop.
  2. Enter a natural language query, such as:
    Find emails about project deadlines from the last 30 days.
    
  3. Claude translates this to a searchEmails tool call (e.g., query: "project deadlines after:2025-03-26"). The server returns a list of emails:
    [
      {"id": "abc123", "subject": "Project Deadlines Update", "snippet": "Please review the June 1 deadline..."},
      {"id": "def456", "subject": "Q2 Deadlines", "snippet": "Deadlines for Project X..."}
    ]
    
  4. Follow up with:
    Read the email with ID abc123.
    
  5. The server executes readEmail("abc123") and returns:
    {
      "id": "abc123",
      "subject": "Project Deadlines Update",
      "from": "jane.doe@example.com",
      "body": "Hi team, please review the June 1 deadline for Project X..."
    }
    
  6. Claude summarizes the results in natural language.

Usage Examples

  • Search by Topic:
    Show me emails about budget approvals from last month.
    
    Maps to: searchEmails("budget approvals after:2025-03-01 before:2025-04-01").
  • Search by Sender:
    Find emails from alice@example.com about conference planning.
    
    Maps to: searchEmails("from:alice@example.com conference planning").
  • Read Specific Email:
    Read the email with ID xyz123.
    
    Maps to: readEmail("xyz123").

Best Practices

  • Security:
    • Uses minimal gmail.readonly scope to limit access.
    • Stores OAuth2 tokens securely in ~/.gmail-mcp/tokens (excluded from version control).
    • Validates inputs to prevent injection attacks.
  • Error Handling:
    • Returns JSON-RPC error responses for invalid requests or API failures.
    • Logs errors with SLF4J/Logback for debugging.
  • Performance:
    • Limits search results to 10 emails to respect Gmail API rate limits (250 queries/minute).
    • Uses efficient JSON parsing with Jackson.
  • Maintainability:
    • Modular code with separated Gmail and MCP logic.
    • Comprehensive logging for monitoring.

Troubleshooting

  • Authentication Errors:
    • Ensure credentials.json is in src/main/resources/.
    • Delete ~/.gmail-mcp/tokens and re-authenticate if tokens are invalid.
  • Server Not Responding:
    • Verify the JAR path in mcp.json is correct.
    • Check logs in the console for errors.
  • Claude Desktop Issues:
    • Ensure Claude Desktop is updated to the latest version.
    • Confirm the MCP configuration file is correctly formatted.
  • Gmail API Rate Limits:
    • If you hit rate limits, reduce query frequency or implement exponential backoff.

Security Considerations

  • Credentials: Add credentials.json and ~/.gmail-mcp/tokens to .gitignore to prevent accidental commits.
  • OAuth2: Uses offline access type for persistent tokens; review Google Cloud Console for unusual activity.
  • Scope: Limited to gmail.readonly to prevent unauthorized actions.

Extending the Server

  • Add Tools: Extend GmailMcpServer.java to include tools like labelEmail or sendEmail (requires additional scopes).
  • Remote Hosting: Modify to use SSE or WebSockets for cloud deployment (e.g., with Spring WebFlux).
  • Caching: Implement caching for frequently searched queries using an in-memory store like Caffeine.

Contributing

Contributions are welcome! Please:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/xyz).
  3. Commit changes (git commit -m "Add XYZ feature").
  4. Push to the branch (git push origin feature/xyz).
  5. Open a pull request.

License

MIT License. See LICENSE for details.

Acknowledgments

For issues or questions, open a GitHub issue or contact the maintainer.

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Gmail MCP Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-gmail-server)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related communication social MCP Servers

Alternative and complementary servers in the same category

View all in communication social →

An AI receptionist platform with an MCP server for accessing business calls, contacts and appointments from AI assistants.

52
Communication

Pidgeon provides an MCP server and an email inbox API that gives AI agents their own addresses for sending, awaiting, and replying to email.

Repository stats unavailable
Communication