Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| DATABASE_URI | Yes | PostgreSQL connection string (Format: postgresql://user:password@host:port/database) |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| get_slow_queries | Retrieve slow queries from PostgreSQL using pg_stat_statements. Returns the top N slowest queries ordered by total execution time. Requires the pg_stat_statements extension to be enabled. Note: This tool focuses on user/application queries only. System catalog queries (pg_catalog, information_schema, pg_toast) are automatically excluded. The results include:
|
| analyze_query | Analyze a SQL query's execution plan and performance characteristics. Uses EXPLAIN ANALYZE to execute the query and capture detailed timing information. Provides analysis of:
WARNING: This actually executes the query! For SELECT queries this is safe, but be careful with INSERT/UPDATE/DELETE - use analyze_only=false for those. |
| get_table_stats | Get detailed statistics for user/client database tables. Note: This tool analyzes only user-created tables and excludes PostgreSQL system tables (pg_catalog, information_schema, pg_toast). This focuses the analysis on your application's custom tables. Returns information about:
This helps identify tables that may need maintenance (VACUUM, ANALYZE) or have performance issues. |
| get_index_recommendations | Get AI-powered index recommendations for your database. Analyzes your query workload (from pg_stat_statements) and recommends indexes that would improve performance. Uses a sophisticated analysis algorithm that:
Note: This tool focuses on user/client tables only and excludes system catalog tables (pg_catalog, information_schema, pg_toast). The recommendations consider:
|
| explain_with_indexes | Run EXPLAIN on a query, optionally with hypothetical indexes. This tool allows you to see how a query would perform with proposed indexes WITHOUT actually creating them. Requires HypoPG extension for hypothetical testing. Use this to:
Returns both the original and hypothetical execution plans for comparison. |
| manage_hypothetical_indexes | Manage HypoPG hypothetical indexes for testing. HypoPG allows you to create "hypothetical" indexes that exist only in memory and can be used to test query plans without the overhead of creating real indexes. Actions:
This is useful for:
|
| find_unused_indexes | Find indexes that are not being used or are duplicates. Note: This tool analyzes only user/client indexes and excludes system catalog indexes (pg_catalog, information_schema, pg_toast). It focuses on your application's custom tables only. Identifies:
Removing unused indexes can:
|
| check_database_health | Perform a comprehensive database health check. Note: This tool focuses on user/client tables and excludes PostgreSQL system tables (pg_catalog, information_schema, pg_toast) from analysis. Analyzes multiple aspects of PostgreSQL health:
Returns a health score with detailed breakdown and recommendations. |
| get_active_queries | Get information about currently active queries and connections. Note: By default, this tool excludes system/background processes and focuses on client backend queries to help you analyze your application's query patterns. System catalog queries are filtered out unless explicitly requested. Shows:
Useful for:
|
| analyze_wait_events | Analyze PostgreSQL wait events to identify bottlenecks. Note: This tool focuses on client backend processes and excludes system background processes to help identify bottlenecks in your application queries. Wait events indicate what processes are waiting for:
This helps identify:
|
| review_settings | Review PostgreSQL configuration settings and get recommendations. Analyzes key performance-related settings:
Compares against best practices and system resources. |
| analyze_table_bloat | Analyze table bloat using the pgstattuple extension. Note: This tool analyzes only user/client tables and excludes PostgreSQL system tables (pg_catalog, information_schema, pg_toast). This focuses the analysis on your application's custom tables. Uses pgstattuple to get accurate tuple-level statistics including:
This helps identify tables that:
Requires the pgstattuple extension to be installed: CREATE EXTENSION IF NOT EXISTS pgstattuple; Note: pgstattuple performs a full table scan, so use with caution on large tables. For large tables, consider using pgstattuple_approx instead (use_approx=true). |
| analyze_index_bloat | Analyze index bloat using pgstatindex from pgstattuple extension. Note: This tool analyzes only user/client indexes and excludes PostgreSQL system indexes (pg_catalog, information_schema, pg_toast). This focuses the analysis on your application's custom indexes. Uses pgstatindex to get B-tree index statistics including:
Helps identify indexes that:
Requires the pgstattuple extension: CREATE EXTENSION IF NOT EXISTS pgstattuple; Note: Also supports GIN indexes (pgstatginindex) and Hash indexes (pgstathashindex). |
| get_bloat_summary | Get a comprehensive summary of database bloat across tables and indexes. Note: This tool analyzes only user/client tables and indexes, excluding PostgreSQL system objects (pg_catalog, information_schema, pg_toast). This focuses the analysis on your application's custom objects. Provides a high-level overview of:
Uses pgstattuple_approx for tables (faster) and pgstatindex for B-tree indexes. Requires the pgstattuple extension to be installed. Best for: Quick assessment of database bloat and maintenance priorities. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
| diagnose_slow_queries | Analyze slow queries and provide optimization recommendations. This prompt guides the AI to systematically investigate query performance issues. |
| index_optimization | Comprehensive index analysis including unused indexes, missing indexes, and hypothetical index testing recommendations. |
| health_check | Perform a comprehensive PostgreSQL health assessment covering connections, cache ratios, locks, replication, and more. |
| query_tuning | Analyze a specific SQL query and provide detailed tuning recommendations including execution plan analysis and index suggestions. |
| performance_baseline | Generate a comprehensive performance baseline report including table statistics, query patterns, and configuration review. |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
| Tool Documentation | Complete documentation of all available PostgreSQL tuning tools |
| Workflow Guide | Common PostgreSQL performance tuning workflows and best practices |
| Prompt Templates | Documentation of available prompt templates for guided tuning sessions |