Skip to main content
Glama

Active queries

list_active_queries
Read-onlyIdempotent

Retrieve active PostgreSQL sessions from pg_stat_activity with role, state, wait events, query age, and masked query text to diagnose live activity. Optionally include idle sessions.

Instructions

Sessions from pg_stat_activity: role, state, wait event, transaction/query age, and query text (inline secrets masked).

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": "list_active_queries"
  }
}

Input Schema

NameRequiredDescriptionDefault
includeIdleNoInclude idle sessions (default false)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.4/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and openWorldHint, and the description usefully adds that inline secrets are masked. However, it omits meaningful behavioral context for pg_stat_activity, notably that visibility of other roles' query text depends on pg_read_all_stats/privileges and whether the result is a point-in-time snapshot with a row cap. Additions like the masking note are valuable but the privilege caveat is a notable gap.

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?

One dense sentence, front-loaded with the data source and then the payload fields, with the masking caveat parenthetically appended. No filler, though the subject-less fragment style leaves no room for scoping or volume guidance.

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

Completeness3/5

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

Since there is no output schema, the description must carry return-shape burden, and it does list the fields returned. It is still silent on result volume/ordering and on privilege-dependent visibility, which matter for an activity-viewer that non-superusers may see only partially.

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?

The single includeIdle parameter is fully documented in the schema including its default, and the description adds nothing about it — but it also doesn't need to at 100% coverage. Baseline 3 applies since the schema carries the parameter semantics.

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

Purpose4/5

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

States the concrete source (pg_stat_activity) and enumerates the returned fields (role, state, wait event, transaction/query age, query text), so its purpose as a live-session inspector is unambiguous. It does not explicitly distinguish itself from get_top_queries, but the field list does most of that work.

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

Usage Guidelines3/5

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

Usage is only implied through the source view and field list — an agent can infer this is for inspecting current sessions. There is no explicit when-to-use/when-not-to-use guidance and no mention of get_top_queries as the alternative for aggregated analysis.

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