postsleuth
<p align="center"><img src="assets/logo.svg" width="72" alt="postsleuth logo"></p>
# postsleuth
**Why isn't Postfix delivering?** postsleuth reads the queue (`postqueue -j`), the mail log and DNS, groups every stuck message by *why* it is stuck, and tells you what to do next. It works as a CLI and as an MCP server, so an AI agent can investigate a mail server without being able to touch it.

<sub>Demo uses generated snapshot data (`testdata/gen.py`) via `--queue-file` / `--log`.</sub>
## Install
```sh
go install github.com/Blackman99/postsleuth/cmd/postsleuth@latest
```
or grab a binary for Linux, macOS or Windows from [Releases](https://github.com/Blackman99/postsleuth/releases/latest).
## Use
```sh
postsleuth doctor # queue + qshape + log + SPF/DKIM/DMARC/PTR, with next steps
postsleuth queue --domain .outlook.com
postsleuth shape --by sender # who filled the deferred queue
postsleuth trend --domain gmail.com # deferral rate over time — getting better?
postsleuth trace bob@example.org # one message, start to finish
postsleuth dns example.com --ip 203.0.113.7
```
Postfix in a container or on another box: `--wrap "docker exec -i mailserver"` or run it over `ssh`.
## MCP
```json
{"mcpServers": {"postsleuth": {"command": "postsleuth", "args": ["mcp"]}}}
```
All tools are read-only. Requeue, flush, hold and delete exist only when the server is started with `--allow-mutations`, and each call still needs `confirm: true`.
**[Docs](https://blackman99.github.io/postsleuth/docs/)** · [Website](https://blackman99.github.io/postsleuth/) · [Goal](GOAL.md) · [Roadmap](ROADMAP.md) · MIT
TDQS
Scored across 10 tools
Most tools target distinct facets: queue_summary (counts), queue_shape (age matrix), queue_list (individual messages), log_stats (aggregate outcomes), log_trace (single-message), log_trend (per-destination trend), and mail_dns_check. The main overlap is that postfix_doctor is a one-call aggregate that duplicates much of queue_summary/log_stats/DNS, and log_stats vs log_trend share a time-window log surface, but descriptions make the boundaries workable.
Nine tools follow a consistent snake_case postfix_<subject>_<aspect> pattern (queue_list, log_trace, log_stats, reason_categories, etc.). Only mail_dns_check breaks the prefix, though it retains the same snake_case verb_noun style, making it a minor deviation rather than an inconsistency.
Ten tools is a well-scoped count for a Postfix diagnostics server, with each tool covering a distinct grain of analysis (DNS, config, queue, logs, categories, plus a doctor aggregate). No tool feels redundant padding.
The surface covers the key diagnostic lifecycle well: DNS/auth checks, config inspection, queue views at three grains, log aggregation/trace/trend, and failure categorization. The notable gap is that everything is read-only — no remediation actions such as queue flush, requeue, or delete — which an operator would likely want next.