AI coding agents
Give Claude Code, Cursor, VS Code or Codex your app's traces over MCP with the agent's MCP server.
A coding agent such as Claude Code, Cursor, Codex or Copilot reads your code, but it can't see what the code does when it runs. It doesn't know how many queries a page makes, where the N+1 is or what failed. The Tracepanel agent runs an MCP server that gives the coding agent this information. The server answers from your project's traces. Each issue in its answers comes with its place in the code and a suggested fix.
The loop
With the server connected, the agent can check its own fix:
You ask "Why is /api/orders slow?" The agent calls find_traces to find the
request, then get_trace to read it. The trace has an N+1 with 50 queries at
shop/api.py:40. In this Django app, the fix is to add select_related().
The agent changes the code.
The agent calls wait_for_trace with a search such as route:/api/orders.
While it waits, it makes the request again with curl or a test.
The agent calls compare_traces on the two traces. It reads that the queries
dropped from 101 to 3, the time dropped from 31 ms to 4 ms, and the N+1 is
fixed.
The server tells the agent this loop when it connects, so you don't have to.
Profiles
The same loop works for code that is slow or uses too much memory, with no query to blame:
The agent makes the request with an X-Tracepanel-Profile: 1 header, or
X-Tracepanel-Profile: memory to count its memory too. It calls
wait_for_trace to get the trace. The trace starts with a line such as
profiled: cpu, memory (by a request header) → get_profile. The part in
brackets says why it was profiled, when the app's SDK says so.
The agent calls get_profile. The answer lists the functions by their own
time and by their time in all, then the hottest paths, such as
sales (reports/views.py:24) → build_cards (reports/cards.py:40), the time
of the libraries a function called counted to it, as in the Profile tab's
Your code. Its time by share is the time strip's, written as the console
writes it, such as External calls 28 ms (80%) · Not profiled 3 ms (9%) · Framework & middleware 3 ms (8%) · GC 1 ms (3%).
With kind: memory, it gives the peak and the allocation sites, each with the
line of your code that led to it.
The agent fixes the code, profiles the request again and calls
compare_traces. It reads lines such as
build_cards (reports/cards.py:40): 135 ms → 0.4 ms and
memory: peak 66 MB → 13 KB.
The answers say what the numbers can't tell. They name the time the profiler
didn't sample and the time the code waited rather than computed, such as an
asyncio.sleep, and say when a profile's times are approximate, as a Go
profile's CPU time on macOS is. They also say that counting memory slows the code down, so
compare times between traces profiled without it. A trace with no profile gets
an answer that says how to record one. The profile setting and the panel's
Profile button profile requests too. See Profile.
Connect it
The MCP server is part of the agent. It runs from your project's directory,
because it reads the traces in .tracepanel/ there:
tracepanel-agent mcp [--dir DIR] [--values]--dir names the store directory when it isn't .tracepanel. --values is
described in What the model sees. Add the server to
your coding agent:
claude mcp add --scope project tracepanel -- tracepanel-agent mcpThe coding agent must find tracepanel-agent on its PATH. If it can't,
give the full path to the program.
In the Python SDK
The tracepanel package installs tracepanel-agent into your virtualenv.
It also offers tracepanel mcp, which runs the same server. It passes the
store directory from the project's settings as --dir. With uv, use
uv run tracepanel mcp as the command:
claude mcp add --scope project tracepanel -- uv run tracepanel mcpWithout uv, run it from the project's virtualenv, as in
.venv/bin/tracepanel mcp. See Command line.
In the JavaScript SDK
@tracepanel/js installs the agent into node_modules, off the PATH. Use
npx @tracepanel/js mcp, which runs the same server with the project's
store, as the command:
claude mcp add --scope project tracepanel -- npx @tracepanel/js mcpIn a JSON config, that is "command": "npx" with "args": ["@tracepanel/js", "mcp"]. See Command line.
In the Go SDK
The Go SDK keeps the agent it downloads in the user's cache, off the
PATH. Its tracepanel command runs the same server with the project's
store. Install it, and use it as the command from the project's directory:
go install github.com/tracepanel/tracepanel-go/cmd/tracepanel@v0.17.0
claude mcp add --scope project tracepanel -- tracepanel mcpIn a JSON config, that is "command": "tracepanel" with "args": ["mcp"].
Without installing it, go run github.com/tracepanel/tracepanel-go/cmd/tracepanel@v0.17.0 mcp does the
same. See Command line.
Then run your app as usual with Tracepanel on, and ask the agent. Before the app records its first trace, the tools answer that there are no traces yet.
Tools
Every tool only reads. A search takes free text and filters, as in the
console. Examples are route:/api/* status>=500,
has:n+1 duration>200ms and kind:task state:FAILURE since:1h.
| Tool | Parameters | What it returns |
|---|---|---|
find_traces | query, limit up to 50, default 10 | Recent requests, tasks and commands, newest first. Each line has the trace's id, its time, its SQL count and SQL time, as the console's header writes them, such as 88 ms · 3 SQL (25 ms), what queries that ran side by side add up to apart, such as 74 SQL (54 ms · 57 ms added up), and the kinds of its issues. |
get_trace | id, focus | One trace: its issues with their place in the code and a suggested fix, the error with its stack, the call tree with repeats folded, warnings, dumps with their values, related tasks, and whether it was profiled. A trace that called other apps also gets the traces down its calls, their warnings and errors, which of them were profiled, an N+1 across apps with its hint, and the hosts it called that send no traces. |
get_profile | id, kind (cpu, the default, or memory), top up to 50, default 10, chain (default true) | A profiled trace's profile as text. For cpu: what it covers of the trace's time, its time by share as the time strip splits it, Not profiled among them, the functions by their own time and in all, the hottest paths with their files and lines, the time spent waiting and the time not sampled. For memory: the peak, what the trace kept and the largest allocation sites. Then the profiles of the traces down its calls, one section per app, an app's traces added up. chain: false gives the trace's own profile only. |
wait_for_trace | query, after, timeout_s up to 120, default 30 | The next trace that matches, recorded after the trace after or after the call. It returns the trace as get_trace does. |
compare_traces | before, after | What changed between two traces: time, SQL count and SQL time, status, the issues fixed and the new ones. When both were profiled, also the functions whose own time changed most, and the memory's peak and allocation sites. It compares the two traces' own profiles: when their chains have profiles too, it says so, and get_profile reads them. |
list_issues | query, limit up to 100, default 20 | The project's issues, one per place in the code, most recent first. Each has its place, a suggested fix, how often it happened, its endpoints and its fingerprint. |
get_issue | fingerprint | One issue in detail, when it was first seen, and its latest traces. |
list_endpoints | query, limit up to 100, default 20 | HTTP endpoints, busiest first: calls, p50 and p95 time, average SQL per call, errors and traces with issues. |
list_calls | query, limit up to 100, default 20 | Calls to databases, Redis, caches, HTTP services and other systems across all traces, grouped by statement or operation, heaviest first: how often each runs, the most per trace, the total and slowest time, its place in the code, a sample trace and the call: filter that finds its traces. A search such as system:sql op:select or system:redis failed:true narrows them. With trace, and system, span, only and chain, a trace's calls and those of the traces down its calls, by statement with how many traces ran each, added up. |
search_logs | query, limit up to 200, default 50 | Log records, newest first, with their level, logger and trace. A dump comes with its call site and its values. A search such as level>=warning logger:app.* or has:dump narrows them. With trace, and span, only and chain, a trace's records and those of the traces down its calls in time order, each with its app, added up by level and app. |
get_trace takes a focus:
issues, the default, shows the branches of the call tree with issues, errors and most of the time.treeshows the whole call tree.sqlshows every statement, grouped.logsshows every log record.
The tree folds repeats into one line, such as SELECT auth_user ×50, and says
how much it left out. An answer stays under about 4,000 tokens. A longer one
ends with a note on how much was cut and asks for a narrower search or focus.
While the Tracepanel agent serves the console, get_trace and
wait_for_trace end with a link to the trace in the console. You can open the
same trace that the coding agent read.
What the model sees
An agent sends its tool answers to its model's provider. So by default, the
answers leave out the values in your data. SQL comes without its parameters,
as in WHERE id = %s, and errors come without their local variables. The
answers do include log messages, dumps with their values, paths and the names
of views and tasks.
--values adds SQL parameters and local variables. Values under
names that look like secrets, such as passwords, tokens and keys, stay masked
with or without --values.
claude mcp add --scope project tracepanel -- tracepanel-agent mcp --values