analyze_db_health
Analyze PostgreSQL database health by checking indexes, connections, vacuum status, sequences, replication, buffer cache, and constraints to identify performance issues.
Instructions
Analyzes database health. Here are the available health checks:
index - checks for invalid, duplicate, and bloated indexes
connection - checks the number of connection and their utilization
vacuum - checks vacuum health for transaction id wraparound
sequence - checks sequences at risk of exceeding their maximum value
replication - checks replication health including lag and slots
buffer - checks for buffer cache hit rates for indexes and tables
constraint - checks for invalid constraints
all - runs all checks You can optionally specify a single health check or a comma-separated list of health checks. The default is 'all' checks.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| health_type | No | Optional. Valid values are: all, buffer, connection, constraint, index, replication, sequence, vacuum. | all |
Implementation Reference
- src/postgres_mcp/server.py:453-479 (handler)The analyze_db_health tool implementation in src/postgres_mcp/server.py. It uses the DatabaseHealthTool class to perform the checks.
@mcp.tool( description="Analyzes database health. Here are the available health checks:\n" "- index - checks for invalid, duplicate, and bloated indexes\n" "- connection - checks the number of connection and their utilization\n" "- vacuum - checks vacuum health for transaction id wraparound\n" "- sequence - checks sequences at risk of exceeding their maximum value\n" "- replication - checks replication health including lag and slots\n" "- buffer - checks for buffer cache hit rates for indexes and tables\n" "- constraint - checks for invalid constraints\n" "- all - runs all checks\n" "You can optionally specify a single health check or a comma-separated list of health checks. The default is 'all' checks." ) async def analyze_db_health( health_type: str = Field( description=f"Optional. Valid values are: {', '.join(sorted([t.value for t in HealthType]))}.", default="all", ), ) -> ResponseType: """Analyze database health for specified components. Args: health_type: Comma-separated list of health check types to perform. Valid values: index, connection, vacuum, sequence, replication, buffer, constraint, all """ health_tool = DatabaseHealthTool(await get_sql_driver()) result = await health_tool.health(health_type=health_type) return format_text_response(result)