Skip to main content
Glama
nahmanmate

PostgreSQL MCP Server

by nahmanmate

debug_database

Debug PostgreSQL database issues including connection problems, performance bottlenecks, lock conflicts, and replication errors to identify and resolve common database problems.

Instructions

Debug common PostgreSQL issues

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionStringYesPostgreSQL connection string
issueYesType of issue to debug
logLevelNoLogging detail levelinfo

Implementation Reference

  • Main handler function that executes the debug_database tool logic: connects to the database and delegates to specific debug functions based on the issue type.
    export async function debugDatabase( connectionString: string, issue: IssueType, logLevel: LogLevel = 'info' ): Promise<DebugResult> { const db = DatabaseConnection.getInstance(); try { await db.connect(connectionString); switch (issue) { case 'connection': return await debugConnection(db); case 'performance': return await debugPerformance(db); case 'locks': return await debugLocks(db); case 'replication': return await debugReplication(db); default: throw new Error(`Unsupported issue type: ${issue}`); } } finally { await db.disconnect(); } }
  • Input schema definition for the debug_database tool, specifying parameters, types, enums, and requirements.
    { name: 'debug_database', description: 'Debug common PostgreSQL issues', inputSchema: { type: 'object', properties: { connectionString: { type: 'string', description: 'PostgreSQL connection string' }, issue: { type: 'string', enum: [ 'connection', 'performance', 'locks', 'replication' ], description: 'Type of issue to debug' }, logLevel: { type: 'string', enum: ['info', 'debug', 'trace'], default: 'info', description: 'Logging detail level' } }, required: ['connectionString', 'issue'] } } ];
  • src/index.ts:102-107 (registration)
    Registration of the debug_database tool in the MCP server capabilities under the tools object.
    tools: { analyze_database: TOOL_DEFINITIONS[0], get_setup_instructions: TOOL_DEFINITIONS[1], debug_database: TOOL_DEFINITIONS[2] }, },
  • Server-side dispatch handler for the debug_database tool call, extracting arguments and invoking the implementation function.
    case 'debug_database': { const { connectionString, issue, logLevel } = request.params.arguments as { connectionString: string; issue: 'connection' | 'performance' | 'locks' | 'replication'; logLevel?: 'info' | 'debug' | 'trace'; }; const result = await debugDatabase(connectionString, issue, logLevel); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }

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/nahmanmate/postgresql-mcp-server'

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