Home / MCP / Email Processing MCP Server

Email Processing MCP Server

Processes Outlook emails, stores in SQLite, and enables semantic search via MongoDB and Ollama embeddings.

python
Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
    "mcpServers": {
        "outlook_email": {
            "command": "C:/Users/username/path/to/mcp-server-outlook-email/.venv/Scripts/python",
            "args": [
                "C:/Users/username/path/to/mcp-server-outlook-email/src/mcp_server.py"
            ],
            "env": {
                "MONGODB_URI": "mongodb://localhost:27017/MCP?authSource=admin",
                "SQLITE_DB_PATH": "C:\\\\Users\\\\username\\\\path\\\\to\\\\mcp-server-outlook-email\\\\data\\\\emails.db",
                "EMBEDDING_BASE_URL": "http://localhost:11434",
                "EMBEDDING_MODEL": "nomic-embed-text",
                "LLM_MODEL": "<LLM_MODEL>",
                "COLLECTION_NAME": "outlook-emails",
                "PROCESS_DELETED_ITEMS": "false"
            }
        }
    }
}

This Email Processing MCP Server lets you import, store, and search Outlook emails locally. It connects to Outlook mailboxes, saves emails in SQLite for fast access, and generates vector embeddings with Ollama for semantic search using MongoDB. You gain streamlined email processing across multiple mailboxes with robust storage and retrieval capabilities.

How to use

You use an MCP client to run actions against the Email Processing MCP Server. Start by ensuring Ollama is running locally for embeddings, then trigger the process_emails tool to fetch emails from your configured Outlook mailboxes within a chosen date range. The server will save emails to SQLite, generate embeddings, and store those embeddings in MongoDB so you can later search emails by content semantics or metadata.

Key usage patterns you can perform include processing emails from multiple mailboxes in a specified date window, including Inbox and Sent Items, and optionally Deleted Items. The workflow involves connecting to Outlook, retrieving emails, storing raw messages in SQLite, creating embeddings with Ollama, and saving those embeddings for semantic search.

How to install

pip install uv

# Create a virtual environment managed by uv
uv venv .venv

# Activate the virtual environment
# Windows
.venv\Scripts\activate

# macOS/Linux
source .venv/bin/activate

# Install package dependencies and the MCP package
uv pip install -e .
uv pip install fastmcp

# Ensure Ollama is running locally and has the embedding model available
ollama pull nomic-embed-text

Additional notes

Prerequisites you need before setup include Python 3.10 or higher, Ollama running locally with the nomic-embed-text model, Microsoft Outlook installed on Windows, and a MongoDB server for embedding storage.

Configuration example

{
  "mcpServers": {
    "outlook-email": {
      "command": "C:/Users/username/path/to/mcp-server-outlook-email/.venv/Scripts/python",
      "args": [
        "C:/Users/username/path/to/mcp-server-outlook-email/src/mcp_server.py"
      ],
      "env": {
        "MONGODB_URI": "mongodb://localhost:27017/MCP?authSource=admin",
        "SQLITE_DB_PATH": "C:\\Users\\username\\path\\to\\mcp-server-outlook-email\\data\\emails.db",
        "EMBEDDING_BASE_URL": "http://localhost:11434",
        "EMBEDDING_MODEL": "nomic-embed-text",
        "COLLECTION_NAME": "outlook-emails",
        "PROCESS_DELETED_ITEMS": "false"
      }
    }
  }
}

Tracing, monitoring, and error handling

The server is designed to support external tracing and monitoring. The logging system has been replaced with a robust tracing approach. If you encounter issues, verify the emails were processed, ensure Ollama is running for embeddings, check SQLite accessibility, and confirm MongoDB connections are healthy.

Security and data handling

The server processes emails only from explicitly configured mailboxes. All data remains locally stored—SQLite for primary data and MongoDB for embeddings. No external API calls are made beyond the local Ollama server, and explicit user approval is required to trigger email processing.

Available tools

process_emails

Process emails from a specified date range, fetch from Outlook mailboxes, store in SQLite, generate embeddings with Ollama, and store embeddings in MongoDB for semantic search.