Skip to main content
Glama
nahmanmate

PostgreSQL MCP Server

by nahmanmate

analyze_database

Analyze PostgreSQL database configuration, performance, or security to identify optimization opportunities and ensure efficient operations.

Instructions

Analyze PostgreSQL database configuration and performance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionStringYesPostgreSQL connection string
analysisTypeNoType of analysis to perform

Implementation Reference

  • Core handler function that orchestrates database analysis: connects to DB, fetches version/settings/metrics, generates recommendations, and returns structured AnalysisResult.
    export async function analyzeDatabase(
      connectionString: string,
      analysisType: 'configuration' | 'performance' | 'security' = 'configuration'
    ): Promise<AnalysisResult> {
      const db = DatabaseConnection.getInstance();
      await db.connect(connectionString);
    
      try {
        const version = await getVersion();
        const settings = await getSettings();
        const metrics = await getMetrics();
        const recommendations = await generateRecommendations(analysisType, settings, metrics);
    
        return {
          version,
          settings,
          metrics,
          recommendations,
        };
      } finally {
        await db.disconnect();
      }
    }
  • Tool definition including name, description, and input schema (connectionString required, analysisType optional enum). Used in TOOL_DEFINITIONS[0] and capabilities.
    {
      name: 'analyze_database',
      description: 'Analyze PostgreSQL database configuration and performance',
      inputSchema: {
        type: 'object',
        properties: {
          connectionString: {
            type: 'string',
            description: 'PostgreSQL connection string'
          },
          analysisType: {
            type: 'string',
            enum: ['configuration', 'performance', 'security'],
            description: 'Type of analysis to perform'
          }
        },
        required: ['connectionString']
      }
    },
  • src/index.ts:102-106 (registration)
    Registers the analyze_database tool in the MCP server's capabilities object, advertising it to clients.
    tools: {
      analyze_database: TOOL_DEFINITIONS[0],
      get_setup_instructions: TOOL_DEFINITIONS[1],
      debug_database: TOOL_DEFINITIONS[2]
    },
  • src/index.ts:122-124 (registration)
    Registers handler for ListToolsRequestSchema that returns all tool definitions including analyze_database.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: TOOL_DEFINITIONS
    }));
  • src/index.ts:129-143 (registration)
    Dispatch logic in CallToolRequestSchema handler: extracts arguments, calls analyzeDatabase, formats and returns result as MCP content.
    case 'analyze_database': {
      const { connectionString, analysisType } = request.params.arguments as {
        connectionString: string;
        analysisType?: 'configuration' | 'performance' | 'security';
      };
      const result = await analyzeDatabase(connectionString, analysisType);
      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 provided, the description carries the full burden of behavioral disclosure but only states what the tool does without detailing traits like whether it's read-only, requires specific permissions, has rate limits, or what the output format might be. This leaves significant gaps in understanding the tool's behavior.

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 that directly states the tool's purpose without any unnecessary words or fluff. It is appropriately sized and front-loaded, making it easy to parse quickly.

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 database analysis, lack of annotations, and absence of an output schema, the description is insufficient. It doesn't explain what the analysis entails, what results to expect, or any behavioral traits, leaving the agent with incomplete context for effective tool use.

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?

The schema description coverage is 100%, meaning the input schema already documents both parameters ('connectionString' and 'analysisType') with descriptions and an enum. The description adds no additional meaning beyond what the schema provides, so it meets the baseline score of 3 for adequate but unenhanced parameter information.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('analyze') and resource ('PostgreSQL database configuration and performance'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'debug_database' or 'get_setup_instructions', which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like 'debug_database' or 'get_setup_instructions'. It lacks any context about prerequisites, such as needing a valid connection string, or exclusions, leaving the agent without clear usage instructions.

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