Zimbra MCP Server
Zimbra MCP Server
MCP (Model Context Protocol) server for Zimbra to manage emails, tags, calendar, and contacts.
Installation
cd ~/Projets/MCP/zimbra-mcp
# With uv
uv sync
# Or with pip
pip install -e .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 |
|
| Enable |
|
Usage
Start the server
uv run zimbra-mcpTest with MCP Inspector
mcp dev src/zimbra_mcp/server.pyAvailable Tools
Emails
Tool | Description |
| Search with Zimbra syntax (in:inbox, from:, tag:, etc.) |
| Retrieve an email by ID with full body |
| Download an attachment to a local file |
| List all mail folders |
| Search for a folder by name or path (case-insensitive partial match) |
| Move emails to a folder |
| Mark emails as read or unread |
| Delete emails (soft delete to Trash, or hard delete) |
| Create a draft with optional reply/forward support |
| Send an email directly (opt-in, requires |
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")
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 one or more contacts |
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
Calendar
Tool | Description |
| Events over a period |
| Full details of an event |
| Create an event |
| User availability |
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
├── CLAUDE.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
│ ├── emails.py # Email tools
│ ├── tags.py # Tag 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_emails.py
├── test_tags.py
├── test_contacts.py
└── test_calendar.py