Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

Show Slow Queries from pg_stat_statements

pg_slow_queries
Read-only

Analyze slow database queries using pg_stat_statements, ranked by mean execution time, to identify performance bottlenecks.

Instructions

Analyze slow queries using the pg_stat_statements extension. Shows queries ranked by mean execution time.

Requires the pg_stat_statements extension to be installed and enabled.

Args:

  • limit: Number of queries to return (default: 20, max: 100)

  • min_calls: Only show queries called at least N times (default: 5)

  • order_by: Sort by 'mean_ms', 'total_ms', or 'calls' (default: mean_ms)

  • response_format: Output format

Returns: JSON: { queries: SlowQuery[], count: number } Markdown: table with calls, mean/total time, % of total, cache hit %, query text

Errors:

  • "pg_stat_statements extension not installed" if extension is missing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of queries to return
min_callsNoMinimum number of calls to include
order_byNoSort ordermean_ms
response_formatNoOutput format: 'markdown' for human-readable, 'json' for machine-readablemarkdown
Behavior4/5

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

Annotations already indicate readOnlyHint=true, so the description adds value by stating the extension requirement, the output formats (JSON and Markdown with fields), and error conditions. This provides useful behavioral context beyond the annotations.

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?

The description is concise and well-structured with separate sections for arguments, returns, and errors. The first sentence immediately conveys the tool's purpose, making it easy to scan.

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?

The description covers all essential aspects: purpose, prerequisites, parameter details, return formats with field descriptions, and error handling. It is complete for the given schema and no output schema.

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?

With 100% schema description coverage, the baseline is 3. The description repeats parameter defaults and options but does not add new meaning beyond what the schema already provides.

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 the tool's purpose: analyzing slow queries using pg_stat_statements and ranking by mean execution time. It distinguishes from sibling tools like pg_active_queries and pg_query by focusing specifically on slow queries.

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 description mentions the prerequisite (pg_stat_statements extension) and provides default values for parameters, but does not explicitly guide when to use this tool versus alternatives, nor does it specify when not to use it.

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/foxter-io/mcp-postgresql'

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