Mail MCP server

Enables AI assistants to send and receive emails directly through IMAP and SMTP protocols, bridging email services with conversation interfaces for seamless correspondence management.
Back to servers
Provider
shuakami
Release date
Mar 20, 2025
Language
TypeScript
Stats
22 stars

The Mail MCP tool enables AI models to access email services through a standardized Model Context Protocol (MCP) interface. It allows AI assistants to perform various email operations like sending emails, reading inboxes, and handling attachments without requiring users to manually input complex API calls or switch to email clients.

Installation

Environment Setup

Before installing Mail MCP, ensure you have the following prerequisites:

Installation Steps

  1. Clone and install the repository:
git clone https://github.com/shuakami/mcp-mail.git
cd mcp-mail
npm install
  1. Build the project:
npm run build
  1. Configure your email account:

Create a mcp.json file in the project root directory with your email settings:

{
  "smtp": {
    "host": "smtp.example.com",
    "port": 465,
    "secure": true,
    "auth": {
      "user": "[email protected]",
      "pass": "your-password-or-app-password"
    }
  },
  "imap": {
    "host": "imap.example.com",
    "port": 993,
    "secure": true,
    "auth": {
      "user": "[email protected]",
      "pass": "your-password-or-app-password"
    }
  },
  "defaults": {
    "fromName": "Your Name",
    "fromEmail": "[email protected]"
  }
}

Common Email Service Configurations

QQ Mail

{
  "smtp": {
    "host": "smtp.qq.com",
    "port": 465,
    "secure": true
  },
  "imap": {
    "host": "imap.qq.com",
    "port": 993,
    "secure": true
  }
}

Gmail

{
  "smtp": {
    "host": "smtp.gmail.com",
    "port": 465,
    "secure": true
  },
  "imap": {
    "host": "imap.gmail.com",
    "port": 993,
    "secure": true
  }
}

Outlook/Hotmail

{
  "smtp": {
    "host": "smtp-mail.outlook.com",
    "port": 587,
    "secure": false
  },
  "imap": {
    "host": "outlook.office365.com",
    "port": 993,
    "secure": true
  }
}

Security Note: For Gmail, Outlook, and similar services, use app-specific passwords instead of your account password. For QQ Mail, you need to enable POP3/SMTP/IMAP services in your QQ Mail settings and obtain an authorization code.

Configuring Cursor MCP

Windows Configuration

Create or edit the MCP configuration file at C:\Users\your-username\.cursor\mcp.json:

{
  "mcpServers": {
    "mail-mcp": {
      "command": "python",
      "args": [
        "C:/Users/your-username/mcp-mail/bridging_mail_mcp.py"
      ]
    }
  }
}

macOS Configuration

Create or edit the MCP configuration file at /Users/your-username/.cursor/mcp.json:

{
  "mcpServers": {
    "mail-mcp": {
      "command": "python3",
      "args": [
        "/Users/your-username/mcp-mail/bridging_mail_mcp.py"
      ]
    }
  }
}

Linux Configuration

Create or edit the MCP configuration file at /home/your-username/.cursor/mcp.json:

{
  "mcpServers": {
    "mail-mcp": {
      "command": "python3",
      "args": [
        "/home/your-username/mcp-mail/bridging_mail_mcp.py"
      ]
    }
  }
}

Important: Replace your-username with your actual username. Make sure the path correctly points to where you cloned the project. Do not delete the cloned folder as this will prevent the MCP from working properly.

Using Mail MCP

After configuration, restart the Cursor editor, which will automatically start the MCP service. You can then use the Mail MCP tool by asking the AI to perform email tasks.

Example Usage

You can ask the AI to perform the following operations:

  • "List my email folders"
  • "Show the latest 5 emails in my inbox"
  • "Send an email with the subject 'Test Email' to [email protected]"
  • "Search for emails containing the keyword 'invoice'"
  • "View details of the email with UID 1234"
  • "Download attachments from an email"

Supported Features

The Mail MCP tool supports a comprehensive range of email operations:

  • Email Sending: Plain text emails, HTML emails, emails with attachments, mass emails
  • Email Reception and Querying: Get folder lists, list emails, advanced search, get email details
  • Email Management: Mark as read/unread, delete emails, move emails
  • Attachment Management: View attachment lists, download attachments, view attachment content
  • Contact Management: Get contact lists, search contacts

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later