Skip to main content
Glama

top_queries

Read-only

Retrieve ranked PostgreSQL statements from pg_stat_statements by total time, mean time, calls, rows, or I/O to identify slow or high-load queries.

Instructions

[READ] Top statements from pg_stat_statements by a whitelisted metric.

Args:
    order_by: One of total_time, mean_time, calls, rows, io.
    limit: Number of statements to return (1..200, default 20).
    target: Target name from config; omit for the default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
targetNo
order_byNototal_time

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?

The '[READ]' prefix aligns with readOnlyHint=true and adds no contradiction. It adds a modest constraint ('whitelisted metric') and the 1..200 limit bound, but says nothing about how many rows the stats cover, whether stats must be reset first, or freshness of pg_stat_statements data.

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 read-only marker and the core action, then a compact Args block. Every line carries information; the only slack is the slightly redundant restatement of defaults already in the schema.

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 simple read-only ranking tool with no output schema and no required parameters, the description covers purpose, all three parameters, and safety. What the returned rows contain (query text, metric values) is left unstated, which is the main remaining gap.

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

Parameters4/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 and does it well: it enumerates the five valid order_by values (total_time, mean_time, calls, rows, io), the limit range and default, and the meaning of target. 'Target name from config' is the only vague spot.

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 a specific resource (top statements from pg_stat_statements) and the ordering axis ('by a whitelisted metric'), which distinguishes it from mere listing tools like list_activity. It does not explicitly name a sibling it contrasts with, so it stops short of a 5.

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

Usage Guidelines2/5

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

The description explains what arguments do but never says when to reach for this tool versus slow_query_rca, long_running_queries, or explain_query. Usage must be inferred from the tool name alone.

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