MCP Tools
pg_report_history
View past Postgres analysis reports and compare trends
View past Postgres analysis reports and compare trends. Shows changes in table sizes, dead tuples, recommendations gained/resolved. Use this to track database health over time.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
count | number | OPTIONAL | 5 | Number of past reports to load (1-50) |
diff | boolean | OPTIONAL | true | Compare latest two reports and show changes |
Example Request
Default (Last 5 Reports with Diff)
{}Last 20 Reports Without Diff
{
"count": 20,
"diff": false
}Compare Recent Reports
{
"count": 2,
"diff": true
}Response
{
"total": 5,
"reports": [
{
"timestamp": "2026-03-26T09:00:00.000Z",
"databaseSize": "256 MB",
"tables": 12,
"critical": 0,
"warnings": 2
},
{
"timestamp": "2026-03-19T09:00:00.000Z",
"databaseSize": "248 MB",
"tables": 12,
"critical": 1,
"warnings": 3
}
],
"diff": {
"tableChanges": [
{
"table": "document_chunks",
"rowDelta": 500,
"deadTupleDelta": -200,
"sizeChange": "+8 MB"
}
],
"newRecommendations": [],
"resolvedRecommendations": ["Table needs immediate vacuum"],
"connectionDelta": -2
}
}When diff is false or only one report exists, the diff field is null.
Error Responses
| Error | Cause | Fix |
|---|---|---|
No saved reports | No reports in PG_REPORT_DIR | Run pg_analyze with save: true first |
Report history failed | File read error | Check PG_REPORT_DIR permissions and path |
Notes
- This tool is read-only and not destructive — it only reads saved report files.
- This tool does not require
DATABASE_URL. It reads previously saved report files fromPG_REPORT_DIR(default./reports/pg-analysis). Reports are created by runningpg_analyzewithsave: true(which does requireDATABASE_URL). - When
diffistrue, the comparison highlights:- Table size changes: growth or shrinkage since the previous report
- Dead tuple changes: increases or decreases in dead tuples
- Recommendations gained: new issues detected since the last report
- Recommendations resolved: issues that are no longer present
Related Tools
pg_analyze- Run a new analysis (usesave: trueto add to history)pg_recommendations- Get current optimization recommendations