Quick start¶
You need a running MailFlow 4.3 or later (personal API tokens), Docker Compose, and a reverse proxy with HTTPS. Two containers join MailFlow's network: mailflow-mcp, and Sesamcp as the sign-in in front of it.
flowchart TD
C[MCP client] -->|HTTPS| R[Reverse proxy]
subgraph N["MailFlow's Docker network"]
S[Sesamcp] -->|MCP calls| M[mailflow-mcp]
M -->|API calls| B[MailFlow backend]
S -->|tries the token| B
end
R -->|port 8081| S
Only Sesamcp is reachable from outside; mailflow-mcp publishes no port.
1. The sign-in's configuration¶
Save as sesamcp.yaml:
service_name: MailFlow
upstream: http://mailflow-mcp:8082/mcp
fields:
- {name: token, label: API token, type: password, required: true}
login:
verify:
request:
url: http://mailflow-backend:3000/api/api-tokens/self
headers: {Authorization: "Bearer {token}"}
upstream_headers: {Authorization: "Bearer {token}"}
health: http://mailflow-mcp:8082/health
Keep login.verify, and leave static_tokens out
mailflow-mcp answers initialize to anyone, so login.upstream would let any text in. With static_tokens, a token Sesamcp did not issue would be passed on to MailFlow: the client looks connected, every call fails, and it never asks for a sign-in.
2. The containers¶
services:
mailflow-mcp:
image: ghcr.io/marceltov/mailflow-mcp:latest
restart: unless-stopped
environment:
MAILFLOW_URL: http://mailflow-backend:3000
MAILFLOW_PUBLIC_URL: https://mail.example.org
mailflow-mcp-login:
image: ghcr.io/marceltov/sesamcp:latest
restart: unless-stopped
environment:
MCP_BASE_URL: https://mailflow-mcp.example.org
MCP_OAUTH_SECRET: ${MCP_OAUTH_SECRET} # openssl rand -hex 32
# MCP_PROXY_HOPS: "2" # reverse proxies in front, when more than one
volumes:
- ./sesamcp.yaml:/config/sesamcp.yaml:ro
- mcp-login:/data
ports:
- "8081:8081"
volumes:
mcp-login:
Put both on the network MailFlow's backend is on, and point your reverse proxy for mailflow-mcp.example.org at port 8081. The environment variables are in Configuration.
3. Check it¶
curl https://mailflow-mcp.example.org/health
curl -i -X POST https://mailflow-mcp.example.org/mcp
The first answers that the service and its upstream are fine, the second 401. Then connect a client.