Zimbra MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Zimbra MCP Server
MCP (Model Context Protocol) server for Zimbra to manage emails, tags, mail filters, calendar, and contacts.
Installation
cd ~/Projets/MCP/zimbra-mcp
# With uv
uv sync
# Or with pip
pip install -e .Related MCP server: Zoho Mail MCP Server
Configuration
Create a .env file from the example:
cp .env.example .envConfigure your Zimbra credentials:
ZIMBRA_URL=https://zimbra.example.com/service/soap
ZIMBRA_USER=me@example.com
ZIMBRA_PASSWORD=your_password
ZIMBRA_TIMEOUT=30
ZIMBRA_ENABLE_SEND=falseVariable | Description | Default |
| Zimbra SOAP endpoint URL | (required) |
| Zimbra account email | (required) |
| Zimbra account password | (required) |
| Request timeout in seconds (SOAP, auth and downloads) |
|
| Enable |
|
| Allow permanent deletion of emails/contacts ( |
|
| Enable the filter write tools ( |
|
| When set, the only directory | (unset) |
| Maximum attachment size downloaded |
|
| Accept a plain |
|
Usage
Start the server
uv run zimbra-mcpTest with MCP Inspector
mcp dev src/zimbra_mcp/server.pyAvailable Tools
Authentication
Tool | Description |
| Complete a two-factor login with the current code from an authenticator app |
| Report whether a Zimbra session is active and for which account |
Accounts without two-factor authentication log in at startup and need neither tool. For a 2FA
account, the server starts without a session: the first tool call fails with an authentication
error, the user gives the current TOTP code and zimbra_authenticate opens the session. When the
session expires, call zimbra_authenticate again with a new code. Accounts without 2FA
re-authenticate automatically.
Emails
Tool | Description |
| Search with Zimbra syntax (in:inbox, from:, tag:, etc.), optionally restricted to a folder ( |
| Retrieve an email by ID with full body |
| Download an attachment to a local file (never overwrites, confined to |
| List mail folders, shared folders included, one level at a time: |
| Search for a folder by name or path (case-insensitive partial match) |
| Create a mail folder ( |
| Move emails to a folder |
| Mark emails as read or unread |
| Delete emails (Trash by default; hard delete requires |
| Create or update a draft (plain text or HTML), with optional reply/forward support |
| Send an email directly (opt-in, requires |
Formatted (HTML) mail
create_draft and send_email accept body_html next to body. The message is then saved as
multipart/alternative with both an HTML and a plain-text part. If body is empty, the plain text
is generated from the HTML.
Sanitised:
body_htmlis reduced to a formatting subset (paragraphs, bold/italic, lists, links, tables, headings, inline styles). Scripts, event handlers,<style>blocks, images,javascript:links and style properties such asbackground-image: url(...)are removed.Replies keep the thread's formatting: with
include_original="inline", the original's HTML is quoted under a From/To/Sent/Subject header. Inlinecid:images in the original are dropped (the reply does not carry those parts); ordinaryhttpsimages are kept.Update in place: pass
draft_idtocreate_draftto replace an existing draft's content instead of creating a new one.
Reply & Forward Drafts
create_draft and send_email support linking to an original message for replies and forwards:
Parameter | Description |
| ID of the original message |
|
|
|
|
Examples:
Simple draft:
create_draft(to=[...], subject="...", body="...")Reply with quote:
create_draft(to=[...], subject="Re: ...", body="...", orig_msg_id="123", reply_type="r", include_original="inline")Forward as attachment:
create_draft(to=[...], subject="Fwd: ...", body="...", orig_msg_id="123", reply_type="w", include_original="attachment")HTML reply:
create_draft(to=[...], subject="Re: ...", body_html="<p>Thanks, <b>agreed</b>.</p>", orig_msg_id="123", reply_type="r")Revise a draft:
create_draft(to=[...], subject="Re: ...", body_html="<p>Revised</p>", draft_id="456")
Zimbra Search Syntax
Basic operators:
in:inbox- Emails in inboxfrom:john@example.com- Emails from Johnto:me- Emails sent to metag:important- Emails with "important" tagsubject:meeting- Subject containing "meeting"has:attachment- Emails with attachmentsafter:2024-01-01 before:2024-12-31- Date range (ISO or MM/DD/YYYY)is:unread- Unread emailsis:flagged- Flagged emails
Boolean operators:
from:john OR from:mary- Emails from John OR MaryNOT is:reador-is:read- Unread emails (exclusion)(from:john OR from:mary) subject:urgent- Parentheses for grouping
Combinations: in:inbox from:boss tag:urgent is:unread
Contacts
Tool | Description |
| Search contacts (all fields). Use |
| Retrieve a contact by ID |
| Create a contact (name, email, phone, company, etc.) |
| Update specific fields of an existing contact |
| Delete contacts (Trash by default; hard delete requires |
Tags
Tool | Description |
| List all tags with colors |
| Create a tag (name, color) |
| Delete a tag |
| Add a tag to emails |
| Remove a tag |
Available colors: blue, cyan, green, purple, red, yellow, pink, gray, orange
Filters
Tool | Description |
| List incoming mail filters in execution order |
| Show which filters would catch an email (received or hypothetical) and which one stops processing, without applying anything |
| Add a filter, at the end of the list or at a given place (opt-in, requires |
| Move a filter before another one or to a position (opt-in) |
| Rename, enable/disable, or replace the conditions or actions of a filter (opt-in) |
| Delete a filter (opt-in) |
| Add one condition to a filter, keeping the others (opt-in) |
| Remove one condition from a filter, keeping the others (opt-in) |
A condition is {"field": ..., "value": ..., "comparison": ..., "part": ...}:
field:sender(From address),recipient(To or Cc address),subject,list_id, or any header name (X-Spam-Flag,Reply-To)comparison:contains(default) oris, case-insensitivepart: forsenderandrecipient,all(default) ordomain
[{"field": "sender", "value": "spammer.com", "part": "domain"},
{"field": "X-VRSPAM-STATE", "value": "spam", "comparison": "is"}]Conditions are matched with all or any. Actions: move to a folder, tag, mark as read, flag, keep a copy in the Inbox, move to the Trash, stop processing the next filters. Filters are identified by their name.
Zimbra only accepts the whole filter list on write: each write tool reads the list, changes one filter and sends the list back, leaving the other filters untouched, including conditions and actions these tools cannot create. A change made in the web client between that read and that write is lost.
Zimbra has no dry run for filters, so find_matching_filters evaluates them itself from the email headers. Conditions on the body, size, date or address book cannot be evaluated: the filter is then reported as unknown, never as not matching.
Calendar
Tool | Description |
| Events over a period |
| Full details of an event |
| Create an event, optionally private, with attendees invited by email if requested |
| Change the title, time, location, description or privacy of an event you organize |
| Move an event to the Trash |
| User availability |
update_event only changes the fields it is given and keeps the rest of the event (recurrence, reminder, attendees). A recurring event is modified as a whole series, and attendees are not notified of the change.
Security
The content of emails is controlled by their senders. A malicious email can contain instructions aimed at the LLM (prompt injection), so the server limits what a manipulated model can do:
No sending by default:
send_emailonly exists whenZIMBRA_ENABLE_SEND=true, andcreate_eventonly emails invitations when it is set. Drafts are always safe to create.No irreversible deletion by default:
hard_delete=Trueis refused unlessZIMBRA_ENABLE_HARD_DELETE=true; emails and contacts go to the Trash.No filter changes by default: a filter acts on every future email, so the filter write tools only exist when
ZIMBRA_ENABLE_FILTERS=true. They never discard, redirect or reply: "delete" means moving to the Trash.File writes:
download_attachmentstrips any path from the file name (../../.bashrcbecomesbashrc), never overwrites an existing file and caps the size (ZIMBRA_MAX_ATTACHMENT_MB). SetZIMBRA_DOWNLOAD_DIRto confine writes to a single directory.Credentials: HTTPS is required unless explicitly overridden; the auth token is sent as a cookie (never in a URL that could end up in proxy logs), redirects are refused so it cannot be forwarded to another host; the password is never included in
repr().Timeouts on every request, so a hung server cannot block the MCP client forever.
Keep .env out of version control (it is in .gitignore) and prefer an application-specific password if your Zimbra supports it.
Development
Running tests
# Install test dependencies
uv sync --extra test
# Run tests
uv run pytest
# Verbose output
uv run pytest -vTest structure
Tests use unittest.mock to mock the Zimbra SOAP client, so no Zimbra server is needed. The capture_tools fixture in conftest.py intercepts @mcp.tool() decorators to access tool functions directly.
Claude Code Integration
Add to your MCP configuration (~/.claude/settings.json):
{
"mcpServers": {
"zimbra": {
"command": "uv",
"args": ["run", "--directory", "/home/me/Projets/MCP/zimbra-mcp", "zimbra-mcp"],
"env": {
"ZIMBRA_URL": "https://zimbra.example.com/service/soap",
"ZIMBRA_USER": "me@example.com",
"ZIMBRA_PASSWORD": "your_password"
}
}
}
}Project Structure
zimbra-mcp/
├── pyproject.toml
├── README.md
├── AGENTS.md
├── .env.example
├── src/
│ └── zimbra_mcp/
│ ├── __init__.py
│ ├── server.py # FastMCP entry point
│ ├── config.py # Configuration
│ ├── client.py # Zimbra SOAP client
│ ├── errors.py # Exceptions
│ └── tools/
│ ├── __init__.py
│ ├── auth.py # Two-factor login tools
│ ├── emails.py # Email tools
│ ├── tags.py # Tag tools
│ ├── filters.py # Mail filter tools
│ ├── contacts.py # Contact tools
│ └── calendar.py # Calendar tools
└── tests/
├── conftest.py # Shared fixtures
├── test_config.py
├── test_errors.py
├── test_client.py
└── tools/
├── test_auth.py
├── test_emails.py
├── test_tags.py
├── test_filters.py
├── test_contacts.py
└── test_calendar.pyContributing
See AGENTS.md for the conventions to follow, whether you write the code yourself or
with an AI assistant. Pull requests target the develop branch.
Acknowledgements
Many thanks to the people who contributed to this project:
Fritz Kunstler (@dfkunstler): two-factor authentication, attachment download hardening and the REST URL fix (#1)
Cindy Piassale (@cindyPiassale): shared folders and subfolder search (#2)
Sam Gelbart (@synaq): HTML bodies, HTML reply quoting, sanitising and draft updates (#3)
Ilies (@Saywyz): security hardening of attachments, deletion, authentication and configuration (#4)
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Search Gmail and Outlook, save drafts, manage email rules, and view email stats.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to read, search, send, and reply to Zoho Mail via IMAP/SMTP using an application-specific password.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to read, send, search, reply to, and delete emails directly from a Zoho Mail account.8MIT
- FlicenseAqualityDmaintenanceEnables reading, sending, and managing emails via IMAP/SMTP through natural language, including listing folders, searching, moving emails, and sending attachments.8-
- FlicenseCqualityDmaintenanceEnables AI assistants to manage Zoho Mail accounts, including sending/receiving emails, folder and label management, organization administration, and productivity tools like tasks and notes.782-