MCP server for dataxplan: read PostgreSQL EXPLAIN plans for AI agents (bottlenecks, estimation errors, fixes, charts).
Project description
dataxplan-mcp
An MCP server that exposes dataxplan,
the PostgreSQL EXPLAIN-plan analyzer for Python, as tools for AI agents: give it
the output of EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) and it returns the
bottlenecks, the estimation errors, documented findings with a suggested action
and a source reference, a regression comparison, and a self-time chart.
Agents asked why a query is slow tend to eyeball the plan and get it wrong: self time is per loop and inclusive of children, so the slow node is rarely the obvious one, and a row mis-estimate (the usual root cause) is buried in the output. Reading the plan belongs in a deterministic, versioned library that the agent calls, which leaves the agent to interpret the result and decide. The server never connects to a database: the agent runs EXPLAIN and passes the output, so nothing leaves its environment.
Tools
Analysis tools return dataxplan's payload: the metrics, the findings (each with a severity, a suggestion and a documented source reference) and a summary.
| Tool | Purpose |
|---|---|
analyze_plan |
bottlenecks, estimation errors and findings from an EXPLAIN plan (JSON, text, YAML or XML) |
compare_plans |
compare two plans for regression (timing, shape, estimates, findings) |
plan_tree |
the plan as an annotated text tree (self time, rows, flags per node) |
describe_inputs |
how to produce the plan, the accepted formats, the findings and the thresholds |
Chart tools return a PNG image.
| Tool | Purpose |
|---|---|
plan_chart |
self time per node, with the high-severity findings highlighted |
All tools are read-only, and the server makes no database connection.
Installation
Run it with uv (no install needed):
uvx dataxplan-mcp
or install from PyPI:
pip install dataxplan-mcp
Configuration
Add it to your MCP client. For example:
{
"mcpServers": {
"dataxplan": {
"command": "uvx",
"args": ["dataxplan-mcp"]
}
}
}
If you installed with pip, use "command": "dataxplan-mcp" with no args.
Example
analyze_plan(plan="<EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) output>")
-> { "summary_metrics": { "execution_time_ms": 1240.0,
"max_estimation_error": 20000, ... },
"findings": [ { "id": "seq_scan_hot", "severity": "high",
"detail": "... 95% of execution time ...",
"suggestion": "consider an index ...",
"reference": "PostgreSQL: Using EXPLAIN; the Indexes chapter" } ],
"summary": "dataxplan - ...\n execution time ..." }
The agent runs the EXPLAIN itself and pastes the output (any format) as plan.
Design
The server is a thin, stateless wrapper. All of the analysis lives in the dataxplan library, which computes the metrics from the documented EXPLAIN fields and grounds each finding in the PostgreSQL manual (and Leis et al. 2015 for the estimation rules). The server adds the tool schema, read-only annotations and an input-schema helper so an agent can format the input and act on the result. The findings are documented heuristics, not guarantees, and the server connects to nothing.
Related
- dataxplan: the library this server wraps.
License
MIT. Written and maintained by Atakan Arikan, MSc Student at Tsinghua University and Politecnico di Milano.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dataxplan_mcp-0.1.0.tar.gz.
File metadata
- Download URL: dataxplan_mcp-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20eb875e7dfa68dc7c4986400f23e6cddc10eaca3067dc48e15e171fa43f9892
|
|
| MD5 |
3e14c9902884ed9148757dab9ee04067
|
|
| BLAKE2b-256 |
b737a3d8888d16bbeea4a396ea281006191f3787bce6bf379864aeb8b558b934
|
Provenance
The following attestation bundles were made for dataxplan_mcp-0.1.0.tar.gz:
Publisher:
release.yml on arikanatakan/dataxplan-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dataxplan_mcp-0.1.0.tar.gz -
Subject digest:
20eb875e7dfa68dc7c4986400f23e6cddc10eaca3067dc48e15e171fa43f9892 - Sigstore transparency entry: 1845384574
- Sigstore integration time:
-
Permalink:
arikanatakan/dataxplan-mcp@8391886755e09f79c546d6c6e4ac41602ca4098e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/arikanatakan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8391886755e09f79c546d6c6e4ac41602ca4098e -
Trigger Event:
push
-
Statement type:
File details
Details for the file dataxplan_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dataxplan_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
970f0329290d9838aa6fd1a8e2fc76deed107cc1eec593f99961b68ad06e3462
|
|
| MD5 |
a13cedba34125841380a348cfbfb6088
|
|
| BLAKE2b-256 |
5c65112dab68deb87c5c5ec42f06f5c60df76d9de23305c56fc83cbb09a2715c
|
Provenance
The following attestation bundles were made for dataxplan_mcp-0.1.0-py3-none-any.whl:
Publisher:
release.yml on arikanatakan/dataxplan-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dataxplan_mcp-0.1.0-py3-none-any.whl -
Subject digest:
970f0329290d9838aa6fd1a8e2fc76deed107cc1eec593f99961b68ad06e3462 - Sigstore transparency entry: 1845384729
- Sigstore integration time:
-
Permalink:
arikanatakan/dataxplan-mcp@8391886755e09f79c546d6c6e4ac41602ca4098e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/arikanatakan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8391886755e09f79c546d6c6e4ac41602ca4098e -
Trigger Event:
push
-
Statement type: