Skip to main content
Glama
itsalfredakku

Postgres MCP Server

monitoring

Retrieve PostgreSQL database performance metrics, statistics, and health checks including connections, locks, replication status, and query performance.

Instructions

Database monitoring: performance metrics, statistics, health checks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricYesMetric type to retrieve
timeRangeNoTime range for metrics1h
limitNoMaximum number of results

Implementation Reference

  • The main execution handler for the 'monitoring' tool. Handles different metrics (connections, performance, cache, security) by delegating to various managers and returning JSON-formatted monitoring data.
    private async handleMonitoring(args: any) {
      const { metric } = args;
      
      switch (metric) {
        case 'connections':
          return {
            content: [{
              type: 'text',
              text: JSON.stringify(this.dbManager.getPoolStats(), null, 2)
            }]
          };
    
        case 'performance':
          const operationalStats = this.dbManager.getOperationalStats();
          const performanceMetrics = this.performanceMonitor.getMetrics();
          const slowOperations = this.performanceMonitor.getSlowOperations();
          
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                operational: operationalStats,
                performance: performanceMetrics,
                slowOperations,
                cache: this.cache.getStats()
              }, null, 2)
            }]
          };
    
        case 'cache':
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                stats: this.cache.getStats(),
                recent: this.cache.getRecentEntries(5),
                popular: this.cache.getPopularEntries(5)
              }, null, 2)
            }]
          };
    
        case 'security':
          const rateLimitEntries = Array.from(this.rateLimiter.getAllEntries().entries()).slice(0, 10);
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                rateLimits: rateLimitEntries,
                securityEvents: 'Security event logging would be implemented here'
              }, null, 2)
            }]
          };
    
        default:
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({ message: `Monitoring metric '${metric}' not yet implemented` }, null, 2)
            }]
          };
      }
    }
  • Input schema for the 'monitoring' tool, defining parameters such as metric (required), timeRange, and limit.
    {
      name: 'monitoring',
      description: 'Database monitoring: performance metrics, statistics, health checks',
      inputSchema: {
        type: 'object',
        properties: {
          metric: {
            type: 'string',
            enum: ['connections', 'performance', 'locks', 'replication', 'disk_usage', 'query_stats', 'index_usage'],
            description: 'Metric type to retrieve'
          },
          timeRange: {
            type: 'string',
            enum: ['1h', '24h', '7d', '30d'],
            description: 'Time range for metrics',
            default: '1h'
          },
          limit: {
            type: 'integer',
            description: 'Maximum number of results',
            default: 50
          }
        },
        required: ['metric']
      }
    },
  • src/index.ts:633-637 (registration)
    Registration of all tool definitions (including 'monitoring') via ListToolsRequestSchema handler, exposing schemas to clients.
    // Register tool definitions
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: toolDefinitions,
    }));
  • src/index.ts:664-666 (registration)
    Dispatch/registration in the CallToolRequestSchema switch statement, routing 'monitoring' tool calls to the handleMonitoring function.
    case 'monitoring':
      return await this.handleMonitoring(args);
  • Tool name mappings in validation module, associating 'monitor' and 'stats' aliases with the 'monitoring' category for error suggestions.
    'monitor': 'monitoring',
    'stats': 'monitoring',
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It implies a read-only operation by mentioning 'retrieval' of metrics, but doesn't specify authentication needs, rate limits, potential side effects, or what the output format looks like (e.g., structured data vs. raw logs). This leaves significant gaps for a monitoring tool.

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 brief and front-loaded with the core purpose, using only one sentence without unnecessary elaboration. However, it could be slightly more structured by explicitly stating it's a retrieval tool (e.g., 'Retrieve database monitoring metrics...') to enhance clarity.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is minimally adequate. It covers the what (monitoring data) but lacks details on behavioral aspects, output expectations, and differentiation from siblings. Without annotations or output schema, more context on what the tool returns would improve completeness.

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 schema fully documents all parameters (metric, timeRange, limit) with enums and defaults. The description adds no additional parameter semantics beyond what's in the schema, such as explaining how metrics are aggregated or what 'limit' applies to. This meets the baseline for high schema coverage.

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 clearly states the tool's purpose as retrieving database monitoring data (performance metrics, statistics, health checks), which is specific and actionable. However, it doesn't distinguish this from potential sibling tools like 'connections' or 'performance' that might overlap in functionality, preventing a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'connections' or 'performance' from the sibling list. It mentions general categories (metrics, statistics, health checks) but offers no explicit when/when-not instructions or prerequisites for usage.

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/itsalfredakku/postgres-mcp'

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