sieve-mcp-server
OfficialAllows managing Sieve mail filter scripts on cPanel-hosted mail servers via ManageSieve.
Enables managing Sieve mail filter scripts on Dovecot/Pigeonhole mail servers over ManageSieve, including validation, activation, and local backups.
Allows reading, writing, validating, activating, and backing up Sieve mail filter scripts on mailbox.org over ManageSieve.
Allows managing Sieve mail filter scripts on Plesk-hosted mail servers via ManageSieve.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sieve-mcp-server create a filter that files emails from newsletters into a News folder"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
sieve-mcp-server
An MCP server that lets Claude (Desktop, Code, or any MCP client) read, write, validate, and activate Sieve mail filter scripts on your mail server over ManageSieve (RFC 5804).
It is built to go alongside an IMAP MCP server such as imap-mcp-server, which can read and move mail but cannot manage server-side filter rules.
Every upload is validated by your server first (
CHECKSCRIPT), and nothing is written if validation fails.Replacing a script needs
overwrite: true, anddryRunshows a diff first.The previous version is backed up locally before any overwrite or delete.
Uploading a script never activates it; activation is a separate, explicit call.
The active script cannot be deleted.
Passwords are stored AES-256-GCM encrypted in one place shared by all your MCP clients.
Requirements
Node.js ≥ 22.12
A mail server with ManageSieve enabled, usually on port 4190. Dovecot/Pigeonhole, Cyrus, Stalwart, mailbox.org, Posteo and most cPanel/Plesk hosts support it. Gmail and Outlook.com do not support Sieve.
Related MCP server: email-mcp
Install
git clone https://github.com/trustypangolin/sieve-mcp-server.git
cd sieve-mcp-server
npm install
npm run buildSet up an account
Run the setup CLI in a terminal. That way your password is typed there and never passes through a chat:
node dist/setup.js addIf you already use imap-mcp-server, you can import its accounts without retyping passwords. The importer only reads ~/.imap-mcp; it never changes anything there.
node dist/setup.js import-imap
# ManageSieve host differs from the IMAP host:
node dist/setup.js import-imap --account personal --host sieve.example.comOther commands: list, test <name>, update <name> [--host … --port … --tls … --password], remove <name>. Run node dist/setup.js --help for all options.
Each account is tested (connect, TLS, login) before it is saved. Pass --skip-test to save it anyway.
Connect Claude
node dist/setup.js config prints both snippets below with the correct absolute path filled in.
Claude Desktop: add to claude_desktop_config.json. On Windows that is %APPDATA%\Claude\; on macOS it is ~/Library/Application Support/Claude/.
{
"mcpServers": {
"sieve": {
"command": "node",
"args": ["C:\\path\\to\\sieve-mcp-server\\dist\\index.js"]
}
}
}Claude Code (available in all projects):
claude mcp add --scope user sieve -- node /path/to/sieve-mcp-server/dist/index.jsEditing rules locally
If you'd rather edit scripts in your own editor than through chat, use the setup CLI. local-rules/ is gitignored, so your real rules never get committed.
node dist/setup.js pull # every script → local-rules/<account>/<script>.sieve
node dist/setup.js check "local-rules/Personal/My Rules.sieve"
node dist/setup.js push "local-rules/Personal/My Rules.sieve" # validate, show diff, confirm, upload
node dist/setup.js activate "My Rules"pullnever overwrites a local file you've edited unless you pass--force.pushuses the file name as the script name; pass--nameto override it. Like the MCP tool, it backs up the server copy first and never activates the script.
samples/ has commented example rules: filing, mailing lists, spam, vacation, flags, plus-addressing, attachments, and a complete combined script.
One shared config for every client
Accounts live in ~/.sieve-mcp/ (%USERPROFILE%\.sieve-mcp\ on Windows):
File | Contents |
| Accounts, with passwords AES-256-GCM encrypted |
| Random 256-bit encryption key (owner-only permissions on macOS/Linux) |
| Script versions saved before each overwrite or delete |
Claude Desktop and Claude Code both run the server as your user, so they read the same store. The store is re-read on every call, which means an account added with the CLI shows up without restarting either client. Set SIEVE_MCP_HOME to move the store somewhere else.
Credentials from environment variables
To keep a password out of the store, save the account with an empty password, then set environment variables in the MCP client's env block:
SIEVE_MCP_ACCOUNT_<NAME>_USERNAME
SIEVE_MCP_ACCOUNT_<NAME>_PASSWORD<NAME> is the account name in uppercase, with every non-alphanumeric character replaced by _. For example, the account Personal Mail becomes SIEVE_MCP_ACCOUNT_PERSONAL_MAIL_PASSWORD. The values are read once at startup and then removed from the process environment.
Tools
Tool | What it does |
| Lists the configured accounts. Passwords are never shown. |
| Manage accounts from the chat. The CLI is preferred for passwords. |
| Shows the server's supported Sieve extensions. Also works as a connection test. |
| Lists the scripts on the server and which one is active. |
| Returns a script's source. |
| Has the server validate a script without saving it. |
| Creates or replaces a script, with validation, |
| Sets which script filters incoming mail, or switches filtering off. |
| Deletes an inactive script, after backing it up. |
| Renames a script. If it was active, it stays active. |
| Lists local backups and reads one back, so a change can be undone. |
Every tool accepts accountName (or accountId). You can leave both out when only one account is configured.
A typical change goes like this. You ask, for example, "file anything from the council into Council". Claude reads the active script, edits it, and runs a dry run so you can review the diff. It writes the change only after you approve it.
Security
TLS is required by default. With the default
tls: "starttls", the server refuses to log in if the mail server doesn't offer STARTTLS. Useimplicitfor a port that speaks TLS from the first byte. Usenoneonly on localhost or a trusted network.Certificates are verified. Set
allowInvalidCertificateonly for a self-signed certificate you trust. The client sets verification explicitly, so a globalNODE_TLS_REJECT_UNAUTHORIZED=0does not weaken it.Logins use SASL PLAIN, and only ever after TLS unless you chose
tls: "none".Nothing is logged except startup info, which goes to stderr. There is no telemetry, and the server makes no network connections other than to your own mail server.
Development
npm run dev # run the server from source
npm run setup -- list
npm test # vitest, including a fake ManageSieve server with STARTTLS
npm run lint # tsc --noEmitThe ManageSieve client in src/protocol/ is written from RFC 5804. It contains no code from other ManageSieve implementations. In particular, the AGPL-licensed Sieve Editor is not a source.
License
MIT
Available Tools
15 toolssieve_activate_scriptA
Make a script the active one, so it filters all incoming mail from now on. This replaces the currently active script (which stays stored, just inactive). Only do this when the user asks for the script to go live.
Inputs: name (required), accountId, accountName.
sieve_add_accountA
Add a ManageSieve account. Prefer telling the user to run sieve-mcp-setup add (or sieve-mcp-setup import-imap) in a terminal so the password is typed there instead of passing through this conversation; use this tool only if the user explicitly provides the details here. By default the connection and login are tested first and nothing is saved if they fail. The account is stored in the shared encrypted store used by every MCP client on this machine.
Inputs: host (required), name (required), user (required), password (required), +4 more.
sieve_check_scriptA
Ask the server to validate Sieve source without saving it. Returns valid/errors/warnings from the server's own compiler, so it catches unsupported extensions too. sieve_put_script runs this automatically; use it directly while iterating on a draft.
Inputs: content (required), accountId, accountName.
sieve_deactivate_scriptsA
Deactivate the active script, so no Sieve filtering is applied to incoming mail at all. Scripts stay stored. Only when the user explicitly wants filtering switched off.
Inputs: accountId, accountName.
sieve_delete_scriptA
Delete a stored script from the server. Refuses to delete the active script. A local backup is saved first and its file name returned. Only when the user asks for the script to be deleted.
Inputs: name (required), accountId, accountName.
sieve_get_backupA
Read the content of a local backup. To restore it, pass the content to sieve_put_script (with overwrite: true if the script still exists).
Inputs: file (required), accountId, accountName.
sieve_get_capabilitiesA
Connect, log in, and return the server's capabilities — most importantly sieveExtensions, the Sieve extensions this server supports (e.g. fileinto, imap4flags, vacation, regex, variables, date). Check this before writing a script that requires an extension. Also the quickest way to test that an account works.
Inputs: accountId, accountName.
sieve_get_scriptA
Read the full source of a Sieve script. Always read the current script before changing it, and edit that text rather than writing a replacement from scratch, so existing rules are preserved.
Inputs: name (required), accountId, accountName.
sieve_list_accountsA
List configured ManageSieve accounts (name, host, port, tls, user, and where the password comes from — never the password itself). Call this first when the user has more than one mailbox, to get the accountName for other tools.
Inputs: no named parameters.
sieve_list_backupsA
List local backups taken automatically before scripts were overwritten or deleted, newest first. Use with sieve_get_backup to undo a change.
Inputs: name, accountId, accountName.
sieve_list_scriptsA
List the Sieve scripts stored on the server and which one is active. Only one script is active at a time; it is the one that filters incoming mail. Start here before reading or changing filters.
Inputs: accountId, accountName.
sieve_put_scriptA
Create or replace a Sieve script. The server validates it first and nothing is written if it is invalid. Replacing an existing script requires overwrite: true; the previous version is backed up locally first (see sieve_list_backups). Recommended flow for changes: sieve_get_script → edit → sieve_put_script with dryRun: true → show the user the diff → sieve_put_script with overwrite: true once they agree. Writing never activates a script: if the script being replaced is already active, the change takes effect immediately; otherwise call sieve_activate_script.
Inputs: name (required), content (required), dryRun, accountId, +2 more.
sieve_remove_accountA
Remove an account from the local config. This only forgets the connection details on this machine; scripts on the server are untouched. The account must be named explicitly, and only do this when the user asks.
Inputs: accountId, accountName.
sieve_rename_scriptA
Rename a script on the server. If it is active it stays active. Fails if the new name is taken.
Inputs: name (required), newName (required), accountId, accountName.
sieve_update_accountA
Change connection settings of an existing account (host, port, tls, user, certificate check, name). Passwords are best changed with sieve-mcp-setup update <name> --password in a terminal. The account must be named explicitly.
Inputs: tls, host, port, user, +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Each tool targets a clearly distinct resource and action: account management, script lifecycle, validation, activation, deletion, and local backups are cleanly separated. Overlaps such as check_script versus put_script with dryRun are explicitly clarified by the descriptions.
The set uses a consistent sieve_ prefix and mostly verb_noun snake_case names. Minor deviations include the plural in sieve_deactivate_scripts and the less standard verb in sieve_put_script, but the pattern remains highly readable.
Fifteen tools is well-scoped for a ManageSieve server covering accounts, scripts, validation, activation, and backups. Each tool has a clear role and no obvious filler.
The surface covers full account CRUD, full script lifecycle including list/read/check/create/replace/activate/deactivate/delete/rename, and backup listing/reading for restoration. No major operation needed for the stated domain appears missing.
Maintenance
Related MCP Connectors
Your mailbox for MCP clients: search, read, draft, send, rules and notes. Sending is off by default.
Your IMAP mailbox as an MCP server: read, search and (if you allow it) organize mail. Open source.
Hosted remote MCP for protected account access, permissions, activity history and supported undo.
Hosted email MCP for your own Gmail, Outlook.com, Microsoft 365, iCloud or IMAP inbox: read, search, draft, reply in thread, forward and file mail. It moves or flags up to 500 messages in one call, and a send leaves exactly one copy in Sent. A calendar is a separate connection, and connecting one adds diary and scheduling tools.
Related MCP Servers
- AlicenseAqualityCmaintenanceMCP server that gives Claude and other MCP hosts full access to Mail.app on macOS — search, read, send, reply, flag, move, and more across all accounts configured in Mail.app.24115 npm1MIT
- FlicenseNot gradedqualityCmaintenanceLocal IMAP/SMTP MCP server that lets Claude read, search, draft, send, flag, and move mail across multiple IMAP mailboxes. Credentials stay on your machine.-
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives Claude access to plain IMAP mailboxes, enabling reading, searching, moving, and forwarding emails with safety controls configured via config files.MIT
- AlicenseAqualityDmaintenanceMCP server to administer a Mailu mail server from Claude — domains, mailboxes, aliases and forwards.3212 npmMIT