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)
          }
        ]
      };
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states 'Debug common PostgreSQL issues', lacking details on behavior such as what the tool does (e.g., runs diagnostics, generates reports, modifies settings), permissions required, side effects, or output format. It doesn't disclose if it's read-only, destructive, or has rate limits, which is a significant gap for a debugging tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste, front-loaded and appropriately sized for its purpose. It avoids redundancy and is structured to convey the core idea without unnecessary elaboration.

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

Completeness2/5

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

Given the complexity of debugging (potentially involving diagnostics, analysis, or fixes), no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, how it handles different issue types, or behavioral traits, leaving gaps that could hinder correct agent invocation.

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 parameters like 'connectionString', 'issue' with enums, and 'logLevel'. The description adds no meaning beyond this, as it doesn't explain parameter interactions or provide examples. Baseline 3 is appropriate since the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Debug common PostgreSQL issues' states a general purpose but lacks specificity about what debugging entails (e.g., diagnostics, fixes, logs) and doesn't clearly distinguish from sibling tools like 'analyze_database' or 'get_setup_instructions'. It's vague about the verb 'debug'—whether it analyzes, reports, or resolves issues.

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?

No guidance is provided on when to use this tool versus alternatives like 'analyze_database' or 'get_setup_instructions'. The description implies usage for PostgreSQL issues but doesn't specify contexts, prerequisites, or exclusions, leaving the agent to infer based on tool names alone.

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

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