Return current server connections and running queries (pg_stat_activity) across all databases: pid, database, user, application_name, backend_type, state, wait event, query text, transaction and query duration, leader_pid for parallel workers, and the backend's xid and xmin.
read-onlyany connectionsweeps replication groupsweeps groupcan return data values
currentActivity([min_duration_s], [pid], [query_id], [state])
Return current server connections and running queries (pg_stat_activity) across all databases: pid, database, user, application_name, backend_type, state, wait event, query text, transaction and query duration, leader_pid for parallel workers, and the backend's xid and xmin. query_id is returned as a decimal string and is the join key to statementStats and explainQuery, so a statement seen running here can be looked up and planned.
All filters are optional and combine; with none the whole view is returned, which on a busy server is mostly idle connections and internal processes.
query_start dates a statement that already finishedleader_pid is this pid)query_id, as a decimal string; use it to find who is running a statement identified by statementStats. Requires compute_query_id to be enabled (the default 'auto' enables it when pg_stat_statements is loaded)pg_stat_activity state, e.g. "active" or "idle in transaction"Also accepts connection, replication_group, group, role, described once under arguments every tool takes.
Keyed by backend pid; each value is that backend's state, query and wait event. 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": "currentActivity",
"arguments": {
"min_duration_s": 5
}
}
}
{
"51877": {
"database": "shop",
"user": "app_rw",
"application_name": "checkout-api",
"client_addr": "10.0.4.17",
"backend_type": "client backend",
"state": "active",
"wait_event_type": "Lock",
"wait_event": "transactionid",
"query_duration_s": 12.402,
"xact_duration_s": 12.44,
"query_id": "-6203381990422871044",
"query": "UPDATE shop.orders SET status = $1 WHERE id = $2"
}
}
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, currentLocks, databaseStats, statementStats, wraparoundStatus, progressStats, ioStats, checkpointStats, tableIOStats, hostCapacity, bufferCacheSummary, bufferCacheContents