Skip to main content
Glama

Gmail MCP Server

A Model Context Protocol (MCP) server that provides Gmail access for Claude Code and other MCP clients. Built with FastMCP.

Features

  • list_unread - List unread emails from inbox

  • search - Search emails using Gmail query syntax

  • archive - Archive emails (removes from inbox)

  • mark_as_read - Mark emails as read without archiving

  • get_labels - Get all Gmail labels

Related MCP server: Gmail MCP Server

Installation

No local installation required! Run directly from GitHub using uvx:

uvx --from git+https://github.com/fred-drake/gmail-mcp gmail-mcp

Setup

1. Create Google Cloud OAuth Credentials

  1. Go to Google Cloud Console

  2. Create a new project or select an existing one:

    • Click the project dropdown at the top of the page

    • Click "New Project", give it a name, and create it

    • Make sure your new project is selected

  3. Enable the Gmail API:

    • Navigate to "APIs & Services" > "Library"

    • Search for "Gmail API" and click on it

    • Click "Enable"

  4. Configure the OAuth consent screen (required before creating credentials):

    • Go to "APIs & Services" > "OAuth consent screen"

    • Select "External" as the user type and click "Create"

    • Fill in the required fields:

      • App name: Choose any name (e.g., "Gmail MCP")

      • User support email: Select your email

      • Developer contact email: Enter your email

    • Click "Save and Continue"

    • On the "Scopes" page, click "Save and Continue" (no changes needed)

    • On the "Test users" page:

      • Click "Add Users"

      • Enter the Gmail address you want to access (this is critical!)

      • Click "Add" then "Save and Continue"

    • Click "Back to Dashboard"

  5. Create OAuth credentials:

    • Go to "APIs & Services" > "Credentials"

    • Click "Create Credentials" > "OAuth client ID"

    • Choose "Desktop app" as the application type

    • Give it a name (e.g., "Gmail MCP Desktop")

    • Click "Create"

    • Click "Download JSON" to save the credentials file

    • Store this file securely - you'll need the path for configuration

2. Set Environment Variables

Set the path to your OAuth credentials file:

export GMAIL_MCP_CREDENTIALS_PATH="/path/to/your/credentials.json"

Optionally, customize the token cache location (default: ~/.config/gmail-mcp/token.json):

export GMAIL_MCP_TOKEN_PATH="/custom/path/token.json"

3. Run OAuth Setup

Run the interactive setup to authenticate:

uvx --from git+https://github.com/fred-drake/gmail-mcp gmail-mcp --setup

This will open a browser window for Google OAuth authentication. After authorizing, the token will be cached for future use.

MCP Client Configuration

Claude Code

Add to your Claude Code MCP settings:

{
  "mcpServers": {
    "gmail": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/fred-drake/gmail-mcp", "gmail-mcp"],
      "env": {
        "GMAIL_MCP_CREDENTIALS_PATH": "/path/to/your/credentials.json"
      }
    }
  }
}

With Custom Token Path

{
  "mcpServers": {
    "gmail": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/fred-drake/gmail-mcp", "gmail-mcp"],
      "env": {
        "GMAIL_MCP_CREDENTIALS_PATH": "/path/to/your/credentials.json",
        "GMAIL_MCP_TOKEN_PATH": "/custom/path/token.json"
      }
    }
  }
}

Environment Variables

Variable

Required

Default

Description

GMAIL_MCP_CREDENTIALS_PATH

Yes

-

Path to OAuth credentials JSON

GMAIL_MCP_TOKEN_PATH

No

~/.config/gmail-mcp/token.json

Path to token cache file

Tool Reference

list_unread

List unread emails from inbox.

Parameters:

  • max_results (int, optional): Maximum emails to return (1-100). Default: 20.

Returns: List of email objects with id, from, subject, date, snippet, labels, body_preview.

Search emails using Gmail query syntax.

