Stores email vector embeddings for semantic search capabilities, manages connections properly, and provides metadata filtering and efficient retrieval
Planned future integration for expanded database options and more advanced relationship modeling for emails
Generates vector embeddings for emails using models like nomic-embed-text for enhanced semantic search capabilities
Provides primary email storage, full-text search capabilities, processing status tracking, and efficient filtering with proper connection management
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Email Processing MCP Serverprocess emails from last week across all mailboxes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Email Processing MCP Server
A cross-platform MCP server that processes Microsoft Outlook emails, generates vector embeddings using Ollama, and provides semantic search capabilities. Works on Windows, macOS, and any platform via Microsoft Graph API.
The server complies with the Model Context Protocol (MCP) 2025-06-18 specification and uses the official MCP SDK.
Features
Core Capabilities
Process emails from Outlook with date range filtering
Store emails in SQLite database with proper connection management
Generate vector embeddings using Ollama (nomic-embed-text)
Semantic search across email content via MongoDB vector store
Multi-mailbox and multi-account support
Support for Inbox, Sent Items, and optionally Deleted Items folders
Cross-Platform Support
Windows: Native Outlook COM automation via pywin32
macOS: AppleScript integration with Outlook for Mac
Any Platform: Microsoft Graph API for cloud-based access (Windows, macOS, Linux, containers)
MCP 2025-06-18 Compliance
Structured Tool Results: Tools return properly typed, validated Pydantic models
HTTP Transport: Supports both STDIO and HTTP (Streamable HTTP) transports
Protocol Negotiation: Declares protocol version during handshake
Enhanced Metadata: Tool titles and descriptions for better UI integration
Available Tools (12+)
Category | Tools |
Email Processing |
|
Search & Analysis |
|
Data Export |
|
Folder Management |
|
Contact Management |
|
Statistics |
|
Related MCP server: Gmail MCP Server
Prerequisites
Required (All Platforms)
Python 3.10 or higher
Ollama running locally with
nomic-embed-textmodelMongoDB server (for storing embeddings)
Platform-Specific Requirements
Platform | Requirement |
Windows | Microsoft Outlook installed + pywin32 |
macOS | Microsoft Outlook for Mac installed |
Graph API | Azure AD app registration with Mail.Read permission |
Installation
1. Install uv (if not already installed)
2. Create and activate virtual environment
3. Install dependencies
Core installation (required):
Platform-specific extras:
4. Install Ollama embedding model
5. (Graph API only) Register Azure AD Application
If using Microsoft Graph API, you need to register an application in Azure AD:
Go to Azure Portal → Azure Active Directory → App registrations
Click "New registration"
Name your app and select "Accounts in this organizational directory only"
After creation, note the Application (client) ID and Directory (tenant) ID
Go to "Certificates & secrets" → "New client secret" → note the secret value
Go to "API permissions" → "Add a permission" → "Microsoft Graph" → "Application permissions"
Add:
Mail.Read,User.Read.All(for multi-account discovery)Click "Grant admin consent"
Configuration
Add the server to your Claude for Desktop configuration file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Environment Variables
Variable | Description | Required |
| MongoDB connection string | Yes |
| Path to SQLite database file | Yes |
| Ollama server URL (default: http://localhost:11434) | No |
| Embedding model name (default: nomic-embed-text) | No |
| MongoDB collection name | Yes |
| Process Deleted Items folder (default: "false") | No |
| Provider: | No |
| Timezone for dates (default: "UTC", e.g., "America/Chicago") | No |
Graph API Variables (required when
Variable | Description |
| Azure AD application (client) ID |
| Azure AD client secret |
| Azure AD tenant ID |
| Mailboxes: comma-separated list or "All" for auto-discovery |
Windows Configuration (COM Automation)
Uses native Outlook COM automation via pywin32.
macOS Configuration (AppleScript)
Uses AppleScript to communicate with Outlook for Mac.
Graph API Configuration (Cross-Platform)
Works on any platform with Azure AD credentials. Supports single or multiple mailboxes.
Single mailbox or specific mailboxes:
All mailboxes in tenant (auto-discovery):
Provider Auto-Detection
When OUTLOOK_PROVIDER is set to auto (default), the server automatically selects the best provider:
Platform | Auto-Selected Provider |
Windows |
|
macOS |
|
Linux/Other |
|
HTTP Transport (2025-06-18 Compliant)
For HTTP transport, run the server with the --http flag:
This will start the server at http://localhost:8000/mcp with full 2025-06-18 protocol compliance including:
Protocol version negotiation
Structured output schemas
HTTP header validation
Proper error handling
The HTTP transport supports both stateful and stateless operation modes.
Available Tools
1. process_emails
Process emails from a specified date range and return structured results:
Input:
Output (Structured):
The tool will:
Connect to specified Outlook mailboxes
Retrieve emails from Inbox and Sent Items folders (and Deleted Items if enabled)
Store emails in SQLite database
Generate embeddings using Ollama
Store embeddings in MongoDB for semantic search
Return structured results with detailed statistics
Example Usage in Claude
Architecture
Provider-Based Connector Design
The server uses a provider-based abstraction for cross-platform email access:
All connectors implement the same interface, returning standardized EmailMetadata objects regardless of platform.
Dual-Database Architecture
The server uses a hybrid storage approach:
SQLite Database:
Primary email storage and metadata
Full-text search capabilities
Processing status tracking
Date range and folder filtering
Fast structured queries
MongoDB:
Vector embeddings storage (768 dimensions)
Semantic similarity search
Metadata stored alongside embeddings
Enables AI-powered search
Error Handling
The server provides detailed error messages for common issues:
Invalid date formats
Connection issues with Outlook
MongoDB errors
Embedding generation failures with retry logic
SQLite storage errors
Ollama server connection issues with automatic retries
Resource Management
The server implements proper resource management to prevent issues:
Database connections (SQLite and MongoDB) are kept open during the server's lifetime to prevent "Cannot operate on a closed database" errors
Connections are only closed when the server shuts down, using an atexit handler
Destructors and context managers are used as a fallback to ensure connections are closed when objects are garbage collected
Connection management is designed to balance resource usage with operational reliability
Robust retry logic for external services like Ollama to handle temporary connection issues
MCP 2025-06-18 Compliance
This server has been upgraded to comply with the MCP 2025-06-18 specification:
Protocol Features
Protocol Version: Declares
protocolVersion: "2025-06-18"during handshakeStructured Output: All tools return typed, validated Pydantic models
HTTP Transport: Supports Streamable HTTP with proper header validation
Tool Metadata: Enhanced tool descriptions with titles and schemas
Error Handling: Structured error responses with detailed information
Transport Support
STDIO: Traditional stdin/stdout communication (default)
HTTP: Streamable HTTP on localhost:8000/mcp with header validation
Protocol Headers: Validates MCP-Protocol-Version and Origin headers
Single-Message JSON-RPC: No batch request support per 2025-06-18 spec
Structured Output
The process_emails tool returns a structured ProcessEmailsResult with:
success: Boolean indicating operation successprocessed_count: Number of emails successfully processedretrieved_count: Total emails retrieved from Outlookstored_count: Number of emails stored in SQLitefailed_count: Number of emails that failed processingmessage: Human-readable status messageerror: Error details if operation failed
Security Notes
The server only processes emails from specified mailboxes
All data is stored locally (SQLite) and in MongoDB
No external API calls except to local Ollama server (and Microsoft Graph if using that provider)
Requires explicit user approval for email processing
No sensitive email data is exposed through the MCP interface
HTTP transport binds only to localhost for security
Graph API uses OAuth 2.0 client credentials flow with Azure AD
Store Azure AD credentials securely (environment variables, not in code)
Debugging
If you encounter issues:
Verify emails were successfully processed (check process_emails response)
Ensure Ollama server is running for embedding generation
Check that the SQLite database is accessible
Verify MongoDB connection is working properly
Use
check_data_consistencytool to verify SQLite/MongoDB sync
Platform-Specific Debugging
Windows:
Ensure Outlook is running and accessible
Check that pywin32 is installed:
pip show pywin32Verify COM automation works:
python -c "import win32com.client; print('OK')"
macOS:
Ensure Outlook for Mac is installed (not just the "New Outlook" web app)
Test AppleScript access:
osascript -e 'tell application "Microsoft Outlook" to get name'Grant Terminal/IDE permission in System Preferences → Security & Privacy → Automation
Graph API:
Verify Azure AD app has correct permissions (Mail.Read, User.Read.All)
Check admin consent was granted
Test token acquisition: credentials are logged at startup
Verify
GRAPH_USER_EMAILSis set correctly ("All" or comma-separated emails)
Platform Limitations
Platform | Limitation |
Windows | Requires Outlook desktop app running |
macOS | "New Outlook" may have limited AppleScript support; use Graph API as fallback |
Graph API | Requires Azure AD setup; 30-day max date range enforced |
All | Maximum 30-day processing range per request |
Upcoming Features
Email summarization using LLMs
Automatic email categorization
Customizable email reports
Outlook drafting email responses
Outlook rule suggestions
Expanded database options with Neo4j and ChromaDB integration