email-agent-mcp-server

email-agent-mcp-server

Enables AI-powered Gmail triage: fetches unread emails, classifies them, drafts replies for important ones, and sends only after user approval via conversational review. Exposes tools for checking unread emails and submitting review feedback from Claude Desktop or any MCP client.

Category
Visit Server

README

Email Triage Agent

An AI agent that reads your Gmail inbox, classifies incoming emails, drafts replies for anything important, and only sends after you review and approve — built with LangGraph, Gemini, and exposed as an MCP server so it can be used directly from Claude Desktop.

What it does

  1. Fetches unread emails from Gmail (full body parsing, not just snippets)
  2. Classifies each one — spam, important, promotional, social, or updates — with urgency, topic, and summary
  3. Drafts a reply for anything classified as important, personalized with the real sender name and company name
  4. Pauses for human review — a conversational loop where you can approve, reject, or give feedback to revise the draft (as many rounds as needed)
  5. Sends the final approved reply as a real email via the Gmail API, correctly threaded

Architecture

Gmail (OAuth) → read_email → classify_intent → draft_response → human_review → send_reply
                                    ↓ (not important)
                                   END

The same pipeline is exposed two ways:

  • Directly — run email_agent.py, review in the terminal
  • Via MCP — run mcp_server.py, which wraps the pipeline as two tools (check_unread_emails, submit_review_feedback) callable from Claude Desktop or any MCP client, so you can review and approve emails just by talking to Claude naturally

Tech stack

  • langgraph — agent orchestration, state management, human-in-the-loop via interrupt()
  • langchain-google-genai — Gemini (gemini-2.5-flash) for classification and drafting
  • google-api-python-client + google-auth-oauthlib — Gmail API (read + send)
  • fastmcp — MCP server exposing the agent as callable tools

Setup

1. Install dependencies

pip install -r requirements.txt

2. Google Cloud setup

  • Create a project in Google Cloud Console
  • Enable the Gmail API
  • Create an OAuth client ID (Desktop app type) under Credentials
  • Download the credentials file and save it as credentials.json in the project root
  • Add yourself as a test user under Audience (while the app is in Testing mode)

3. Gemini API key

Get a key from Google AI Studio, then create a .env file:

GEMINI_API_KEY=your_key_here

4. First run — authorize Gmail access

python email_agent.py

This opens a browser window for one-time Google sign-in and authorization. A token.pickle file is saved afterward so you won't need to re-authorize on future runs.

Running it

Option A: Standalone script (terminal review)

python email_agent.py

Fetches unread emails, processes each one, and walks you through review in the terminal — approve, reject, or type feedback to revise the draft.

Option B: MCP server (for Claude Desktop or any MCP client)

python mcp_server.py

Exposes two tools:

  • check_unread_emails(max_results) — runs the full pipeline, returns classifications and any drafts pending review
  • submit_review_feedback(email_id, feedback) — resumes a paused review with "approve", "reject", or free-text revision instructions

Connecting to Claude Desktop

Add this to your claude_desktop_config.json under mcpServers:

"email-agent": {
  "command": "path/to/venv/Scripts/python.exe",
  "args": ["path/to/mcp_server.py"]
}

Restart Claude Desktop, then just ask it to "check my unread emails" — it will call the tools and let you review/approve drafts conversationally.

Notes

  • Uses MemorySaver for checkpointing, which is in-memory only — review state won't survive a process restart. A persistent checkpointer would be needed for long-running production use.
  • Retry policies are attached to classify_intent, draft_response, and send_reply to handle transient failures.
  • Requires absolute paths for .env, credentials.json, and token.pickle when run by Claude Desktop, since it doesn't launch from the project's working directory by default.

License

MIT (or your preference)

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured