Skip to main content
Glama
itsalfredakku

Postgres MCP Server

connections

Manage PostgreSQL connection pools by checking status, viewing statistics, testing connections, or resetting the pool for database administration.

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

  • JSON Schema definition for the 'connections' tool input parameters, defining actions like status, stats, test, reset.
    { 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'] }
  • Main handler function for the 'connections' tool. Dispatches to different actions (status, stats, test) using DatabaseConnectionManager methods and returns JSON-formatted results.
    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}`); } }
  • src/index.ts:634-636 (registration)
    Registration of tool list handler, which includes the 'connections' tool schema from toolDefinitions array.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: toolDefinitions, }));
  • src/index.ts:667-669 (registration)
    Dispatch/registration in the central CallToolRequestSchema handler switch statement, routing 'connections' calls to handleConnections.
    case 'connections': return await this.handleConnections(args);
  • Helper method getPoolStats() in DatabaseConnectionManager providing pool statistics used by connections tool status action. (Note: approximate lines from search; actual may vary slightly.)
    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