Add multi-account support, HTML default, EMAIL_HTML_SIGNATURE with template, and signature templates

This commit is contained in:
Admin
2026-06-25 04:41:38 +00:00
parent 1336178abc
commit 12e72ac891
5 changed files with 732 additions and 739 deletions
+104 -28
View File
@@ -3,16 +3,15 @@
A Dockerized MCP (Model Context Protocol) email assistant for law firms and legal teams.
Integrates:
- IMAP/SMTP email operations
- Multiple IMAP/SMTP email accounts
- Shared/public folder support
- New-message tracking and flagging
- Conflict check search
- CalDAV/CardDAV (e.g., Nextcloud) for calendar and contacts
- Triage guidance using personnel/chain-of-command
Designed to be consumed by LLMs via MCP (Streamable HTTP) in Open WebUI.
## Quick start
## Quick start (single account)
1. Build:
@@ -59,6 +58,90 @@ Designed to be consumed by LLMs via MCP (Streamable HTTP) in Open WebUI.
- Key: your_api_key_here
- Save, then enable tools in a chat.
## Multi-account configuration
The server can manage multiple IMAP/SMTP accounts. Tools accept an optional "account" parameter; if omitted, the default account is used.
You have two main options:
1) Inline JSON (ACCOUNTS_JSON)
Set ACCOUNTS_JSON with a JSON array of accounts.
Copy-paste template (single line, for docker run):
-e ACCOUNTS_JSON='[{"id":"account1","name":"Primary Firm Inbox","imap_host":"imap.primary.com","imap_port":993,"imap_use_ssl":true,"imap_username":"user@primary.com","imap_password":"CHANGE_ME_1","smtp_host":"smtp.primary.com","smtp_port":587,"smtp_use_tls":true,"smtp_use_ssl":false,"smtp_username":"user@primary.com","smtp_password":"CHANGE_ME_1","smtp_from":"user@primary.com"},{"id":"account2","name":"Secondary Inbox","imap_host":"imap.secondary.com","imap_port":993,"imap_use_ssl":true,"imap_username":"user@secondary.com","imap_password":"CHANGE_ME_2","smtp_host":"smtp.secondary.com","smtp_port":587,"smtp_use_tls":true,"smtp_use_ssl":false,"smtp_username":"user@secondary.com","smtp_password":"CHANGE_ME_2","smtp_from":"user@secondary.com"}]'
Human-readable equivalent (for reference):
ACCOUNTS_JSON='[
{
"id": "account1",
"name": "Primary Firm Inbox",
"imap_host": "imap.primary.com",
"imap_port": 993,
"imap_use_ssl": true,
"imap_username": "user@primary.com",
"imap_password": "CHANGE_ME_1",
"smtp_host": "smtp.primary.com",
"smtp_port": 587,
"smtp_use_tls": true,
"smtp_use_ssl": false,
"smtp_username": "user@primary.com",
"smtp_password": "CHANGE_ME_1",
"smtp_from": "user@primary.com"
},
{
"id": "account2",
"name": "Secondary Inbox",
"imap_host": "imap.secondary.com",
"imap_port": 993,
"imap_use_ssl": true,
"imap_username": "user@secondary.com",
"imap_password": "CHANGE_ME_2",
"smtp_host": "smtp.secondary.com",
"smtp_port": 587,
"smtp_use_tls": true,
"smtp_use_ssl": false,
"smtp_username": "user@secondary.com",
"smtp_password": "CHANGE_ME_2",
"smtp_from": "user@secondary.com"
}
]'
2) JSON file (ACCOUNTS_CONFIG_PATH)
Mount a JSON file and set ACCOUNTS_CONFIG_PATH. Example:
docker run -d \
-p 8000:8000 \
-v /path/to/accounts.json:/etc/mcp-email/accounts.json:ro \
-e API_KEY="your_api_key_here" \
-e ACCOUNTS_CONFIG_PATH="/etc/mcp-email/accounts.json" \
mcp-email-server
Use the same structure as ACCOUNTS_JSON.
Default account:
- Use DEFAULT_ACCOUNT="firm_main" to set the default.
- If not set:
- If only one account exists, it is default.
- Otherwise, an account with id "default" is preferred, or the first one is used.
Tool usage with multiple accounts:
- Most tools accept an "account" field. Examples:
- list_folders: { "account": "firm_main" }
- search_messages: { "account": "secondary", "folder": "INBOX", "query": "conflict" }
- send_email: { "account": "firm_main", "to": ["client@example.com"], "subject": "...", "body": "..." }
- If "account" is omitted, the default account is used.
A new tool is available:
- list_accounts:
- Lists all configured accounts and shows which is default.
## Environment variables
See env.example for a full list.
@@ -73,7 +156,7 @@ Core:
- LOG_LEVEL:
- e.g., INFO, DEBUG, ERROR (default: INFO)
IMAP (incoming mail):
Single-account IMAP (only if not using ACCOUNTS_JSON/ACCOUNTS_CONFIG_PATH):
- IMAP_HOST
- IMAP_PORT
@@ -81,7 +164,7 @@ IMAP (incoming mail):
- IMAP_USERNAME
- IMAP_PASSWORD
SMTP (outgoing mail):
Single-account SMTP:
- SMTP_HOST
- SMTP_PORT
@@ -114,17 +197,27 @@ Optional email:
]
- SCHEDULED_SEND_INTERVAL: Seconds between checks for scheduled emails (default: 10).
CalDAV/CardDAV (e.g., Nextcloud):
HTML and signature:
- DAV_BASE_URL: Base DAV URL (e.g., https://cloud.example.com/remote.php/dav)
- DAV_USERNAME
- DAV_PASSWORD
- DAV_VERIFY_TLS: true/false (default: true)
- Emails (send_email, reply_to_message, forward_message, schedule_send) default to HTML (html=true) unless explicitly set to false.
- EMAIL_HTML_SIGNATURE: Optional HTML signature appended to HTML emails.
- Inline HTML example:
-e EMAIL_HTML_SIGNATURE='<div style="font-size:12px;">Best regards,<br>Jane Doe<br>Associate</div>'
- Template file example:
- Mount the file:
-v /path/to/signature.html:/etc/mcp-email/signature.html:ro
- Set env:
-e EMAIL_HTML_SIGNATURE='/etc/mcp-email/signature.html'
If the value is an existing file path, its contents are used as the signature.
## MCP tools
All tools are exposed via MCP (Streamable HTTP) at POST /mcp.
General:
- list_accounts
Email:
- list_folders
@@ -151,24 +244,7 @@ Email:
- conflict_check_search
- get_triage_config
Contacts (CardDAV):
- list_carddav_addressbooks
- search_carddav_contacts
- get_carddav_contact
- create_carddav_contact
- update_carddav_contact
- delete_carddav_contact
Calendar (CalDAV):
- list_caldav_calendars
- search_caldav_events
- create_caldav_event
- update_caldav_event
- delete_caldav_event
## Notes
Notes:
- IMAP operations use UIDs for stability.
- Conflict check search scans subject lines across specified folders for given terms.