MCP cover image
See in Github
2024-12-02

镜像://github.com/ajbr0wn/gmail-mcp-server

0

Github Watches

1

Github Forks

0

Github Stars

Gmail MCP Server

An MCP (Model Context Protocol) server that provides Gmail integration capabilities to MCP clients like Claude Desktop.

Features

  • View recent emails from your Gmail inbox
  • Search emails using Gmail's search syntax
  • Secure OAuth2 authentication with Gmail API

Setup

1. Google Cloud Project Setup

  1. Create a Google Cloud Project at https://console.cloud.google.com/
  2. Enable the Gmail API
  3. Create OAuth 2.0 credentials:
    • Application type: Desktop application
    • Download the credentials as credentials.json

2. Installation

# Create a conda environment
conda create -n mcp-gmail python=3.12
conda activate mcp-gmail

# Install the package
cd gmail-mcp-server
pip install -e .

3. Configuration for Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "gmail": {
      "command": "/path/to/conda/envs/mcp-gmail/bin/python",
      "args": ["-m", "gmail_mcp_server.server"],
      "env": {
        "PYTHONPATH": "/path/to/gmail-mcp-server/src",
        "GMAIL_CREDENTIALS_FILE": "/path/to/credentials.json",
        "GMAIL_TOKEN_FILE": "/path/to/token.json"
      }
    }
  }
}

Replace /path/to/ with your actual paths. The token file will be created automatically when you first authenticate.

4. First Run

When you first try to access Gmail through Claude, you'll be prompted to authorize the application in your browser. After authorization, your credentials will be saved to the token file for future use.

Available Resources

  • gmail://inbox/recent - Returns your 10 most recent emails

Available Tools

  • search_emails
    • Description: Search Gmail emails with a query
    • Parameters:
      • query (required): Gmail search query (uses Gmail's standard search syntax)
      • max_results (optional): Maximum number of results to return (default: 10)

Example search:

Could you show me any emails from sanrio in the last two days?

Security

This server requires OAuth2 authentication with Gmail:

  • You'll be prompted to authorize access in your browser on first use
  • Credentials are stored locally in the specified token file
  • Access can be revoked at any time through your Google Account settings
  • Only read access to Gmail is requested (no write permissions)

Environment Variables

  • GMAIL_CREDENTIALS_FILE (required): Path to your Google OAuth credentials file
  • GMAIL_TOKEN_FILE (required): Path where the authentication token will be saved

For testing, you can run the server directly:

GMAIL_CREDENTIALS_FILE="/path/to/credentials.json" \
GMAIL_TOKEN_FILE="/path/to/token.json" \
python -m gmail_mcp_server.server

Development

The server uses the Model Context Protocol to provide:

  • Resource access to recent emails
  • Tool support for email search
  • Secure OAuth2 authentication flow
  • Automatic token refresh

Logging

The server logs detailed information about its operations to stderr, including:

  • Server startup information
  • Authentication status
  • Resource and tool usage
  • Any errors or issues

Contributing

Pull requests are welcome! Please ensure to:

  • Update documentation for any new features
  • Add appropriate error handling
  • Test OAuth flow with new features
  • Follow existing code style

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Andris Teikmanis
  • Latvian GPT assistant for developing GPT applications

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Jan Meindl
  • Builds new GPTs

  • https://jgadvisorycpa.com
  • This GPT assists in finding a top-rated business CPA - local or virtual. We account for their qualifications, experience, testimonials and reviews. Business operators provide a short description of your business, services wanted, and city or state.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Contraband Interactive
  • Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.

  • rustassistant.com
  • Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • modelcontextprotocol
  • 模型上下文协议服务器

  • OffchainLabs
  • 进行以太坊的实施

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

    Reviews

    5 (1)
    Avatar
    user_obTqgGtL
    2025-04-16

    As a dedicated MCP application user, I find the ajbr0wn_gmail-mcp-server by MCP-Mirror to be incredibly reliable and efficient. This server enhances email management seamlessly. The code repository on GitHub is well-documented, and the support provided is exceptional. I highly recommend this product to anyone looking for a robust email control solution. Check it out here: https://github.com/MCP-Mirror/ajbr0wn_gmail-mcp-server.