Skip to main content
Glama
sieve-mcp-server

sieve-mcp-server

Official

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, and dryRun shows 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 build

Set 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 add

If 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.com

Other 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.js

Editing 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"
  • pull never overwrites a local file you've edited unless you pass --force.

  • push uses the file name as the script name; pass --name to 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.json

Accounts, with passwords AES-256-GCM encrypted

.key

Random 256-bit encryption key (owner-only permissions on macOS/Linux)

backups/<account id>/

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

sieve_list_accounts

Lists the configured accounts. Passwords are never shown.

sieve_add_account / sieve_update_account / sieve_remove_account

Manage accounts from the chat. The CLI is preferred for passwords.

sieve_get_capabilities

Shows the server's supported Sieve extensions. Also works as a connection test.

sieve_list_scripts

Lists the scripts on the server and which one is active.

sieve_get_script

Returns a script's source.

sieve_check_script

Has the server validate a script without saving it.

sieve_put_script

Creates or replaces a script, with validation, overwrite, dryRun and diff, and an automatic backup.

sieve_activate_script / sieve_deactivate_scripts

Sets which script filters incoming mail, or switches filtering off.

sieve_delete_script

Deletes an inactive script, after backing it up.

sieve_rename_script

Renames a script. If it was active, it stays active.

sieve_list_backups / sieve_get_backup

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. Use implicit for a port that speaks TLS from the first byte. Use none only on localhost or a trusted network.

  • Certificates are verified. Set allowInvalidCertificate only for a self-signed certificate you trust. The client sets verification explicitly, so a global NODE_TLS_REJECT_UNAUTHORIZED=0 does 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 --noEmit

The 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 tools
sieve_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

    A4.2/5.0

    Scored across 15 tools

    Disambiguation5/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness5/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      MCP 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.
      24
      115 npm
      1
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Local IMAP/SMTP MCP server that lets Claude read, search, draft, send, flag, and move mail across multiple IMAP mailboxes. Credentials stay on your machine.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      An 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
    • A
      license
      A
      quality
      D
      maintenance
      MCP server to administer a Mailu mail server from Claude — domains, mailboxes, aliases and forwards.
      32
      12 npm
      MIT