DS

david-strejc/gmail-mcp-server

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

11 stars 9 forks 품질 67 트렌드 18BSD-3-Clause

MCP Server for interacting with Gmail via IMAP and SMTP

개요

This project implements a Model Context Protocol (MCP) server that allows interaction with Gmail accounts via IMAP and SMTP. It provides tools for searching emails, retrieving content, managing labels (creating, deleting, renaming, applying, removing), and sending/forwarding emails. * Search emails by date range, keyword, or raw Gmail query string. Supports searching specific folders (inbox, sent) and limiting results. Uses Gmail's X-GM-RAW extension for efficient inbox searching (e.g., filtering by category:primary). * Fetch the full content (headers, body, attachments) of a specific email using its sequence ID. * * List all available Gmail labels (folders). * Create new custom labels. * Rename existing custom labels. * Delete existing custom labels (cannot delete system labels). * Apply labels to individual emails. * Remove labels from individual emails. * * Apply labels to multiple emails simultaneously using sequence IDs. * Remove labels from multiple emails simultaneously.

README

원문 README의 일부입니다. 원문 보기.

Gmail MCP Server

This project implements a Model Context Protocol (MCP) server that allows interaction with Gmail accounts via IMAP and SMTP. It provides tools for searching emails, retrieving content, managing labels (creating, deleting, renaming, applying, removing), and sending/forwarding emails.

Features

  • Email Search: Search emails by date range, keyword, or raw Gmail query string. Supports searching specific folders (inbox, sent) and limiting results. Uses Gmail’s X-GM-RAW extension for efficient inbox searching (e.g., filtering by category:primary).
  • Email Content Retrieval: Fetch the full content (headers, body, attachments) of a specific email using its sequence ID.
  • Label Management (CRUD):
    • List all available Gmail labels (folders).
    • Create new custom labels.
    • Rename existing custom labels.
    • Delete existing custom labels (cannot delete system labels).
    • Apply labels to individual emails.
    • Remove labels from individual emails.
  • Batch Operations:
    • Apply labels to multiple emails simultaneously using sequence IDs.
    • Remove labels from multiple emails simultaneously.
    • Move multiple emails to a specific label/folder.
  • Email Sending: Send new emails (requires SMTP configuration).
  • Email Forwarding: Forward existing emails, including attachments (requires SMTP configuration).
  • Daily Email Count: Count emails received per day within a specified date range.

Project Structure

.
├── .gitignore         # Specifies intentionally untracked files that Git should ignore
├── .python-version    # Specifies Python version (used by pyenv)
├── LICENSE            # Project license file
├── pyproject.toml     # Python project configuration (dependencies, build system)
├── README.md          # This file
├── task_list.md       # Tracks development progress
├── uv.lock            # Lock file for uv package manager
├── src/
│   └── email_client/
│       ├── __init__.py
│       ├── config.py        # Handles loading configuration from environment variables (.env)
│       ├── handlers.py      # Implements the logic for handling MCP tool calls
│       ├── imap_client.py   # Contains functions for interacting with IMAP server
│       ├── server.py        # Main MCP server script using @modelcontextprotocol/sdk
│       ├── smtp_client.py   # Contains functions for interacting with SMTP server
│       ├── tool_definitions.py # Defines the available MCP tools and their schemas
│       └── utils.py         # Utility functions (e.g., email parsing, date formatting)
└── ... (other potential files like test scripts, helper scripts)

Setup

  1. Clone the repository (if applicable):

    git clone https://github.com/david-strejc/gmail-mcp-server.git
    cd gmail-mcp-server
    
  2. Install Dependencies: This project uses uv for package management.

    # Ensure uv is installed (e.g., pip install uv)
GitHub에서 전체 README 보기

설치

This server does not publish a one-line install command.

Open the repository installation guide MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →

설정

{ "mcpServers": { "gmail": { "command": "/path/to/your/project/gmail-mcp-server/.venv/bin/python", "args": ["/path/to/your/project/gmail-mcp-server/src/email_client/server.py"], "env": {}, // Environment variables are loaded from .env by the script "enabled": true, // Set to true to enable "autoApprove": [] // Configure auto-approval if desired } // ... other servers } }