Return current locks (pg_locks) joined with the holding backend's query and user, plus which pids are blocking each waiting lock; use to diagnose lock contention.
read-onlyany connectionsweeps replication groupsweeps groupcan return data values
currentLocks([pid])
Return current locks (pg_locks) joined with the holding backend's query and user, plus which pids are blocking each waiting lock; use to diagnose lock contention. Given a pid, returns that backend's locks together with every backend blocking it transitively, each tagged with chain_depth: 0 is the pid asked about, and the largest depth is the backend at the root of the pile-up, which is the one to look at first.
pg_blocking_pids. Omit for every lock in the clusterAlso accepts connection, replication_group, group, role, described once under arguments every tool takes.
Lock rows, newest blocking chain first. An absent extension or a missing grant is reported as {error, hint} instead.
| Field | Type |
|---|---|
| locks | array | null |
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": "currentLocks",
"arguments": {}
}
}
{
"locks": [
{
"pid": 51877,
"chain_depth": 1,
"lock_type": "transactionid",
"relation": null,
"mode": "ShareLock",
"granted": false,
"wait_start": "2026-09-15T10:04:20Z",
"blocked_by": [
51702
],
"user": "app_rw",
"application_name": "checkout-api",
"query": "UPDATE shop.orders SET status = $1 WHERE id = $2"
},
{
"pid": 51702,
"chain_depth": 0,
"lock_type": "transactionid",
"relation": null,
"mode": "ExclusiveLock",
"granted": true,
"wait_start": null,
"blocked_by": [],
"user": "batch",
"application_name": "nightly-reconcile",
"query": "COMMIT"
}
]
}
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, databaseStats, statementStats, wraparoundStatus, progressStats, ioStats, checkpointStats, tableIOStats, hostCapacity, bufferCacheSummary, bufferCacheContents