Email Server logo

Email Server

Organization
ai-zerolab

IMAP and SMTP via MCP Server

Publisherai-zerolab
Repositorymcp-email-server
LanguagePython
Forks
93
Stars
234
Available tools
7
Transport typestdio
Categories
LicenseBSD-3-Clause
Links
  • Connect tools to AI workflows

    Email Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 7 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    234 stars and 93 forks from the linked repository.

mcp-email-server

Release Build status codecov Commit activity License smithery badge

IMAP and SMTP via MCP Server

Installation

Manual Installation

We recommend using uv to manage your environment.

Try uvx mcp-email-server@latest ui to config, and use following configuration for mcp client:

json
{
  "mcpServers": {
    "zerolib-email": {
      "command": "uvx",
      "args": ["mcp-email-server@latest", "stdio"]
    }
  }
}

This package is available on PyPI, so you can install it using pip install mcp-email-server

After that, configure your email server using the ui: mcp-email-server ui

Environment Variable Configuration

You can also configure the email server using environment variables, which is particularly useful for CI/CD environments like Jenkins. zerolib-email supports both UI configuration (via TOML file) and environment variables, with environment variables taking precedence.

json
{
  "mcpServers": {
    "zerolib-email": {
      "command": "uvx",
      "args": ["mcp-email-server@latest", "stdio"],
      "env": {
        "MCP_EMAIL_SERVER_ACCOUNT_NAME": "work",
        "MCP_EMAIL_SERVER_FULL_NAME": "John Doe",
        "MCP_EMAIL_SERVER_EMAIL_ADDRESS": "john@example.com",
        "MCP_EMAIL_SERVER_USER_NAME": "john@example.com",
        "MCP_EMAIL_SERVER_PASSWORD": "your_password",
        "MCP_EMAIL_SERVER_IMAP_HOST": "imap.gmail.com",
        "MCP_EMAIL_SERVER_IMAP_PORT": "993",
        "MCP_EMAIL_SERVER_SMTP_HOST": "smtp.gmail.com",
        "MCP_EMAIL_SERVER_SMTP_PORT": "465"
      }
    }
  }
}

Available Environment Variables

VariableDescriptionDefaultRequired
MCP_EMAIL_SERVER_ACCOUNT_NAMEAccount identifier"default"No
MCP_EMAIL_SERVER_FULL_NAMEDisplay nameEmail prefixNo
MCP_EMAIL_SERVER_EMAIL_ADDRESSEmail address-Yes
MCP_EMAIL_SERVER_USER_NAMELogin usernameSame as emailNo
MCP_EMAIL_SERVER_PASSWORDEmail password-Yes
MCP_EMAIL_SERVER_IMAP_HOSTIMAP server host-Yes
MCP_EMAIL_SERVER_IMAP_PORTIMAP server port993No
MCP_EMAIL_SERVER_IMAP_SSLEnable IMAP SSLtrueNo
MCP_EMAIL_SERVER_IMAP_VERIFY_SSLVerify IMAP SSL certificates (disable for self-signed)trueNo
MCP_EMAIL_SERVER_SMTP_HOSTSMTP server host-Yes
MCP_EMAIL_SERVER_SMTP_PORTSMTP server port465No
MCP_EMAIL_SERVER_SMTP_SSLEnable SMTP SSLtrueNo
MCP_EMAIL_SERVER_SMTP_START_SSLEnable STARTTLSfalseNo
MCP_EMAIL_SERVER_SMTP_VERIFY_SSLVerify SSL certificates (disable for self-signed)trueNo
MCP_EMAIL_SERVER_ENABLE_ATTACHMENT_DOWNLOADEnable attachment downloadfalseNo
MCP_EMAIL_SERVER_SAVE_TO_SENTSave sent emails to IMAP Sent foldertrueNo
MCP_EMAIL_SERVER_SENT_FOLDER_NAMECustom Sent folder name (auto-detect if not set)-No

