Skip to main content
Glama
nahmanmate

PostgreSQL MCP Server

by nahmanmate

analyze_database

Evaluate PostgreSQL database configuration, performance, and security using input connection details. Identify optimization opportunities and ensure operational efficiency.

Instructions

Analyze PostgreSQL database configuration and performance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
analysisTypeNoType of analysis to perform
connectionStringYesPostgreSQL connection string

Implementation Reference

  • Main handler function that executes the analyze_database tool logic: connects to PostgreSQL database, retrieves version, settings, performance metrics, generates recommendations based on analysis type, and returns structured results.
    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(); } }
  • Input schema and metadata definition for the analyze_database tool used in MCP capabilities and listTools response.
    { 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)
    MCP server capabilities registration declaring the analyze_database tool (and others) by referencing its TOOL_DEFINITION.
    tools: { analyze_database: TOOL_DEFINITIONS[0], get_setup_instructions: TOOL_DEFINITIONS[1], debug_database: TOOL_DEFINITIONS[2] },
  • src/index.ts:129-143 (registration)
    Tool call request handler dispatch case for 'analyze_database' that invokes the analyzeDatabase implementation and formats the response.
    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) } ] }; }
  • TypeScript interface defining the output structure returned by the analyzeDatabase handler.
    interface AnalysisResult { version: string; settings: Record<string, any>; metrics: { connections: number; activeQueries: number; cacheHitRatio: number; tableSizes: Record<string, string>; }; recommendations: string[]; }

Other Tools

Related 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