Skip to main content
Glama
call518

MCP PostgreSQL Operations

by call518

get_pg_stat_monitor_recent_queries

Retrieve detailed performance data for recently executed PostgreSQL queries using pg_stat_monitor, including client IP and time-bucket breakdowns for real-time monitoring and client-specific analysis.

Instructions

[Tool Purpose]: Analyze recently executed queries and detailed monitoring information using pg_stat_monitor extension

[Exact Functionality]:

  • Retrieve detailed performance information of recently executed queries

  • Display client IP and time bucket information by execution period

  • Provide more detailed monitoring data than pg_stat_statements

[Required Use Cases]:

  • When user requests "recent queries", "detailed monitoring", "pg_stat_monitor", etc.

  • When real-time query performance monitoring is needed

  • When client-specific or time-based query analysis is required

[Strictly Prohibited Use Cases]:

  • When pg_stat_monitor extension is not installed

  • Requests for query execution or data modification

  • Requests for monitoring configuration changes or data reset

Input Schema

NameRequiredDescriptionDefault
limitNoNumber of recent queries to retrieve (default: 20, max: 100)
database_nameNoDatabase name to analyze (uses default database if omitted)

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv3.4.3
    • addedInput schema / properties / database_name / description
      Added value: +"Database name to analyze (uses default database if omitted)"
    • addedInput schema / properties / limit / description
      Added value: +"Number of recent queries to retrieve (default: 20, max: 100)"
  2. Changed7 schema fields changedv3.4.2
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / database_name / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / database_name / title
      Removed value: -"Database Name"
    • removedInput schema / properties / database_name / type
      Removed value: -"string"
    • removedInput schema / properties / limit / title
      Removed value: -"Limit"
    • removedOutput schema / properties / result / title
      Removed value: -"Result"
    • removedOutput schema / title
      Removed value: -"_WrappedResult"
  3. Addedv1.0.0

TDQS

A4.2/5.0
Behavior4/5

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

No annotations are provided, so the description carries the behavioral burden. It clearly describes a retrieval/analysis operation and explicitly prohibits use for query execution, data modification, configuration changes, or data reset, effectively signaling read-only monitoring behavior. It does not mention permission requirements, rate limits, or other operational constraints, so it is strong but not complete.

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?

The description is front-loaded and organized into clear sections for purpose, functionality, required cases, and prohibited cases. It is somewhat repetitive across those sections, repeating 'recently executed queries' and 'detailed monitoring', which keeps it from being maximally concise.

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?

Given the tool's complexity, lack of annotations, complete parameter schema, and existence of an output schema, the description provides enough context to call it correctly. It covers purpose, functionality, appropriate use, prohibited use, and the prerequisite that pg_stat_monitor be installed.

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 parameters are fully documented in the schema. The description does not add any parameter-specific semantics such as guidance on choosing limit values or using database_name. With the schema doing all parameter documentation, the baseline of 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 states a specific verb and resource: analyze recently executed queries using pg_stat_monitor. It distinguishes itself from pg_stat_statements by noting it provides more detailed monitoring including client IP and time bucket information. This is enough for an agent to understand the tool's purpose without opening the schema.

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 has explicit Required Use Cases and Strictly Prohibited Use Cases, including requests for recent queries, detailed monitoring, and pg_stat_monitor, plus exclusions for missing extension, execution/modification, and configuration/reset requests. It does not explicitly name the sibling alternative get_pg_stat_statements_top_queries or state when to choose it instead, which keeps this below a 5.

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