HTTP Transport Security

HTTP transports (sse and streamable-http) validate request Host and Origin headers to protect against DNS rebinding attacks. Localhost is allowed by default. For Docker networks or reverse proxies, configure the expected service names explicitly.

VariableDescriptionDefault
MCP_HOSTHTTP bind host for streamable-httplocalhost
MCP_PORTHTTP bind port for streamable-http9557
MCP_ALLOWED_HOSTSComma-separated allowed Host values. Supports host:* portsLocalhost hosts
MCP_ALLOWED_ORIGINSComma-separated allowed Origin values. Supports host:* portsLocalhost origins
MCP_ENABLE_DNS_REBINDING_PROTECTIONEnable DNS rebinding protectiontrue

Docker Compose example:

yaml
services:
  mcp-email-server:
    image: ghcr.io/ai-zerolab/mcp-email-server:latest
    command: ["streamable-http"]
    environment:
      MCP_HOST: 0.0.0.0
      MCP_PORT: 9557
      MCP_ALLOWED_HOSTS: mcp-email-server:*,localhost:*,127.0.0.1:*
      MCP_ALLOWED_ORIGINS: http://mcp-email-server:*,http://localhost:*,http://127.0.0.1:*

Bare host entries such as MCP_ALLOWED_HOSTS=mcp-email-server also allow any port on that host. MCP_ENABLE_DNS_REBINDING_PROTECTION=false, MCP_ALLOWED_HOSTS=*, or MCP_ALLOWED_ORIGINS=* disables Host and Origin validation entirely. Use those options only in isolated local development environments.

IPv6 literals in allowlists should use bracketed notation, such as [::1]:* and http://[::1]:*.

Enabling Attachment Downloads

By default, downloading email attachments is disabled for security reasons. To enable this feature, you can either:

Option 1: Environment Variable

json
{
  "mcpServers": {
    "zerolib-email": {
      "command": "uvx",
      "args": ["mcp-email-server@latest", "stdio"],
      "env": {
        "MCP_EMAIL_SERVER_ENABLE_ATTACHMENT_DOWNLOAD": "true"
      }
    }
  }
}

Option 2: TOML Configuration

Add enable_attachment_download = true to your TOML configuration file (~/.config/zerolib/mcp_email_server/config.toml):

toml
enable_attachment_download = true

[[emails]]
# ... your email configuration

Once enabled, you can use the download_attachment tool to save email attachments to a specified path.

Saving Sent Emails to IMAP Sent Folder

By default, sent emails are automatically saved to your IMAP Sent folder. This ensures that emails sent via the MCP server appear in your email client (Thunderbird, webmail, etc.).

The server auto-detects common Sent folder names: Sent, INBOX.Sent, Sent Items, Sent Mail, [Gmail]/Sent Mail.

To specify a custom Sent folder name (useful for providers with non-standard folder names):

Option 1: Environment Variable

json
{
  "mcpServers": {
    "zerolib-email": {
      "command": "uvx",
      "args": ["mcp-email-server@latest", "stdio"],
      "env": {
        "MCP_EMAIL_SERVER_SENT_FOLDER_NAME": "INBOX.Sent"
      }
    }
  }
}

Option 2: TOML Configuration

toml
[[emails]]
account_name = "work"
save_to_sent = true
sent_folder_name = "INBOX.Sent"
# ... rest of your email configuration

To disable saving to Sent folder, set MCP_EMAIL_SERVER_SAVE_TO_SENT=false or save_to_sent = false in your TOML config.

Self-Signed Certificates (e.g., ProtonMail Bridge)

If you're using a local mail server with self-signed certificates (like ProtonMail Bridge), you'll need to disable SSL certificate verification:

