Skip to main content
Glama

get_top_queries

Read-onlyIdempotent

Identify slow or resource-intensive queries by ranking pg_stat_statements and Multigres gateway statistics separately, helping you target database performance tuning.

Instructions

Report the slowest or most resource-intensive queries from pg_stat_statements and from the query statistics each Multigres gateway keeps. The two sources cover different periods and are shown separately.

Input Schema

NameRequiredDescriptionDefault
nodeNoRead pg_stat_statements on this node over a direct connection (cell/name, name, or primary); default is through the gateway
limitNoNumber of queries when ranking by total_time or mean_time (default 10)
sourceNoboth (default), pg_stat_statements, or gateway for the query statistics each Multigres gateway keeps
sort_byNoRanking: total_time, mean_time, or resources for queries using more than 5% of any resource (default resources)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive, and closed-world, so the safety profile is covered. The description adds genuinely useful behavioral context beyond that: results come from two sources with different time coverage and are returned separately, which directly affects how an agent should interpret the output. It does not discuss pagination or result size limits, keeping it short of a 5.

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?

Two sentences, zero filler, with the core purpose stated first and the interpretive caveat about differing time periods second. Nothing is repeated from the schema or annotations.

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 read-only, four-parameter reporting tool with full schema coverage and no output schema, this is close to complete — it explains what is reported and why two result sets appear. Minor gaps remain: the description does not characterize what a row contains (query text, timing, resource share) or clarify the gateway-vs-direct connection tradeoff implied by `node`.

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 all four parameters (node, limit, source, sort_by) are already well documented, and the baseline is 3. The description only adds the framing that the sources are shown separately, which reinforces the `source` parameter but adds no syntax, defaults, or edge-case detail beyond the schema.

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?

The description names a specific verb and resource ("Report the slowest or most resource-intensive queries") and identifies two concrete data sources, pg_stat_statements and per-gateway query statistics. It implicitly distinguishes itself from siblings like explain_query or analyze_query_indexes by being a top-N ranking report rather than a plan or index analysis, though it never names those alternatives explicitly.

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: an agent can infer this is the tool for finding expensive queries, but there is no explicit "use this when X, use explain_query when Y" guidance. The note that the two sources cover different periods is helpful context but is not when-to-use guidance.

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