Skip to main content
Glama

PostgreSQL MCP Server

AGPL 3.0
498
94
  • Linux
  • Apple

pg_manage_query

Analyze and optimize PostgreSQL queries using EXPLAIN plans, identify slow queries, monitor query statistics, and reset performance metrics via customizable operations for enhanced database management.

Instructions

Manage PostgreSQL query analysis and performance - operation="explain" for EXPLAIN plans, operation="get_slow_queries" for slow query analysis, operation="get_stats" for query statistics, operation="reset_stats" for clearing statistics

Input Schema

NameRequiredDescriptionDefault
analyzeNoUse EXPLAIN ANALYZE - actually executes the query (for explain operation)
buffersNoInclude buffer usage information (for explain operation)
connectionStringNo
costsNoInclude cost estimates (for explain operation)
formatNoOutput format (for explain operation)json
includeNormalizedNoInclude normalized query text (for get_slow_queries operation)
limitNoNumber of slow queries to return (for get_slow_queries operation)
minCallsNoMinimum number of calls (for get_stats operation)
minDurationNoMinimum average duration in milliseconds (for get_slow_queries operation)
operationYesOperation: explain (EXPLAIN/EXPLAIN ANALYZE query), get_slow_queries (find slow queries from pg_stat_statements), get_stats (query statistics with cache hit ratios), reset_stats (reset pg_stat_statements)
orderByNoSort order (for get_slow_queries and get_stats operations)mean_time
queryNoSQL query to explain (required for explain operation)
queryIdNoSpecific query ID to reset (for reset_stats operation, resets all if not provided)
queryPatternNoFilter queries containing this pattern (for get_stats operation)
verboseNoInclude verbose output (for explain operation)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "analyze": { "default": false, "description": "Use EXPLAIN ANALYZE - actually executes the query (for explain operation)", "type": "boolean" }, "buffers": { "default": false, "description": "Include buffer usage information (for explain operation)", "type": "boolean" }, "connectionString": { "type": "string" }, "costs": { "default": true, "description": "Include cost estimates (for explain operation)", "type": "boolean" }, "format": { "default": "json", "description": "Output format (for explain operation)", "enum": [ "text", "json", "xml", "yaml" ], "type": "string" }, "includeNormalized": { "default": true, "description": "Include normalized query text (for get_slow_queries operation)", "type": "boolean" }, "limit": { "default": 10, "description": "Number of slow queries to return (for get_slow_queries operation)", "type": "number" }, "minCalls": { "description": "Minimum number of calls (for get_stats operation)", "type": "number" }, "minDuration": { "description": "Minimum average duration in milliseconds (for get_slow_queries operation)", "type": "number" }, "operation": { "description": "Operation: explain (EXPLAIN/EXPLAIN ANALYZE query), get_slow_queries (find slow queries from pg_stat_statements), get_stats (query statistics with cache hit ratios), reset_stats (reset pg_stat_statements)", "enum": [ "explain", "get_slow_queries", "get_stats", "reset_stats" ], "type": "string" }, "orderBy": { "default": "mean_time", "description": "Sort order (for get_slow_queries and get_stats operations)", "enum": [ "mean_time", "total_time", "calls", "cache_hit_ratio" ], "type": "string" }, "query": { "description": "SQL query to explain (required for explain operation)", "type": "string" }, "queryId": { "description": "Specific query ID to reset (for reset_stats operation, resets all if not provided)", "type": "string" }, "queryPattern": { "description": "Filter queries containing this pattern (for get_stats operation)", "type": "string" }, "verbose": { "default": false, "description": "Include verbose output (for explain operation)", "type": "boolean" } }, "required": [ "operation" ], "type": "object" }

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

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