Gmail MCP MCP Server

$cd gmail-mcp && uv sync && uv run python src/main.py
README.md

A Gmail MCP server using OAuth2 bearer token auth via Dedalus

gmail-mcp

A Gmail MCP server using OAuth2 bearer token auth via the Dedalus MCP framework.

Tools

Messages

  • gmail_list_messages - List messages with search queries
  • gmail_get_message - Get a specific message by ID
  • gmail_send_message - Send an email
  • gmail_trash_message - Move message to trash
  • gmail_untrash_message - Remove message from trash
  • gmail_modify_message - Add/remove labels on a message

Threads

  • gmail_list_threads - List email threads (conversations)
  • gmail_get_thread - Get a thread with all messages
  • gmail_trash_thread - Move thread to trash

Labels

  • gmail_list_labels - List all labels
  • gmail_get_label - Get label details
  • gmail_create_label - Create a new label
  • gmail_delete_label - Delete a user label

Drafts

  • gmail_list_drafts - List draft emails
  • gmail_get_draft - Get a draft by ID
  • gmail_create_draft - Create a draft
  • gmail_send_draft - Send a draft
  • gmail_delete_draft - Delete a draft

Profile

  • gmail_get_profile - Get user's Gmail profile

Authentication

Gmail API requires OAuth2. The access token is provided at runtime via Dedalus credential exchange.

Required OAuth scopes (depending on operations):

  • https://www.googleapis.com/auth/gmail.readonly - Read-only access
  • https://www.googleapis.com/auth/gmail.send - Send emails
  • https://www.googleapis.com/auth/gmail.modify - Modify messages/labels
  • https://www.googleapis.com/auth/gmail.compose - Create drafts

Usage

Prerequisites

  1. A Dedalus API key (dsk-live-* or dsk-test-*)
  2. The dedalus-labs Python SDK installed

Environment Variables

DEDALUS_API_KEY=dsk-live-your-key-here
DEDALUS_API_URL=https://api.dedaluslabs.ai
DEDALUS_AS_URL=https://as.dedaluslabs.ai

Example Client

See `src/_client.py` for a complete example client that handles the OAuth browser flow.

The first time you use the MCP server, you'll be prompted to authorize Gmail access via OAuth.

OAuth Flow

  1. On first request, you'll receive an AuthenticationError with a connect_url
  2. Open the URL in a browser to authorize Gmail access
  3. After authorization, retry the request - credentials are now stored
  4. Subsequent requests will work without re-authorization

Local Development

cd gmail-mcp
uv sync
uv run python src/main.py

API Reference

Tools (19)

gmail_list_messagesList messages with search queries
gmail_get_messageGet a specific message by ID
gmail_send_messageSend an email
gmail_trash_messageMove message to trash
gmail_untrash_messageRemove message from trash
gmail_modify_messageAdd/remove labels on a message
gmail_list_threadsList email threads (conversations)
gmail_get_threadGet a thread with all messages
gmail_trash_threadMove thread to trash
gmail_list_labelsList all labels
gmail_get_labelGet label details
gmail_create_labelCreate a new label
gmail_delete_labelDelete a user label
gmail_list_draftsList draft emails
gmail_get_draftGet a draft by ID
gmail_create_draftCreate a draft
gmail_send_draftSend a draft
gmail_delete_draftDelete a draft
gmail_get_profileGet user's Gmail profile

Environment Variables

DEDALUS_API_KEYrequiredDedalus API key (dsk-live-* or dsk-test-*)
DEDALUS_API_URLrequiredDedalus API endpoint URL
DEDALUS_AS_URLrequiredDedalus AS endpoint URL

Configuration

claude_desktop_config.json
{"mcpServers":{"gmail":{"command":"uv","args":["run","--project","/path/to/gmail-mcp","src/main.py"],"env":{"DEDALUS_API_KEY":"dsk-live-your-key-here","DEDALUS_API_URL":"https://api.dedaluslabs.ai","DEDALUS_AS_URL":"https://as.dedaluslabs.ai"}}}}

Try it

Search my Gmail for messages from 'GitHub' about recent pull requests.
Get the full conversation thread for the email with ID '12345'.
Send an email to example@test.com with the subject 'Meeting Update' and a brief summary of our last call.
List all my Gmail labels and create a new one called 'Project Alpha'.
Find my latest draft and send it.

Frequently Asked Questions

What are the key features of Gmail MCP?

Full message management including searching, retrieving, sending, and trashing emails.. Thread support to interact with entire email conversations.. Label management to list, create, delete, and modify labels on messages.. Draft support for creating, listing, sending, and deleting email drafts.. Secure OAuth2 authentication flow via Dedalus credential exchange..

What can I use Gmail MCP for?

Automating email triage by searching for specific keywords and applying labels.. Drafting and sending automated responses or updates directly from an AI assistant.. Retrieving context from past email threads to inform current tasks or projects.. Managing mailbox organization by programmatically trashing or untrashing messages.. Checking user profile information and mailbox status via the Gmail API..

How do I install Gmail MCP?

Install Gmail MCP by running: cd gmail-mcp && uv sync && uv run python src/main.py

What MCP clients work with Gmail MCP?

Gmail MCP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Use Gmail MCP with Conare

Manage MCP servers visually, upload persistent context, and never start from zero with Claude Code & Codex.

Try Free