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
| Name | Required | Description | Default |
|---|---|---|---|
| connectionString | Yes | PostgreSQL connection string | |
| issue | Yes | Type of issue to debug | |
| logLevel | No | Logging detail level | info |
Implementation Reference
- src/tools/debug.ts:40-65 (handler)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(); } } - src/index.ts:59-89 (schema)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] }, }, - src/index.ts:171-186 (handler)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) } ] }; }