Skip to main content
Glama
YawLabs

@yawlabs/postgres-mcp

by YawLabs

pg_top_queries

Read-onlyIdempotent

Retrieves the top N queries by total or mean execution time to identify slow queries for optimization. Requires pg_stat_statements extension.

Instructions

Top N queries by total or mean execution time. Requires the pg_stat_statements extension to be installed and enabled (most managed Postgres providers have it on by default). Returns normalized query text (constants replaced with ?), call count, total/mean/min/max time in ms, rows returned, and cache hit ratio. Use this to find slow queries worth optimizing. On pg_stat_statements >= 1.10 (Postgres 15+), also returns io_read_time_ms and io_write_time_ms to separate IO-bound from CPU-bound queries (null when track_io_timing = off or the query did no measurable IO -- enable track_io_timing in postgresql.conf to get non-null values).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of rows to return (default 20).
orderByNoRanking: total_time (cumulative impact), mean_time (worst per-call), or calls (hottest).total_time
Behavior5/5

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

The description details all returned fields, explains IO timing null behavior, and prerequisites. Annotations already indicate readOnly and idempotent; description adds rich behavioral context without contradiction.

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?

Six sentences efficiently convey purpose, prerequisites, return fields, use case, and version details. Front-loaded with key information, no fluff.

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

Completeness5/5

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

Despite no output schema, the description covers all return fields, prerequisites, and version-dependent behavior. Complete for the tool's complexity.

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 coverage is 100% with detailed descriptions for both parameters. The description adds slight clarification but doesn't significantly exceed schema info, so baseline 3 is appropriate.

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?

The description clearly states it retrieves the top N queries by execution time, using specific verbs and resource. It distinguishes from siblings by focusing on slow query identification, unlike pg_explain (plan analysis) or pg_health (general health).

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

Usage Guidelines4/5

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

The description explains prerequisite (pg_stat_statements) and use case (find slow queries), but doesn't explicitly state when not to use or list alternative tools.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/YawLabs/postgres-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server