Files
mcp-email/README.md
T

3.6 KiB

MCP Email Server

A Dockerized, OpenAPI-based MCP email assistant for law firms and legal teams.

Integrates:

  • IMAP/SMTP email operations
  • 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 OpenAPI tool servers (e.g., Open WebUI).

Quick start

  1. Build:

    docker build -t mcp-email-server /home/user/wall-o/mcp-email-server

  2. Run (example):

    docker run -d
    -p 8000:8000
    -e IMAP_HOST=imap.example.com
    -e IMAP_PORT=993
    -e IMAP_USE_SSL=true
    -e IMAP_USERNAME="user@example.com"
    -e IMAP_PASSWORD="secret"
    -e SMTP_HOST=smtp.example.com
    -e SMTP_PORT=587
    -e SMTP_USE_TLS=true
    -e SMTP_USE_SSL=false
    -e SMTP_USERNAME="user@example.com"
    -e SMTP_PASSWORD="secret"
    -e SMTP_FROM="user@example.com"
    -e DEFAULT_CC="supervisor@example.com"
    -e BUSINESS_DESCRIPTION="A law firm handling corporate and litigation matters."
    -e PERSONNEL_JSON='[{"name":"Jane Doe","role":"Managing Partner","email":"jane@example.com","escalates_to":null},{"name":"John Smith","role":"Associate","email":"john@example.com","escalates_to":"Jane Doe"}]'
    mcp-email-server

  3. OpenAPI spec:

    http://localhost:8000/openapi.json

  4. Integrate with Open WebUI (OpenAPI tool server):

    • Admin Settings → External Tools → Add Server
    • Type: OpenAPI
    • URL: http://:8000/openapi.json

Environment variables

Required for email:

  • IMAP_HOST

  • IMAP_PORT

  • IMAP_USE_SSL

  • IMAP_USERNAME

  • IMAP_PASSWORD

  • SMTP_HOST

  • SMTP_PORT

  • SMTP_USE_TLS

  • SMTP_USE_SSL

  • SMTP_USERNAME

  • SMTP_PASSWORD

  • SMTP_FROM

Optional email:

  • DEFAULT_CC: Comma-separated CC addresses.
  • DEFAULT_BCC: Comma-separated BCC addresses.
  • BUSINESS_DESCRIPTION: Context for the LLM (e.g., firm description).
  • PERSONNEL_JSON: JSON array of personnel/chain-of-command:
    • Example: [ { "name": "Jane Doe", "role": "Managing Partner", "email": "jane@example.com", "escalates_to": null }, { "name": "John Smith", "role": "Associate", "email": "john@example.com", "escalates_to": "Jane Doe" } ]
  • SCHEDULED_SEND_INTERVAL: Seconds between checks for scheduled emails (default: 10).

CalDAV/CardDAV (e.g., Nextcloud):

Logging:

  • LOG_LEVEL: e.g., INFO, DEBUG, ERROR (default: INFO)

Tools (OpenAPI endpoints)

All endpoints are POST and return JSON.

Email:

  • /list_folders
  • /search_messages
  • /get_new_messages
  • /sync_seen
  • /mark_as_read
  • /flag_message
  • /move_message
  • /copy_message
  • /apply_label
  • /remove_label
  • /list_labels
  • /get_unread_summary
  • /send_email
  • /reply_to_message
  • /forward_message
  • /save_draft
  • /list_attachments
  • /download_attachment
  • /search_attachments
  • /schedule_send
  • /export_conversation
  • /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

  • IMAP operations use UIDs for stability.
  • Conflict check search scans subject lines across specified folders for given terms.
  • New-message tracking is in-memory per container instance.