Gmail Check MCP Server
Integrates with Gmail over IMAP using app-password authentication to search and filter messages by sender, subject, date range, and read status, download email headers and body content, and cache results for AI-agent access.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Gmail Check MCP Server
๐ง AI-Powered Gmail Integration for MCP (Model Context Protocol)
A comprehensive skill for checking Gmail emails with advanced filtering, caching, and AI agent integration. Supports both standalone operation and MCP server mode for use with Claude Desktop and other AI agents.
โจ Features
๐ Smart Email Filtering - Filter by sender, subject (partial match), date range, and read status
๐ง Full Content Download - Download email headers, body content, and metadata
๐พ Intelligent Caching - 30-minute cache with hash-based deduplication
๐ค MCP Compatible - Full Model Context Protocol support for AI agents
๐ Multi-Language - Supports Chinese and English interfaces
๐ Secure Auth - Gmail app password authentication
โก High Performance - Optimized IMAP operations with connection reuse
Related MCP server: Gmail AutoAuth MCP Server
๐ Quick Start
Option 1: One-Click Installation (Recommended)
# Clone and install
git clone https://github.com/baddif/mcp-server-gmail-check.git
cd mcp-server-gmail-check
bash install.sh
# Check installation
python3 version.py --infoOption 2: Manual Installation
# 1. Clone repository
git clone https://github.com/baddif/mcp-server-gmail-check.git
cd mcp-server-gmail-check
# 2. Install Python dependencies
pip3 install -r requirements.txt
# 3. Configure Gmail credentials
cp gmail_config_example.json gmail_config_local.json
# Edit gmail_config_local.json with your credentials
# 4. Test installation
python3 test_gmail_skill.py
# 5. Check version
python3 version.py --version๐ Version Control & Updates
Check Current Version
# Show version information
python3 version.py --info
# Show version string only
python3 version.py --version
# Check for available updates
python3 version.py --check-updates
# Get version data as JSON
python3 version.py --jsonAutomatic Updates
One-Click Update (Recommended)
# Automatic update with backup
./update.sh
# Check for updates without applying
./update.sh --check
# Show update help
./update.sh --helpManual Update Process
# 1. Backup your configuration
cp gmail_config_local.json gmail_config_backup.json
# 2. Check for uncommitted changes
git status
# 3. Pull latest changes
git pull origin main
# 4. Update dependencies
pip3 install -r requirements.txt --upgrade
# 5. Test installation
python3 mcp_server.py --test
# 6. Restore configuration if needed
# (your gmail_config_local.json is preserved automatically)Version Information
Current Version: v1.1.0 (2026-02-12)
MCP Compatibility: 2024-11-05
Python Requirement: 3.7+
Update Method: Git-based with automatic dependency management
What's New in v1.1.0
โฑ๏ธ Enhanced Time Control:
time_range_hoursparameter for precise timing (1-720 hours)๐พ Cache Management:
use_cacheparameter for flexible cache control๐ Version Control: Automatic update system with configuration backup
๐ Improved Documentation: Comprehensive parameter guides and examples
See CHANGELOG.md for complete version history.
Running tests
The project uses pytest for tests. Most tests are unit tests and safe to run locally. Integration tests that contact live Gmail services are located under tests/integration/ and are gated behind the RUN_LIVE_TESTS environment variable to avoid accidental runs.
How to run integration (live) tests
Create and activate the project's virtual environment (recommended):
source .venv/bin/activate
Create a local credentials file at the repository root named
gmail_config_local.json(this file is gitignored). Provide your Gmail username and an app password (recommended). Do not commit this file.Run the integration tests by enabling the gate:
export RUN_LIVE_TESTS=1 .venv/bin/python -m pytest tests/integration -q
If you only want to run a single integration test file, pass its path instead of the whole folder.
MCP integration tests and secure credentials
If you want to test the MCP server integration (starting the MCP server and calling it with a client), follow these steps.
Provide credentials securely
Locally: create
gmail_config_local.jsonin the repository root. This file is gitignored. Do not commit it.In CI: store your credentials as secret variables (for example, GMAIL_USERNAME and GMAIL_APP_PASSWORD), and write them to
gmail_config_local.jsonat job runtime before running tests.
Example gmail_config_local.json (do not commit):
{
"username": "your_email@gmail.com",
"app_password": "your_16_digit_app_password",
"imap_server": "imap.gmail.com",
"imap_port": 993
}Start the MCP server (in a separate shell):
source .venv/bin/activate
python -m mcp_serverRun MCP integration tests (gated):
export RUN_LIVE_TESTS=1
.venv/bin/python -m pytest tests/integration -qSecurity notes:
Never commit
gmail_config_local.jsonor other secrets. Use CI secrets and write them to files at runtime.Limit the scope of credentials used for CI by using a dedicated Gmail account with minimal permissions.
Rotate app passwords periodically.
Creating a local MCP inspector configuration
If you use an MCP inspector or local MCP client for development, you can create a local inspector config from the provided example:
Copy the example file to create your local config:
cp mcp-inspector-config.example.json mcp-inspector-config.json
Edit
mcp-inspector-config.jsonand adjust theargsorenv.PYTHONPATHif necessary for your local setup. Prefer relative paths (e.g../mcp_server.pyand.) so the config remains portable.The repository keeps
mcp-inspector-config.example.jsonunder version control; your localmcp-inspector-config.jsonis ignored by git to avoid committing machine-specific paths.
If you need a quick one-liner to create a local copy and open it in your default editor (macOS):
cp mcp-inspector-config.example.json mcp-inspector-config.json && open mcp-inspector-config.jsonBackup & Recovery
The update script automatically backs up:
gmail_config_local.json- Your private Gmail credentialsclaude_desktop_config.json- Claude Desktop configurationAny custom configuration files
Backups are stored in timestamped folders: backup_YYYYMMDD_HHMMSS/
Update Troubleshooting
Update Script Fails
# Check Git repository status
git status
# Manual update
git fetch origin main
git pull origin mainDependencies Issues
# Force reinstall dependencies
pip3 install -r requirements.txt --force-reinstall
# Check Python version
python3 --versionConfiguration Lost
# Restore from backup (replace with your backup folder)
cp backup_20260212_143000/gmail_config_local.json .โ๏ธ Configuration
Gmail App Password Setup
Enable 2-Factor Authentication on your Google account
Generate App Password:
Go to Google Account Settings
Security โ 2-Step Verification โ App passwords
Select "Mail" and generate password
Configure credentials in
gmail_config_local.json:
{
"username": "your_email@gmail.com",
"password": "your_16_digit_app_password",
"imap_server": "imap.gmail.com",
"imap_port": 993
}Configuration Files
gmail_config_example.json- Public template (safe to commit)gmail_config_local.json- Your private config (gitignored)
๐ Usage Examples
Standalone Python Usage
from gmail_check_skill import GmailCheckSkill
from ldr_compat import ExecutionContext
# Initialize skill
skill = GmailCheckSkill()
ctx = ExecutionContext()
# Check recent emails
result = skill.execute(ctx,
sender_filter="notifications@github.com",
max_emails=10,
download_content=True
)
print(f"Found {len(result['data']['emails'])} emails")MCP Server Integration
Start MCP Server
# Start MCP server for AI agent integration
python3 mcp_server.py
# Test MCP server
python3 mcp_server.py --testClaude Desktop Integration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"gmail-check": {
"command": "python3",
"args": ["/path/to/mcp-server-gmail-check/mcp_server.py"],
"env": {
"PYTHONPATH": "/path/to/mcp-server-gmail-check"
}
}
}
}Generic MCP Client
from mcp import ClientSession, StdioServerParameters
async def use_gmail_skill():
server_params = StdioServerParameters(
command="python3",
args=["/path/to/mcp-server-gmail-check/mcp_server.py"]
)
async with ClientSession(server_params) as session:
await session.initialize()
# List available tools
tools = await session.list_tools()
# Check emails
result = await session.call_tool("gmail_check", {
"sender_filter": "important@company.com",
"days_back": 7,
"download_content": True
})
return result๐ง Function Parameters
The Gmail Check MCP Server ๅฎๅ จๆฏๆๅๆฐไผ ้๏ผไปฅไธๆฏๆๆๅฏ็จๅๆฐ๏ผ
๐ Complete Parameter List
Parameter | Type | Required | Default | Description |
| string | โ YES | - | Gmail username (email address) |
| string | โ YES | - | Gmail 16-digit app password |
| object | โ YES | - | Email filters: |
| integer | โ No | 30 | Check interval in minutes (1-1440) |
| boolean | โ No | false | Continuous monitoring mode |
| integer | โ No | 100 | Max emails per check (1-1000) |
| integer | โ No | 1 | Days to look back (1-30) |
| integer | โ No | 24 | Time range in hours from current time (1-720, overrides days_back) |
| boolean | โ No | true | Whether to use cache to avoid re-processing emails |
๐ฏ Parameter Usage Examples
Basic Email Check
{
"username": "your_email@gmail.com",
"app_password": "your_16_digit_app_password",
"email_filters": {
"notifications@github.com": ["pull request", "issue"],
"billing@aws.amazon.com": ["invoice", "bill"]
},
"max_emails": 20,
"days_back": 3
}Background Monitoring
{
"username": "monitor@gmail.com",
"app_password": "monitoring_password",
"email_filters": {
"alerts@company.com": ["urgent", "critical", "error"],
"support@service.com": ["ticket", "request"]
},
"background_mode": true,
"check_interval": 15,
"max_emails": 50,
"days_back": 1
}Comprehensive Scan
{
"username": "admin@domain.com",
"app_password": "admin_app_password",
"email_filters": {
"security@bank.com": ["alert", "fraud"],
"notifications@system.com": ["down", "maintenance"],
"reports@analytics.com": ["weekly", "monthly"]
},
"max_emails": 200,
"days_back": 7,
"check_interval": 60
}Precise Time Range Check
{
"username": "monitor@company.com",
"app_password": "precise_monitoring_pwd",
"email_filters": {
"alerts@system.com": ["critical", "error"]
},
"time_range_hours": 6,
"use_cache": false,
"max_emails": 50
}Cache-Disabled Full Scan
{
"username": "audit@company.com",
"app_password": "audit_app_password",
"email_filters": {
"compliance@bank.com": ["violation", "audit"],
"security@company.com": ["breach", "incident"]
},
"time_range_hours": 72,
"use_cache": false,
"max_emails": 500
}๐ค MCP Client Integration with Parameters
Direct JSON-RPC Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "gmail_check",
"arguments": {
"username": "user@gmail.com",
"app_password": "your_app_password",
"email_filters": {
"important@company.com": ["urgent", "action required"]
},
"max_emails": 25,
"days_back": 2
}
}
}Python MCP Client
async def check_emails_with_params():
server_params = StdioServerParameters(
command="python3",
args=["/path/to/mcp_server.py"]
)
async with ClientSession(server_params) as session:
await session.initialize()
# Call with custom parameters
result = await session.call_tool("gmail_check", {
"username": "your_email@gmail.com",
"app_password": "your_app_password",
"email_filters": {
"github@notifications.com": ["mentioned", "review"],
"alerts@system.com": ["critical", "down"]
},
"max_emails": 30,
"days_back": 3,
"background_mode": False
})
return resultClaude Desktop with Parameters
When using Claude Desktop, you can specify parameters in your conversation:
"Check my Gmail for:
- GitHub notifications about pull requests from last 2 days
- System alerts containing 'critical' or 'error' from last week
- Maximum 50 emails
- Username: developer@company.com
- Use background mode for continuous monitoring"โก Quick Test Commands
# Test parameter validation
python3 test_mcp_parameters.py
# Simulate MCP client with parameters
python3 demo_mcp_client.py
# Test real MCP server
echo '{"method":"tools/call","params":{"name":"gmail_check","arguments":{"username":"test@gmail.com","app_password":"test123","email_filters":{"test@example.com":["test"]}}}}' | python3 mcp_server.py
## ๐๏ธ Project Structure
mcp-server-gmail-check/
โโโ ๐ง Core Implementation
โ โโโ gmail_check_skill.py # Main Gmail skill
โ โโโ mcp_server.py # MCP protocol server
โ โโโ ldr_compat.py # Framework compatibility
โโโ ๐งช Testing & Validation
โ โโโ test_gmail_skill.py # Comprehensive tests
โ โโโ test_mcp_parameters.py # Parameter validation tests
โ โโโ test_mcp_server.py # MCP server tests
โโโ โ๏ธ Configuration
โ โโโ gmail_config_example.json # Public template
โ โโโ gmail_config_local.json # Private config (gitignored)
โ โโโ claude_desktop_config.json # Claude Desktop setup
โโโ ๐ Deployment & Updates
โ โโโ install.sh # One-click installation
โ โโโ update.sh # Automatic update script
โ โโโ version.py # Version management system
โ โโโ requirements.txt # Python dependencies
โ โโโ .gitignore # Security exclusions
โโโ ๐ Documentation
โโโ README.md # This file
โโโ CHANGELOG.md # Version history & updates
โโโ MCP_DEPLOYMENT.md # MCP integration guide
โโโ SKILL_GENERATION_RULES.md # Development standards
## ๐ Security Features
- โ
**App Password Auth** - Uses Gmail app passwords, not main password
- โ
**Config Isolation** - Private credentials separated from code
- โ
**Git Security** - Sensitive files automatically gitignored
- โ
**Input Validation** - All parameters validated and sanitized
- โ
**Error Handling** - Secure error messages without credential leaks
## ๐ Performance Optimizations
- โก **Connection Reuse** - Persistent IMAP connections
- ๐พ **Smart Caching** - 30-minute cache with hash-based deduplication
- ๐ **Efficient Search** - Server-side IMAP SEARCH commands
- ๐ **Batch Processing** - Bulk email operations
- ๐งน **Memory Management** - Automatic cleanup and connection management
## ๐ Troubleshooting
### Common Issues
**Authentication Failed**
```bash
# Check credentials
python3 -c "
import json
with open('gmail_config_local.json') as f:
config = json.load(f)
print('Username:', config['username'])
print('Password length:', len(config['password']))
"No Emails Found
Check date range with
days_backparameterVerify sender/subject filters are correct
Ensure Gmail IMAP is enabled
MCP Server Issues
# Test MCP server functionality
python3 mcp_server.py --test
# Check MCP configuration
echo '{"method":"initialize","params":{},"id":1}' | python3 mcp_server.pyDebug Mode
Enable detailed debugging:
import logging
logging.basicConfig(level=logging.DEBUG)
# Run with debug output
result = skill.execute(ctx, sender_filter="test@example.com")๐ค Contributing
Fork the repository
Create feature branch:
git checkout -b feature/amazing-featureFollow coding standards in
SKILL_GENERATION_RULES.mdAdd tests: Update
test_gmail_skill.pyCommit changes:
git commit -m 'Add amazing feature'Push to branch:
git push origin feature/amazing-featureOpen Pull Request
๐ Development Standards
This project follows the AI-Powered Application Standards v2.0.0:
โ OpenAI Function Calling compatible
โ Model Context Protocol (MCP) support
โ Framework-agnostic design
โ Comprehensive error handling
โ Multi-language support
โ Security-first configuration
See SKILL_GENERATION_RULES.md for detailed development guidelines.
๐ License
MIT License - see LICENSE file for details.
๐ Related Projects
Model Context Protocol - MCP specification
Claude Desktop - AI assistant with MCP support
OpenAI Function Calling - Function calling standard
๐ Support
๐ Bug Reports: GitHub Issues
๐ก Feature Requests: GitHub Discussions
๐ Documentation: See
MCP_DEPLOYMENT.mdfor advanced setup๐ Updates: Use
./update.shfor automatic updates or checkCHANGELOG.md๐ Version Info: Run
python3 version.py --infofor current version details
Getting Help
Before reporting issues, please:
Check your version:
python3 version.py --versionTry updating:
./update.sh --checkReview CHANGELOG.md for known issues
Test basic functionality:
python3 mcp_server.py --test
Include in bug reports:
Version information (
python3 version.py --json)Error messages and logs
Configuration (without credentials)
Steps to reproduce the issue
Made with โค๏ธ for the AI-powered future
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
This server cannot be deployed
Maintenance
Related MCP Connectors
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Email inboxes for AI agents: read, search, reply, send, bulk send and read attachments.
1- MyAgentMailDeprecatedcom.myagentmail
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to interact with Gmail accounts through IMAP/SMTP, supporting reading, sending, replying to emails, managing threads, downloading attachments, and searching with Gmail syntax using simple app password authentication.-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage Gmail through natural language interactions, supporting email operations (send, read, search, draft), comprehensive attachment handling (send, receive, download), label management, filters, and batch operations with automatic OAuth2 authentication.MIT
- FlicenseNot gradedqualityDmaintenanceEnables interaction with Gmail accounts via IMAP and SMTP, providing tools for searching emails, retrieving content, managing labels, and sending/forwarding emails through natural language.-
- AlicenseAqualityBmaintenanceEnables AI agents to search, read, label, draft, and reversibly trash Gmail messages through the official Gmail API, with safe attachment handling and guardrails against prompt injection. Drafts can be sent only after explicit user confirmation for that exact draft, and nothing is permanently deleted.211MIT