Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

PostgreSQL Connection Statistics

pg_connection_stats
Read-only

Show connection statistics grouped by database, user, application, or state to monitor pool utilization and detect idle connections or leaks.

Instructions

Show a summary of current connections grouped by database, user, application, and state.

Useful for monitoring connection pool utilization, finding idle connections, and detecting connection leaks from specific applications.

Args:

  • group_by: Group connections by 'database', 'user', 'application', or 'state' (default: state)

  • database: Filter to a specific database (optional)

  • response_format: Output format

Returns: JSON: { summary: ConnectionStat[], total_connections: number, max_connections: string, usage_pct: number } Markdown: grouped connection count with waiting and max idle age

Note: Excludes the MCP server's own backend connection from counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
group_byNoGroup connections by 'database', 'user', 'application', or 'state'state
databaseNoFilter to specific database (optional)
response_formatNoOutput format: 'markdown' for human-readable, 'json' for machine-readablemarkdown
Behavior5/5

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

Beyond the annotations (readOnlyHint=true, destructiveHint=false), the description adds important behavioral context: it excludes the MCP server's own backend connection from counts, and details the output format for both JSON and Markdown. This helps the AI agent understand exactly what the tool returns and its non-destructive nature.

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: a brief purpose statement, followed by use cases, a clear Args section, a Returns section, and a critical note. Every sentence adds value, and there is no redundancy with the input schema.

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 that there is no output schema, the description fully compensates by detailing the return structure for both JSON and Markdown formats. The tool has 3 parameters, all documented, and the description includes a note about connection exclusion. This is comprehensive for a read-only diagnostic tool.

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 the baseline is 3. The description restates the parameters and their defaults but adds no new semantic detail beyond what the schema already provides. For example, the group_by enum values are listed in both places. No additional constraints or examples are given.

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 shows a summary of current PostgreSQL connections grouped by database, user, application, or state. It specifies the resource (connection statistics) and action (show summary), distinguishing it from sibling tools like pg_active_queries which focuses on active queries.

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 explicitly states use cases: monitoring connection pool utilization, finding idle connections, and detecting connection leaks. While it doesn't list when not to use or directly name alternatives, the context signals and sibling tools list imply that for different monitoring needs (e.g., active queries) other tools exist.

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