Gmail MCP server built with FastMCP

Gmail MCP server built with FastMCP

gmail-mcp-server-gkdivya•bygkdivya

An MCP server that exposes Gmail email operations as tools through FastMCP, using Google OAuth 2.0 and the Gmail API for authentication and email management.

License: Not specified•Runtime: Awaiting documentation review•Category: communication social

WHAT IT DOES

  • •Exposes Gmail operations as MCP tools, including sending, reading, trashing, opening, and marking emails as read.
  • •Handles Gmail API authentication, token management, and refreshing.
  • •Includes prompts for email drafting and management.
  • •Parses and decodes MIME messages, including multipart messages and attachments.

BEST FOR

  • •AI assistants that need to send, read, and manage Gmail messages through MCP tools.
  • •Natural language email management using the included Gemini-powered smart client.

ABOUT GMAIL-MCP-SERVER-GKDIVYA

Gmail MCP server built with FastMCP is cataloged as an MCP server attributed to gkdivya. An MCP server that exposes Gmail email operations as tools through FastMCP, using Google OAuth 2.0 and the Gmail API for authentication and email management. 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: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

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 built with FastMCP 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 tools does the Gmail server expose?

It exposes send_email, get_unread_emails, read_email, trash_email, open_email, and mark_email_as_read.

How does the server authenticate with Gmail?

It uses Google's OAuth 2.0 and requires credentials.json and a generated token.json.

Upstream README

View this exact version on GitHub

README.md · d349620aa906 · Fetched 2026-11-13 12:15:06 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

Gmail MCP Server

A Gmail integration with FastMCP (Model Control Protocol) that enables AI assistants to interact with Gmail through a set of tools and prompts.

Overview

This project provides a server-client architecture that allows AI assistants to perform Gmail operations such as:

  • Sending emails
  • Reading unread emails
  • Viewing email content
  • Moving emails to trash
  • Opening emails in browser
  • Marking emails as read

The system uses Google's OAuth 2.0 for authentication and the Gmail API for email operations. It now includes an LLM-powered client that understands natural language requests.

Components

1. Gmail Server (gmail_server.py)

The core server that provides MCP tools for Gmail operations:

  • FastMCP Integration: Uses the FastMCP framework to expose Gmail operations as tools
  • OAuth Authentication: Handles Gmail API authentication, token management and refreshing
  • Email Operations: Implements email sending, reading, and management functionality
  • Prompts: Includes special prompts for email drafting and management

2. Smart Gmail Client (test_gmail_server.py)

A natural language interface to the Gmail server:

  • LLM Integration: Uses Google's Generative AI (Gemini) to interpret user requests
  • Natural Language Understanding: Converts plain English requests into tool calls
  • Parameter Extraction: Automatically extracts required parameters from user queries
  • Interactive Interface: Provides a conversational experience for managing emails
  • Comprehensive Logging: Includes detailed logging for debugging communication

Setup and Requirements

Prerequisites

  • Python 3.6+
  • Gmail API credentials (for authentication with Gmail)
  • Google Generative AI API key (for the LLM-powered client)
  • Packages from requirements.txt:
    google-auth>=2.22.0
    google-auth-oauthlib>=1.0.0
    google-api-python-client>=2.95.0
    fastmcp>=0.1.0
    typing-extensions>=4.5.0
    google-generativeai>=0.1.0
    python-dotenv>=0.19.0
    

Initial Setup After Cloning

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Set up Gmail API credentials:

    • Go to the Google Cloud Console
    • Create a new project or select an existing one
    • Enable the Gmail API for your project
    • Create OAuth 2.0 credentials (Desktop client type)
    • Download the credentials JSON file
    • Rename it to credentials.json and place it in the project root
  3. Set up Gemini API Key:

    • Go to Google AI Studio
    • Create a new API key
    • Create a .env file based on the example.env template:
      cp example.env .env
      
    • Add your Gemini API key to the .env file:
      GOOGLE_API_KEY=your_api_key_here
      
  4. First run will generate token:

    • The first time you run the Gmail server, it will open a browser window
    • Log in to your Google account and grant the requested permissions
    • This will generate a token.json file for future authentication

Authentication Files

The system requires several authentication files:

  • credentials.json: OAuth client ID credentials from Google Cloud Console for Gmail API
  • token.json: Generated token file for authenticated access to Gmail
  • .env: Environment variables file containing your Google Generative AI API key

Usage

Starting the Gmail Server

Start the Gmail server:

python gmail_server.py --creds credentials.json --token token.json

The server exposes the following tools:

  • send_email: Send emails with recipient, subject, and message
  • get_unread_emails: Retrieve unread messages
  • read_email: Get contents of specific emails
  • trash_email: Move emails to trash
  • open_email: Open emails in browser
  • mark_email_as_read: Mark emails as read

Using the Smart Gmail Client

The smart client allows you to interact with Gmail using natural language:

python test_gmail_server.py

Example Commands:

  • "Send an email to [recipient] about [topic]"
  • "Check my unread emails"
  • "Read my most recent message"
  • "Open the latest email in browser"
  • "Move an email from [sender] to trash"
  • "Mark my unread emails as read"

The client will:

  1. Process your request using the LLM
  2. Determine which Gmail operation you want to perform
  3. Extract necessary parameters from your request
  4. Request any missing information
  5. Confirm sensitive operations before executing them
  6. Execute the operation and show you the results

Implementation Details

Email Content Handling

  • Supports parsing and decoding MIME messages
  • Handles multipart messages and attachments
  • Properly decodes email headers

LLM Integration

  • Uses Gemini 1.5 Flash for natural language understanding
  • Converts LLM responses to structured tool calls
  • Includes fallback mechanisms for handling malformed LLM responses
  • Handles parameter extraction from free-form text

Error Handling

  • Comprehensive logging throughout the application
  • Graceful handling of HTTP errors from Gmail API
  • Fallback mechanisms when the LLM response isn't formatted as expected
  • Clear error responses for client applications

Development

Extending the Smart Client

To add support for new Gmail operations:

  1. Add the appropriate tool implementation in gmail_server.py
  2. The smart client will automatically discover and expose the new tools
  3. The LLM will learn to understand requests for the new operations from the tool descriptions

Customizing LLM Integration

You can modify the LLM prompt in test_gmail_server.py to:

  • Improve parameter extraction for specific use cases
  • Add specialized handling for particular types of requests
  • Tune the system for your specific Gmail usage patterns

Security Note

This repository does not include credential files. Never commit your:

  • credentials.json file
  • token.json file
  • .env file with API keys

These files are included in the .gitignore file to prevent accidental commits of sensitive information.

Reference

https://medium.com/@jason.summer/create-a-gmail-agent-with-model-context-protocol-mcp-061059c07777

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 built with FastMCP 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/gmail-mcp-server-gkdivya)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

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

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

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