Return per-database statistics (pg_stat_database) for every database in the cluster: connections, commits/rollbacks, block hit ratio inputs, tuple counts, conflicts, deadlocks, temp file usage, and checksum failures.
read-onlyany connectionsweeps replication groupsweeps group
databaseStats()
Return per-database statistics (pg_stat_database) for every database in the cluster: connections, commits/rollbacks, block hit ratio inputs, tuple counts, conflicts, deadlocks, temp file usage, and checksum failures.
None of its own.
Also accepts connection, replication_group, group, role, described once under arguments every tool takes.
Keyed by database name; each value is that database's pg_stat_database counters. An absent extension or a missing grant is reported as {error, hint} in place of the map.
This reading is instance-wide -- every database on the same postmaster returns it identically, so asking each of them in turn repeats one answer. The counters here are each server's own, so members of a replication group legitimately disagree and the answer is their sum, not the primary's copy.
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "databaseStats",
"arguments": {}
}
}
{
"shop": {
"numbackends": 84,
"xact_commit": 902211408,
"xact_rollback": 120442,
"blks_read": 81220331,
"blks_hit": 99201844221,
"temp_files": 211,
"temp_bytes": 90211332096,
"deadlocks": 3,
"checksum_failures": null,
"stats_reset": "2026-08-01T00:00:00Z"
}
}
Invented values on a fictional shop database, shaped by and checked against this tool's output schema. Real output is returned as structuredContent to clients that negotiate MCP 2025-06-18 or later.
diskUsage, databaseSize, serverSettings, currentActivity, currentLocks, statementStats, wraparoundStatus, progressStats, ioStats, checkpointStats, tableIOStats, hostCapacity, bufferCacheSummary, bufferCacheContents