IMAP Email Assistant
STDIOMCP server enabling AI assistants to check email, process messages, and learn user preferences.
MCP server enabling AI assistants to check email, process messages, and learn user preferences.
A Model Context Protocol (MCP) server that enables AI assistants to check email, process messages, and learn user preferences through interaction.
This project implements an MCP server that interfaces with IMAP email servers to provide the following capabilities:
The IMAP MCP server is designed to work with Claude or any other MCP-compatible assistant, allowing them to act as intelligent email assistants that learn your preferences over time.
The project is currently organized as follows:
.
├── examples/ # Example configurations
│ └── config.yaml.example
├── imap_mcp/ # Source code
│ ├── __init__.py
│ ├── config.py # Configuration handling
│ ├── imap_client.py # IMAP client implementation
│ ├── models.py # Data models
│ ├── resources.py # MCP resources implementation
│ ├── server.py # Main server implementation
│ └── tools.py # MCP tools implementation
├── tests/ # Test suite
│ ├── __init__.py
│ └── test_models.py
├── INSTALLATION.md # Detailed installation guide
├── pyproject.toml # Project configuration
└── README.md # This file
Install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
Clone and install the package:
git clone https://github.com/non-dirty/imap-mcp.git cd imap-mcp uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate uv pip install -e ".[dev]"
Create a config file:
cp config.sample.yaml config.yaml
Set up Gmail OAuth2 credentials:
Update config.yaml
with your Gmail settings:
imap: host: imap.gmail.com port: 993 username: your-[email protected] use_ssl: true oauth2: client_id: YOUR_CLIENT_ID client_secret: YOUR_CLIENT_SECRET refresh_token: YOUR_REFRESH_TOKEN
To list emails in your inbox:
uv run list_inbox.py --config config.yaml --folder INBOX --limit 10
Available options:
--folder
: Specify which folder to check (default: INBOX)--limit
: Maximum number of emails to display (default: 10)--verbose
: Enable detailed logging outputTo start the IMAP MCP server:
uv run imap_mcp.server --config config.yaml
For development mode with debugging:
uv run imap_mcp.server --dev
To refresh your OAuth2 token:
uv run imap_mcp.auth_setup refresh-token --config config.yaml
To generate a new OAuth2 token:
uv run imap_mcp.auth_setup generate-token --config config.yaml
# Set up virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install development dependencies pip install -e ".[dev]"
pytest
This MCP server requires access to your email account, which contains sensitive personal information. Please be aware of the following security considerations:
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.