Add multi-account support, HTML default, EMAIL_HTML_SIGNATURE with template, and signature templates
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
.env
|
||||||
@@ -3,16 +3,15 @@
|
|||||||
A Dockerized MCP (Model Context Protocol) email assistant for law firms and legal teams.
|
A Dockerized MCP (Model Context Protocol) email assistant for law firms and legal teams.
|
||||||
|
|
||||||
Integrates:
|
Integrates:
|
||||||
- IMAP/SMTP email operations
|
- Multiple IMAP/SMTP email accounts
|
||||||
- Shared/public folder support
|
- Shared/public folder support
|
||||||
- New-message tracking and flagging
|
- New-message tracking and flagging
|
||||||
- Conflict check search
|
- Conflict check search
|
||||||
- CalDAV/CardDAV (e.g., Nextcloud) for calendar and contacts
|
|
||||||
- Triage guidance using personnel/chain-of-command
|
- Triage guidance using personnel/chain-of-command
|
||||||
|
|
||||||
Designed to be consumed by LLMs via MCP (Streamable HTTP) in Open WebUI.
|
Designed to be consumed by LLMs via MCP (Streamable HTTP) in Open WebUI.
|
||||||
|
|
||||||
## Quick start
|
## Quick start (single account)
|
||||||
|
|
||||||
1. Build:
|
1. Build:
|
||||||
|
|
||||||
@@ -59,6 +58,90 @@ Designed to be consumed by LLMs via MCP (Streamable HTTP) in Open WebUI.
|
|||||||
- Key: your_api_key_here
|
- Key: your_api_key_here
|
||||||
- Save, then enable tools in a chat.
|
- 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
|
## Environment variables
|
||||||
|
|
||||||
See env.example for a full list.
|
See env.example for a full list.
|
||||||
@@ -73,7 +156,7 @@ Core:
|
|||||||
- LOG_LEVEL:
|
- LOG_LEVEL:
|
||||||
- e.g., INFO, DEBUG, ERROR (default: INFO)
|
- 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_HOST
|
||||||
- IMAP_PORT
|
- IMAP_PORT
|
||||||
@@ -81,7 +164,7 @@ IMAP (incoming mail):
|
|||||||
- IMAP_USERNAME
|
- IMAP_USERNAME
|
||||||
- IMAP_PASSWORD
|
- IMAP_PASSWORD
|
||||||
|
|
||||||
SMTP (outgoing mail):
|
Single-account SMTP:
|
||||||
|
|
||||||
- SMTP_HOST
|
- SMTP_HOST
|
||||||
- SMTP_PORT
|
- SMTP_PORT
|
||||||
@@ -114,17 +197,27 @@ Optional email:
|
|||||||
]
|
]
|
||||||
- SCHEDULED_SEND_INTERVAL: Seconds between checks for scheduled emails (default: 10).
|
- 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)
|
- Emails (send_email, reply_to_message, forward_message, schedule_send) default to HTML (html=true) unless explicitly set to false.
|
||||||
- DAV_USERNAME
|
- EMAIL_HTML_SIGNATURE: Optional HTML signature appended to HTML emails.
|
||||||
- DAV_PASSWORD
|
- Inline HTML example:
|
||||||
- DAV_VERIFY_TLS: true/false (default: true)
|
-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
|
## MCP tools
|
||||||
|
|
||||||
All tools are exposed via MCP (Streamable HTTP) at POST /mcp.
|
All tools are exposed via MCP (Streamable HTTP) at POST /mcp.
|
||||||
|
|
||||||
|
General:
|
||||||
|
|
||||||
|
- list_accounts
|
||||||
|
|
||||||
Email:
|
Email:
|
||||||
|
|
||||||
- list_folders
|
- list_folders
|
||||||
@@ -151,24 +244,7 @@ Email:
|
|||||||
- conflict_check_search
|
- conflict_check_search
|
||||||
- get_triage_config
|
- get_triage_config
|
||||||
|
|
||||||
Contacts (CardDAV):
|
Notes:
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- IMAP operations use UIDs for stability.
|
- IMAP operations use UIDs for stability.
|
||||||
- Conflict check search scans subject lines across specified folders for given terms.
|
- Conflict check search scans subject lines across specified folders for given terms.
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<table style="font-family: 'Times New Roman', Times, serif; background-color: #ffffff;" border="0" width="577" cellspacing="0" cellpadding="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
<br />
|
||||||
|
<p style="text-align: center;">
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
<strong style="font-weight: bolder;">Adam P. Strömbergsson-DeNora</strong>
|
||||||
|
</span>
|
||||||
|
<br />
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
Barrister & Solicitor<br />
|
||||||
|
LSO, LSY, LSN
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td valign="top">
|
||||||
|
<table border="0" width="100%" cellspacing="0" cellpadding="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
7th floor - 1 Rideau St. Ottawa, ON. K1N 8S7
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
<strong style="font-weight: bolder;">T:</strong> 1 613 699 2127
|
||||||
|
</span>
|
||||||
|
<br />
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
<strong style="font-weight: bolder;">E:</strong>
|
||||||
|
<a style="color: #00acff; background-color: transparent;" href="mailto:adam@apstrom.ca" rel="noreferrer">
|
||||||
|
adam@apstrom.ca
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
A.P. Ström & Associates
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
<a style="color: #00acff; background-color: transparent;" href="http://apstrom.ca/" rel="noopener noreferrer">
|
||||||
|
<strong style="font-weight: bolder;">apstrom.ca</strong>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<br />
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
This e-mail message may contain PRIVILEGED and CONFIDENTIAL information and thus may be intended only for the use of the specific individual or individuals to which it is addressed. If you are not an intended recipient of this e-mail, you know that any unauthorized use, dissemination or copying of this e-mail or the information contained herein or attached hereto is strictly prohibited. If you receive this e-mail in error, notify the person named above by reply e-mail and please delete this message and any attachments. Thank you.
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<table style="font-family: 'Times New Roman', Times, serif; background-color: #ffffff;" border="0" width="577" cellspacing="0" cellpadding="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
<br />
|
||||||
|
<p style="text-align: center;">
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
<strong style="font-weight: bolder;">{{NAME}}</strong>
|
||||||
|
</span>
|
||||||
|
<br />
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
{{TITLE}}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td valign="top">
|
||||||
|
<table border="0" width="100%" cellspacing="0" cellpadding="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
{{ADDRESS}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
<strong style="font-weight: bolder;">T:</strong> {{PHONE}}
|
||||||
|
</span>
|
||||||
|
<br />
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
<strong style="font-weight: bolder;">E:</strong>
|
||||||
|
<a style="color: #00acff; background-color: transparent;" href="mailto:{{EMAIL}}">
|
||||||
|
{{EMAIL}}
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<br />
|
||||||
|
<span style="font-family: 'Times New Roman', Times, serif;">
|
||||||
|
This e-mail message may contain PRIVILEGED and CONFIDENTIAL information and thus may be intended only for the use of the specific individual or individuals to which it is addressed. If you are not an intended recipient of this e-mail, you know that any unauthorized use, dissemination or copying of this e-mail or the information contained herein or attached hereto is strictly prohibited. If you receive this e-mail in error, notify the person named above by reply e-mail and please delete this message and any attachments. Thank you.
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
Reference in New Issue
Block a user