Skip to main content
Glama

Session activity

pg_activity
Read-onlyIdempotent

Inspect live PostgreSQL sessions to find long-running queries, idle-in-transaction connections, and blocked sessions, with state summaries and max_connections usage.

Instructions

Show who is connected right now: sessions from pg_stat_activity with user, database, application, client, state, wait event, how long the transaction, query and state have lasted, the query text, which sessions block them (blocked_by), plus a summary by state and the use of max_connections.

Use it to find long-running queries, sessions stuck "idle in transaction" and blocked sessions. Idle sessions are hidden unless include_idle is true or state="idle" is given. min_duration_seconds keeps sessions whose transaction or current state is at least that old. Your own session is never listed. For the lock tree use pg_locks.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "pg_activity"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
stateNo
databaseNo
connectionNo
include_idleNo
min_duration_secondsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/idempotent/non-destructive, so the safety profile is covered; the description adds real behavioral substance beyond that, such as idle sessions being hidden by default, own-session exclusion, the min_duration_seconds filter semantics, and the presence of a state summary with max_connections usage. Minor gap: it does not say what limit does to the result set or whether the summary is affected by it.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the resource and its fields, then use cases, then filter rules, then the sibling redirect — a logical order with little waste. The first sentence is dense with column enumerations, but each list item is informative rather than padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a six-parameter read tool with no output schema, the description does the important work: what is returned (fields, summary, blocked_by), default filtering, and the pg_locks alternative. It stops short of explaining how limit/database/connection shape results, which is the remaining gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description carries the burden. It meaningfully explains state, include_idle and min_duration_seconds, but leaves limit (default 50), database and connection completely unaddressed — half the parameters get no semantic help anywhere.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Show who is connected right now: sessions from pg_stat_activity') and enumerates the returned fields, including waits, durations and blocked_by. It explicitly names the sibling that covers a different concern ('For the lock tree use pg_locks'), so an agent can distinguish it without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Names concrete use cases (long-running queries, 'idle in transaction', blocked sessions) and states the conditions that change behavior for include_idle and min_duration_seconds. It also gives an explicit redirect to pg_locks for the lock tree, which is a real when-not-to-use signal.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.