Skip to main content
Glama
itsalfredakku

Postgres MCP Server

connections

Manage PostgreSQL connection pool operations including checking status, viewing statistics, testing connections, and resetting the pool for optimal database performance.

Instructions

Connection pool management: status, statistics, configuration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction: status (pool status), stats (detailed statistics), test (test connection), reset (reset pool)

Implementation Reference

  • Primary handler function for the 'connections' tool. Dispatches based on 'action' parameter to return pool status, operational stats, or test connection using DatabaseConnectionManager methods.
    private async handleConnections(args: any) { const { action } = args; switch (action) { case 'status': return { content: [{ type: 'text', text: JSON.stringify(this.dbManager.getPoolStats(), null, 2) }] }; case 'stats': return { content: [{ type: 'text', text: JSON.stringify(this.dbManager.getOperationalStats(), null, 2) }] }; case 'test': const isHealthy = await this.dbManager.testConnection(); return { content: [{ type: 'text', text: JSON.stringify({ connected: isHealthy, timestamp: new Date().toISOString() }, null, 2) }] }; default: throw new Error(`Unknown connections action: ${action}`); } }
  • Input schema and metadata definition for the 'connections' MCP tool, specifying the required 'action' parameter with supported values.
    name: 'connections', description: 'Connection pool management: status, statistics, configuration', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['status', 'stats', 'test', 'reset'], description: 'Action: status (pool status), stats (detailed statistics), test (test connection), reset (reset pool)' } }, required: ['action'] } },
  • src/index.ts:634-636 (registration)
    Registration of the 'connections' tool schema via the ListToolsRequestSchema handler, which returns the full toolDefinitions array including 'connections'.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: toolDefinitions, }));
  • src/index.ts:668-669 (registration)
    Handler dispatch registration for 'connections' tool in the MCP CallToolRequestSchema switch statement.
    return await this.handleConnections(args);
  • Helper method returning current connection pool statistics (total, idle, waiting connections, config), used by 'status' action in connections tool.
    getPoolStats(): ConnectionPoolStats { return { totalConnections: this.pool.totalCount, idleConnections: this.pool.idleCount, waitingCount: this.pool.waitingCount, config: { min: this.config.get().pool.min, max: this.config.get().pool.max, idleTimeoutMillis: this.config.get().pool.idleTimeoutMillis, } }; }

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