Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
health_typeNoOptional. Valid values are: all, buffer, connection, constraint, index, replication, sequence, vacuum.all

Implementation Reference

  • 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)

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/moecodeshere/mcptrial'

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