Skip to main content
Glama

Top queries

get_top_queries
Read-onlyIdempotent

Retrieve high-cost PostgreSQL statements from pg_stat_statements, ranked by total time, mean time, or calls, with inline secrets masked.

Instructions

Most expensive statements from pg_stat_statements (requires the extension), with 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": "get_top_queries"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoHow many (default 20)
orderByNoRank by (default total_time)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/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, so the safety profile is covered. The description adds two pieces of genuine context beyond that: the pg_stat_statements dependency and the fact that inline secrets are masked in the output. It says nothing about volume limits, performance cost of the lookup, or the shape of returned rows.

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

Conciseness5/5

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

A single front-loaded sentence that states the source, the extension dependency, and the masking behavior with no filler. Nothing needs to be cut.

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?

For a low-complexity read-only tool with zero required parameters this is nearly adequate, and the extension prerequisite plus masking note cover the main surprises. With no output schema, the description should say more about what a returned statement row contains and whether results are capped, and it never mentions the alternatives for query analysis.

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 100%, so both the integer limit (default 20, max 100) and the orderBy enum are fully documented in the schema. The description adds no additional meaning about how ordering or limits interact with the ranking, so the baseline of 3 applies.

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?

Names a specific resource ('Most expensive statements from pg_stat_statements'), so the agent knows it returns ranked expensive statements rather than live activity. It does not explicitly distinguish itself from siblings such as list_active_queries, leaving the differentiation implicit.

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?

The prerequisite ('requires the extension') tells the agent when the tool will not work, which is useful. However, there is no guidance on when to prefer this over list_active_queries, get_database_stats, or explain_query for performance investigation.

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