Parameters:

  • query (str): Gmail search query (e.g., "from:user@example.com is:unread")

  • max_results (int, optional): Maximum results (1-100). Default: 20.

Returns: List of matching email objects.

Example queries:

  • from:notifications@github.com - Emails from GitHub

  • is:unread newer_than:1d - Unread emails from last 24 hours

  • subject:invoice - Emails with "invoice" in subject

  • has:attachment larger:5M - Emails with attachments over 5MB

archive

Archive emails by removing INBOX and UNREAD labels.

Parameters:

  • message_ids (list[str]): List of message IDs to archive.

Returns: Dict with archived_count, failed_count, and details.

mark_as_read

Mark emails as read without archiving.

Parameters:

  • message_ids (list[str]): List of message IDs to mark as read.

Returns: Dict with marked_count, failed_count, and details.

get_labels

Get all Gmail labels for the authenticated user.

Returns: List of label objects with id, name, type, and message counts.

Development

Prerequisites

  • Python 3.13+

  • Nix (optional, for reproducible environment)

Setup with Nix

cd gmail-mcp
nix develop

Setup with pip

cd gmail-mcp
pip install -e ".[dev]"

Running Tests

pytest

Linting

ruff check .
ruff format .

License

MIT

Available Tools

5 tools
archiveA

Archive emails by removing INBOX and UNREAD labels.

Args: message_ids: List of message IDs to archive.

Returns: Dict with archived_count, failed_count, and details.

ParametersJSON Schema
NameRequiredDescriptionDefault
message_idsYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses the mechanism (label removal) and return structure (archived_count, failed_count), but omits safety/reversibility details, rate limits, or partial failure behavior beyond the return keys.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Docstring-style Args/Returns format is slightly redundant with structured schema fields, but efficient given the lack of schema descriptions. No wasted prose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter mutation tool, the description adequately covers the parameter, operation semantics, and return structure. Missing only edge-case handling details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% (no property descriptions), but the Args section compensates by documenting message_ids as 'List of message IDs to archive,' clarifying the expected input format.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description defines 'archive' concretely as 'removing INBOX and UNREAD labels,' avoiding tautology. It distinguishes from sibling mark_as_read by specifying both labels are removed (inbox removal is the key differentiator).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to choose this over mark_as_read (which likely only removes UNREAD) or delete. No mention of typical use cases like 'inbox zero' workflows or that archived emails remain searchable via search.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_labelsB

Get all Gmail labels for the authenticated user.

Returns: List of label objects with id, name, type, and message counts.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Lacks annotations, so the description carries full disclosure burden. It clarifies scope ('all Gmail labels', 'authenticated user') but omits safety confirmation (read-only nature), rate limits, or whether system labels are included. The return value description is redundant since output schema exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded action sentence followed by return description. Efficient structure with minimal waste, though the Returns sentence adds limited value given the existence of an output schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a simple read operation with no parameters and existing output schema. Covers the essential operation scope, though additional context on label types (system vs. user) would improve completeness given zero annotation coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema contains zero parameters. Per rubric, baseline score is 4 for zero-parameter tools. The description implicitly confirms no filtering is possible ('all Gmail labels'), which aligns with the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Provides specific verb (Get), resource (Gmail labels), and scope (all labels for authenticated user). However, it does not explicitly differentiate from sibling tools like 'search' or 'list_unread' that might also interact with labels in different contexts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Offers no guidance on when to invoke this tool versus siblings like 'search' or 'list_unread', nor does it mention prerequisites such as requiring OAuth scopes or when label data is needed for subsequent operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_unreadB

List unread emails from inbox.

Args: max_results: Maximum number of emails to return (1-100). Default: 20.

Returns: List of email objects with id, from, subject, date, snippet, labels, body_preview.

