Zero-config SQL flight recorder for slow Python/SQLAlchemy jobs: exact call site, count, and fix.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
A zero-config recorder that answers "why did this Python batch job take so long?"
Run it from your shell β or as an MCP server an AI agent invokes directly.
A query can be individually fast β 0.4ms β and still sink your job, because it's
called 500,000 times from a single line of code. Your app burns 300 seconds on
round-trips while Postgres itself only worked for 80. Every profiler you've tried shows
you "time spent in psycopg" and stops there.
wherewent shows you the calling pattern. It groups queries by shape, counts how
often each shape ran, sums the wall time, and points at the exact file:line in your
code that fired it β then tells you, in plain English with the arithmetic shown, what to
do about it.
| Sampling profilers | APM / tracing | wherewent | |
|---|---|---|---|
| Zero code changes | β | β | β |
| Groups queries by shape | β | β οΈ | β |
| Blames your call site | β οΈ | β οΈ | β |
| Tells you the fix | β | β | β |
| Runs anywhere, no server | β | β | β |
| Works on a Ctrl-C'd partial run | β | β οΈ | β |
That's it β the recorder is pure standard library. You only need SQLAlchemy because your job already uses it.
Wrap any command. Your script runs completely unmodified β no imports, no decorators, no config:
SIGUSR1 (kill -USR1 <pid>) for a partial snapshot mid-run,
or run with WHEREWENT_INTERVAL=30 to print one every 30s. The job keeps going.AsyncSession / AsyncConnection).wherewent ships a Model Context Protocol (MCP) server, so
an AI agent can invoke it directly the moment a job is slow and get back machine-readable findings
β instead of reading raw query logs and reasoning its way to the same conclusion. It is listed in
the official MCP Registry as
io.github.habibafaisal/wherewent.
Install with the [mcp] extra (this pulls in the MCP SDK; the core recorder stays pure-stdlib)
and run the stdio server:
Transport: stdio. Tools exposed:
| MCP tool | What it does |
|---|---|
analyze_job(command, unit_function?, timeout_s=600) | Run a Python/SQLAlchemy job under wherewent and return why it was slow β exact call site, query count, and fix as structured fields. On timeout, partial results are returned (timed_out: true). |
explain_run(path) | Return the enriched findings from a JSON file already produced by wherewent run --save β no re-run. |
Each finding carries fix, call_site, calls, wall_fraction, and an evidence object an
agent can act on and cite. Wire it into any MCP client (e.g. Claude Desktop) via config:
A Dockerfile at the repo root builds this same stdio server for container-based MCP hosts.
"81,749 queries" is hard to judge. "135 queries per receivable" tells an engineer instantly that the architecture is chatty. Name the unit your job processes and wherewent reports the economics of one β median duration, queries/commits/rows per unit, and how the cost trends as the run progresses:
R6 fires on either slope. That matters for a compute-bound job: if the clock stays flat but
queries/unit climbs, the duration trend reads flat and only the query trend exposes the problem β
so wherewent reports both and says plainly that the pattern is a scalability risk rather than the
current wall-clock bottleneck.
The growth trend is why a sampled run is honest: it shows cost-per-unit rising, so you know the full run will be worse than a linear extrapolation β the thing a totals-only profiler can never tell you. Per-unit counts are exact even under concurrent async units; nothing but shapes and counts is ever recorded.
PYTHONPATH sitecustomize shim β no
changes to your code, no wrapper imports.event.listen(sqlalchemy.engine.Engine, ...) β so
every engine your app creates is captured automatically, config-free.IN-lists
and multi-row VALUES collapse, so a million distinct inserts become one honest row.No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/wherewent)<a href="https://allmcps.com/mcp/wherewent"><img src="https://allmcps.com/api/badge/wherewent?style=directory" alt="Wherewent on AllMCPs" /></a>