json
{
  "mcpServers": {
    "zerolib-email": {
      "command": "uvx",
      "args": ["mcp-email-server@latest", "stdio"],
      "env": {
        "MCP_EMAIL_SERVER_IMAP_VERIFY_SSL": "false",
        "MCP_EMAIL_SERVER_SMTP_VERIFY_SSL": "false"
      }
    }
  }
}

Or in TOML configuration:

toml
[[emails]]
account_name = "protonmail"
# ... other settings ...

[emails.incoming]
verify_ssl = false

[emails.outgoing]
verify_ssl = false

For separate IMAP/SMTP credentials, you can also use:

  • MCP_EMAIL_SERVER_IMAP_USER_NAME / MCP_EMAIL_SERVER_IMAP_PASSWORD
  • MCP_EMAIL_SERVER_SMTP_USER_NAME / MCP_EMAIL_SERVER_SMTP_PASSWORD

Then you can try it in Claude Desktop. If you want to intergrate it with other mcp client, run $which mcp-email-server for the path and configure it in your client like:

json
{
  "mcpServers": {
    "zerolib-email": {
      "command": "{{ ENTRYPOINT }}",
      "args": ["stdio"]
    }
  }
}

If docker is avaliable, you can try use docker image, but you may need to config it in your client using tools via MCP. The default config path is ~/.config/zerolib/mcp_email_server/config.toml

json
{
  "mcpServers": {
    "zerolib-email": {
      "command": "docker",
      "args": ["run", "-it", "ghcr.io/ai-zerolab/mcp-email-server:latest"]
    }
  }
}

Installing via Smithery

To install Email Server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @ai-zerolab/mcp-email-server --client claude

Usage

Replying to Emails

To reply to an email with proper threading (so it appears in the same conversation in email clients):

  1. First, fetch the original email to get its message_id:
python
emails = await get_emails_content(account_name="work", email_ids=["123"])
original = emails.emails[0]
  1. Send your reply using in_reply_to and references:
python
await send_email(
    account_name="work",
    recipients=[original.sender],
    subject=f"Re: {original.subject}",
    body="Thank you for your email...",
    in_reply_to=original.message_id,
    references=original.message_id,
)

The in_reply_to parameter sets the In-Reply-To header, and references sets the References header. Both are used by email clients to thread conversations properly.

Development

This project is managed using uv.

Try make install to install the virtual environment and install the pre-commit hooks.

Use uv run mcp-email-server for local development.

Releasing a new version

  • Create an API Token on PyPI.
  • Add the API Token to your projects secrets with the name PYPI_TOKEN by visiting this page.
  • Create a new release on Github.
  • Create a new tag in the form *.*.*.

For more details, see here.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "zerolib-email": {
      "command": "uvx",
      "args": [
        "mcp-email-server@latest",
        "stdio"
      ]
    }
  }
}

Available Tools

  • list_available_accounts

    List all configured email accounts with masked credentials.

  • add_email_account

    Add a new email account configuration to the settings.

  • send_email

    Send an email using the specified account. Supports replying to emails with proper threading when in_reply_to is provided.

  • list_emails_metadata

    List email metadata (email_id, subject, sender, recipients, date) without body content. Returns email_id for use with get_emails_content.

  • get_emails_content

    Get the full content (including body) of one or more emails by their email_id. Use list_emails_metadata first to get the email_id.

  • delete_emails

    Delete one or more emails by their email_id. Use list_emails_metadata first to get the email_id.

  • download_attachment

    Download an email attachment and save it to the specified path. This feature must be explicitly enabled in settings (enable_attachment_download=true) due to security considerations.

Use Email Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Email Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Email Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Email Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "email-server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-email-server"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Email Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Email Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Email Server to help me with this task?
Email Server
Sure. I read it.
Here is what I found using Email Server.

Frequently asked questions

What is the Email Server MCP server used for?

Email Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Email Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Email Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Email Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Email Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Email Server MCP to TypingMind?

Email Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Email Server MCP provide in TypingMind?

Email Server exposes 7 MCP tools that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Email Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Email Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