ParametersJSON Schema
NameRequiredDescriptionDefault
max_resultsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full disclosure burden. It successfully documents the return structure (email object fields) and parameter constraints (1-100 range). However, lacks safety context (auth requirements, rate limits) and behavior on empty inbox.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Uses docstring format with Args/Returns sections. First sentence is strong and front-loaded. Returns section may be redundant if rich output schema exists, but structure is logical and information density is high with minimal waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a single-parameter list operation. Describes the parameter fully and outlines return fields. Lacks completeness on behavioral edge cases and sibling differentiation, which would elevate it for an email tool with multiple query options.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% (max_results lacks description), but description fully compensates by documenting the parameter semantics, valid range (1-100), and default value (20).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States specific verb (List) + resource (unread emails) + scope (from inbox). Clearly implies read-only operation distinct from mutation siblings like 'archive' and 'mark_as_read', though it doesn't explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides no explicit guidance on when to use this versus the 'search' sibling, which could also retrieve unread emails. No preconditions or filtering guidance provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

mark_as_readA

Mark emails as read without archiving.

Args: message_ids: List of message IDs to mark as read.

Returns: Dict with marked_count, failed_count, and details.

ParametersJSON Schema
NameRequiredDescriptionDefault
message_idsYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It partially satisfies this by documenting the return structure (marked_count, failed_count, details) in the Returns section, revealing idempotency hints (failed_count suggests partial success handling). However, it omits mutation semantics (permissions required, thread vs individual message behavior) that would be critical for a write operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Uses a clean docstring structure with Args and Returns sections. Every sentence earns its place: the first line establishes the core operation and sibling distinction, Args documents the single parameter, and Returns documents the output structure. No redundancy or boilerplate.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter tool with zero schema coverage, the description adequately fills gaps by documenting the parameter (Args) and return values (Returns). Given the output schema exists (per context signals), the Returns section may be partially redundant, but still provides semantic field descriptions. Completeness is appropriate for the tool's simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, requiring the description to compensate. The Args section successfully defines 'message_ids' as 'List of message IDs to mark as read', adding essential semantic context (the IDs represent messages) and purpose (to mark as read) that the bare JSON schema lacks. It loses a point for not specifying ID format or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening line 'Mark emails as read without archiving' provides a specific verb (Mark), resource (emails), and target state (as read). Crucially, it explicitly distinguishes itself from the 'archive' sibling tool by stating the negative constraint 'without archiving', preventing confusion between the two mutation operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'without archiving' implicitly provides usage guidance by contrasting with the sibling 'archive' tool, indicating when to use this (when you want to keep the email in the inbox but mark it read). While it lacks exhaustive when-to-use logic for all siblings (like search vs mark), it successfully handles the most critical adjacent alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.7/5.0
Disambiguation5/5

Each tool has a distinct and clear purpose: archive emails, get labels, list unread emails, mark emails as read, and search emails. There is no overlap in functionality, making it easy for an agent to select the correct tool without confusion.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (e.g., archive, get_labels, list_unread, mark_as_read, search). The naming is straightforward and predictable, enhancing usability and clarity.

Tool Count4/5

With 5 tools, the server is well-scoped for basic Gmail operations, covering key actions like reading, archiving, and searching emails. However, it lacks some advanced features like sending or deleting emails, which slightly limits its completeness but keeps the count reasonable.

Completeness3/5

The tool set covers essential read and modify operations (list, search, mark as read, archive) and label management, but it has notable gaps: there are no tools for sending emails, deleting emails, or managing drafts. This could lead to agent failures for common email workflows like composing or removing messages.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables interaction with Gmail through MCP-compatible clients to list, read, search, and send emails. It supports advanced features such as managing labels, handling threaded replies, and utilizing Gmail's native search syntax.
    49
    2
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with Gmail through the MCP protocol, supporting sending, reading, searching, replying, forwarding, managing drafts and labels, and saving attachments.
    15
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables Gmail operations such as reading, sending, searching, and managing emails, threads, labels, and drafts via MCP tools.
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables Gmail operations like listing, searching, sending emails, and managing labels via MCP tools.
    15
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fred-drake/gmail-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server