PostgreSQL-Performance-Tuner-Mcp
This MCP server provides comprehensive AI-powered PostgreSQL performance tuning through query analysis, index optimization, and database health monitoring.
Query Performance Analysis
Identify slow queries using pg_stat_statements with filtering by execution time, call frequency, and sorting options
Analyze execution plans with EXPLAIN ANALYZE showing actual vs estimated rows, timing, buffer usage, and I/O statistics
Monitor active queries, connection states, blocked queries, idle transactions, and wait events to identify bottlenecks
Index Optimization
Generate AI-powered index recommendations based on query workload patterns, frequency, and performance impact
Test hypothetical indexes using HypoPG extension without creating real indexes, comparing execution plans and estimating improvements
Identify unused, duplicate, or overlapping indexes that waste storage and slow write operations
Manage hypothetical indexes (create, list, drop, estimate size)
Database Health Monitoring
Comprehensive health checks covering connections, cache hit rates, locks, replication lag, transaction ID wraparound risk, and disk space
Detailed table statistics including size, row counts, dead tuple ratios, vacuum/analyze times, and scan frequencies
Configuration review for memory, checkpoints, WAL, autovacuum, and connections with best practice recommendations
Deployment Modes
Standard MCP mode (stdio-based) for MCP clients like Claude Desktop
Streamable HTTP mode with stateful/stateless session support
SSE mode for web applications
Docker support for all modes
Provides AI-powered PostgreSQL performance tuning capabilities including query analysis, index recommendations with HypoPG support, execution plan analysis, and database health monitoring for connections, vacuum operations, replication lag, and buffer cache performance.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PostgreSQL-Performance-Tuner-Mcpanalyze slow queries from the last hour and recommend indexes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PostgreSQL Performance Tuning MCP
A Model Context Protocol (MCP) server that provides AI-powered PostgreSQL performance tuning capabilities. This server helps identify slow queries, recommend optimal indexes, analyze execution plans, and leverage HypoPG for hypothetical index testing.
Features
Query Analysis
Retrieve slow queries from
pg_stat_statementswith detailed statisticsAnalyze query execution plans with
EXPLAINandEXPLAIN ANALYZEIdentify performance bottlenecks with automated plan analysis
Monitor active queries and detect long-running transactions
Index Tuning
AI-powered index recommendations based on query workload analysis
Hypothetical index testing with HypoPG extension (no disk usage)
Find unused and duplicate indexes for cleanup
Estimate index sizes before creation
Test query plans with proposed indexes before implementing
Database Health
Comprehensive health scoring with multiple checks
Connection utilization monitoring
Cache hit ratio analysis (buffer and index)
Lock contention detection
Vacuum health and transaction ID wraparound monitoring
Replication lag monitoring
Background writer and checkpoint analysis
Vacuum Monitoring
Track long-running VACUUM and VACUUM FULL operations in real-time
Monitor autovacuum progress and performance
Identify tables that need vacuuming
View recent vacuum activity history
Analyze autovacuum configuration effectiveness
I/O Performance Analysis
Analyze disk read/write patterns across tables and indexes
Identify I/O bottlenecks and hot tables
Monitor buffer cache hit ratios
Track temporary file usage indicating work_mem issues
Analyze checkpoint and background writer I/O
PostgreSQL 16+ enhanced pg_stat_io metrics support
Configuration Analysis
Review PostgreSQL settings by category
Get recommendations for memory, checkpoint, WAL, autovacuum, and connection settings
Identify suboptimal configurations
MCP Prompts & Resources
Pre-defined prompt templates for common tuning workflows
Dynamic resources for table stats, index info, and health checks
Comprehensive documentation resources
Related MCP server: PostgreSQL MCP
Installation
Standard Installation (for MCP clients like Claude Desktop)
pip install pgtuner_mcpOr using uv:
uv pip install pgtuner_mcpManual Installation
git clone https://github.com/isdaniel/pgtuner_mcp.git
cd pgtuner_mcp
pip install -e .Configuration
Environment Variables
Variable | Description | Required |
| PostgreSQL connection string | Yes |
| Comma-separated list of user IDs (OIDs) to exclude from monitoring | No |
| Per-statement timeout in ms (default 30000, 0=disable) | No |
| Idle-in-txn timeout in ms (default 60000) | No |
| Lock timeout in ms (default 5000) | No |
| Comma-separated CORS allowlist; | No |
| Comma-separated rule IDs to disable in linter | No |
Connection String Format: postgresql://user:password@host:port/database
Minimal User Permissions
To run this MCP server, the PostgreSQL user requires specific permissions to query system catalogs and extensions. Below are the minimal permissions needed for different feature sets.
Basic Permissions (Required for Core Functionality)
-- Create a dedicated monitoring user
CREATE USER pgtuner_monitor WITH PASSWORD 'secure_password';
-- Grant connection to the target database
GRANT CONNECT ON DATABASE your_database TO pgtuner_monitor;
-- Grant usage on schemas
GRANT USAGE ON SCHEMA public TO pgtuner_monitor;
GRANT USAGE ON SCHEMA pg_catalog TO pgtuner_monitor;
-- Grant SELECT on user tables and indexes (for table stats and analysis)
GRANT SELECT ON ALL TABLES IN SCHEMA public TO pgtuner_monitor;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO pgtuner_monitor;
-- Grant access to system catalog views (read-only)
GRANT pg_read_all_stats TO pgtuner_monitor; -- PostgreSQL 10+Extension-Specific Permissions
For pgstattuple (Bloat Detection):
-- Create the extension (requires superuser or appropriate privileges)
CREATE EXTENSION IF NOT EXISTS pgstattuple;
-- Grant execution on pgstattuple functions
GRANT EXECUTE ON FUNCTION pgstattuple(regclass) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION pgstattuple_approx(regclass) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION pgstatindex(regclass) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION pgstatginindex(regclass) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION pgstathashindex(regclass) TO pgtuner_monitor;
-- Alternative: Use pg_stat_scan_tables role (PostgreSQL 14+)
GRANT pg_stat_scan_tables TO pgtuner_monitor;For HypoPG (Hypothetical Index Testing):
-- Create the extension (requires superuser or appropriate privileges)
CREATE EXTENSION IF NOT EXISTS hypopg;
-- Grant SELECT on HypoPG views
GRANT SELECT ON hypopg_list_indexes TO pgtuner_monitor;
GRANT SELECT ON hypopg_hidden_indexes TO pgtuner_monitor;
-- Grant execution on HypoPG functions with proper signatures
GRANT EXECUTE ON FUNCTION hypopg_create_index(text) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_drop_index(oid) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_reset() TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_hide_index(oid) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_unhide_index(oid) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_relation_size(oid) TO pgtuner_monitor;
-- Note: HypoPG operations are session-scoped and don't affect the actual databaseComplete Setup Script
-- 1. Create the monitoring user
CREATE USER pgtuner_monitor WITH PASSWORD 'secure_password';
-- 2. Grant connection and schema access
GRANT CONNECT ON DATABASE your_database TO pgtuner_monitor;
GRANT USAGE ON SCHEMA public TO pgtuner_monitor;
-- 3. Grant read access to user tables
GRANT SELECT ON ALL TABLES IN SCHEMA public TO pgtuner_monitor;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO pgtuner_monitor;
-- 4. Grant system statistics access
GRANT pg_read_all_stats TO pgtuner_monitor; -- PostgreSQL 10+
-- Grant access to pg_stat_statements views explicitly
GRANT SELECT ON pg_stat_statements TO pgtuner_monitor;
GRANT SELECT ON pg_stat_statements_info TO pgtuner_monitor;
-- 5. Install and grant access to extensions (as superuser)
-- pg_stat_statements (required)
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
-- pgstattuple (for bloat detection)
CREATE EXTENSION IF NOT EXISTS pgstattuple;
GRANT pg_stat_scan_tables TO pgtuner_monitor; -- PostgreSQL 14+
-- OR grant individual functions:
-- GRANT EXECUTE ON FUNCTION pgstattuple(regclass) TO pgtuner_monitor;
-- GRANT EXECUTE ON FUNCTION pgstattuple_approx(regclass) TO pgtuner_monitor;
-- GRANT EXECUTE ON FUNCTION pgstatindex(regclass) TO pgtuner_monitor;
-- hypopg (for hypothetical index testing)
CREATE EXTENSION IF NOT EXISTS hypopg;
GRANT SELECT ON hypopg_list_indexes TO pgtuner_monitor;
GRANT SELECT ON hypopg_hidden_indexes TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_create_index(text) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_drop_index(oid) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_reset() TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_hide_index(oid) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_unhide_index(oid) TO pgtuner_monitor;
GRANT EXECUTE ON FUNCTION hypopg_relation_size(oid) TO pgtuner_monitor;
-- 6. Verify permissions
SET ROLE pgtuner_monitor;
SELECT * FROM pg_stat_statements LIMIT 1;
SELECT * FROM pg_stat_activity WHERE pid = pg_backend_pid();
SELECT * FROM pgstattuple('pg_class') LIMIT 1;
SELECT * FROM hypopg_list_indexes();
RESET ROLE;Excluding Specific Users from Monitoring
You can exclude specific PostgreSQL users from being included in query analysis and monitoring results. This is useful for filtering out:
Monitoring or replication users
System accounts
Internal application service accounts
Set the PGTUNER_EXCLUDE_USERIDS environment variable with a comma-separated list of user OIDs:
# Exclude user IDs 16384, 16385, and 16386
export PGTUNER_EXCLUDE_USERIDS="16384,16385,16386"To find the OID for a specific PostgreSQL user:
SELECT usesysid, usename FROM pg_user WHERE usename = 'monitoring_user';When configured, the following queries are filtered:
pg_stat_activityqueries (filters onusesysidcolumn)pg_stat_statementsqueries (filters onuseridcolumn)
This affects tools like get_slow_queries, get_active_queries, analyze_wait_events, check_database_health, and get_index_recommendations.
MCP Client Configuration
Add to your cline_mcp_settings.json or Claude Desktop config:
{
"mcpServers": {
"pgtuner_mcp": {
"command": "python",
"args": ["-m", "pgtuner_mcp"],
"env": {
"DATABASE_URI": "postgresql://user:password@localhost:5432/mydb"
},
"disabled": false,
"autoApprove": []
}
}
}Or Streamable HTTP Mode
{
"mcpServers": {
"pgtuner_mcp": {
"type": "http",
"url": "http://localhost:8080/mcp"
}
}
}Security Hardening
pgtuner_mcp HTTP modes (sse, streamable-http) do not include authentication. They are safe for local-only use; for any networked deployment you MUST front them with a reverse proxy that handles auth and TLS.
Connection-level safeguards (built in)
Every connection started by the pool receives session-level guards via libpq options at handshake time:
Env | Default | Effect |
|
| Per-statement cap. Caps |
|
| Kills orphaned transactions. Set |
|
| Caps the tuning user's wait on application locks. |
Belt-and-braces — also pin on the monitoring role:
ALTER ROLE pgtuner_monitor SET statement_timeout = '30s';
ALTER ROLE pgtuner_monitor SET idle_in_transaction_session_timeout = '60s';CORS
Env | Default | Effect |
| (default: any localhost/127.0.0.1 port, http or https) | Comma-separated allowlist. Setting it switches off the localhost regex default and uses literal-origin matching. Use |
Recommended reverse-proxy template (Caddy)
mcp.example.com {
basicauth {
teamuser <hashed_password>
}
reverse_proxy localhost:8080
}What is NOT included
No Bearer-token / API-key auth (operator concern — see reverse proxy)
No rate limiting (operator concern)
No in-process TLS (use the reverse proxy)
No per-client tool allowlist
Server Modes
1. Standard MCP Mode (Default)
# Default mode (stdio)
python -m pgtuner_mcp
# Explicitly specify stdio mode
python -m pgtuner_mcp --mode stdio2. HTTP SSE Mode (Legacy Web Applications)
The SSE (Server-Sent Events) mode provides a web-based transport for MCP communication. It's useful for web applications and clients that need HTTP-based communication.
# Start SSE server on default host/port (0.0.0.0:8080)
python -m pgtuner_mcp --mode sse
# Specify custom host and port
python -m pgtuner_mcp --mode sse --host localhost --port 3000
# Enable debug mode
python -m pgtuner_mcp --mode sse --debugSSE Endpoints:
Endpoint | Method | Description |
| GET | SSE connection endpoint - clients connect here to receive server events |
| POST | Send messages/requests to the server |
MCP Client Configuration for SSE:
For MCP clients that support SSE transport (like Claude Desktop or custom clients):
{
"mcpServers": {
"pgtuner_mcp": {
"type": "sse",
"url": "http://localhost:8080/sse"
}
}
}3. Streamable HTTP Mode (Modern MCP Protocol - Recommended)
The streamable-http mode implements the modern MCP Streamable HTTP protocol with a single /mcp endpoint. It supports both stateful (session-based) and stateless modes.
# Start Streamable HTTP server in stateful mode (default)
python -m pgtuner_mcp --mode streamable-http
# Start in stateless mode (fresh transport per request)
python -m pgtuner_mcp --mode streamable-http --stateless
# Specify custom host and port
python -m pgtuner_mcp --mode streamable-http --host localhost --port 8080
# Enable debug mode
python -m pgtuner_mcp --mode streamable-http --debugStateful vs Stateless:
Stateful (default): Maintains session state across requests using
mcp-session-idheader. Ideal for long-running interactions.Stateless: Creates a fresh transport for each request with no session tracking. Ideal for serverless deployments or simple request/response patterns.
Endpoint: http://{host}:{port}/mcp
Available Tools
Note: All tools focus exclusively on user/application tables and indexes. System catalog tables (
pg_catalog,information_schema,pg_toast) are automatically excluded from all analyses.
Performance Analysis Tools
Tool | Description |
| Retrieve slow queries from pg_stat_statements with detailed stats (total time, mean time, calls, cache hit ratio). Excludes system catalog queries. |
| Analyze a query's execution plan with EXPLAIN ANALYZE, including automated issue detection |
| Get detailed table statistics including size, row counts, dead tuples, and access patterns |
| Analyze disk I/O read/write patterns, identify hot tables, buffer cache efficiency, and I/O bottlenecks. Supports filtering by analysis type (all, buffer_pool, tables, indexes, temp_files, checkpoints). |
Index Tuning Tools
Tool | Description |
| AI-powered index recommendations based on query workload analysis |
| Run EXPLAIN with hypothetical indexes to test improvements without creating real indexes |
| Create, list, drop, or reset HypoPG hypothetical indexes. Supports hide/unhide existing indexes. |
| Find unused and duplicate indexes that can be safely dropped |
Database Health Tools
Tool | Description |
| Comprehensive health check with scoring (connections, cache, locks, replication, wraparound, disk, checkpoints) |
| Monitor active queries, find long-running transactions and blocked queries. By default excludes system processes. |
| Analyze wait events to identify I/O, lock, or CPU bottlenecks. Focuses on client backend processes. |
| Review PostgreSQL settings by category with optimization recommendations |
Bloat Detection Tools (pgstattuple)
Tool | Description |
| Analyze table bloat using pgstattuple extension. Shows dead tuple counts, free space, and wasted space percentage. |
| Analyze B-tree index bloat using pgstatindex. Shows leaf density, fragmentation, and empty/deleted pages. Also supports GIN and Hash indexes. |
| Get a comprehensive overview of database bloat with top bloated tables/indexes, total reclaimable space, and priority maintenance actions. |
Vacuum Monitoring Tools
Tool | Description |
| Track manual VACUUM, VACUUM FULL, and autovacuum operations. Monitor progress percentage, dead tuples collected, index vacuum rounds, and estimated time remaining. Includes autovacuum configuration review and tables needing maintenance. |
Tool Parameters
get_slow_queries
limit: Maximum queries to return (default: 10)min_calls: Minimum call count filter (default: 1)min_mean_time_ms: Minimum mean (average) execution time in milliseconds filterorder_by: Sort bymean_time,calls, orrows
analyze_query
query(required): SQL query to analyzeanalyze: Execute query with EXPLAIN ANALYZE (default: true)buffers: Include buffer statistics (default: true)format: Output format -json,text,yaml,xml
get_index_recommendations
workload_queries: Optional list of specific queries to analyzemax_recommendations: Maximum recommendations (default: 10)min_improvement_percent: Minimum improvement threshold (default: 10%)include_hypothetical_testing: Test with HypoPG (default: true)target_tables: Focus on specific tables
check_database_health
include_recommendations: Include actionable recommendations (default: true)verbose: Include detailed statistics (default: false)
analyze_table_bloat
table_name: Name of a specific table to analyze (optional)schema_name: Schema name (default:public)use_approx: Usepgstattuple_approxfor faster analysis on large tables (default: false)min_table_size_gb: Minimum table size in GB to include in schema-wide scan (default: 5)include_toast: Include TOAST table analysis (default: false)
analyze_index_bloat
index_name: Name of a specific index to analyze (optional)table_name: Analyze all indexes on this table (optional)schema_name: Schema name (default:public)min_index_size_gb: Minimum index size in GB to include (default: 5)min_bloat_percent: Only show indexes with bloat above this percentage (default: 20)
get_bloat_summary
schema_name: Schema to analyze (default:public)top_n: Number of top bloated objects to show (default: 10)min_size_gb: Minimum object size in GB to include (default: 5)
monitor_vacuum_progress
action: Action to perform -progress(monitor active vacuum operations),needs_vacuum(find tables needing vacuum),autovacuum_status(review autovacuum configuration), orrecent_activity(view recent vacuum history)schema_name: Schema to analyze (default:public, used withneeds_vacuumaction)top_n: Number of results to return (default: 20)
analyze_disk_io_patterns
analysis_type: Type of I/O analysis -all(comprehensive),buffer_pool(cache hit ratios),tables(table I/O patterns),indexes(index I/O patterns),temp_files(temporary file usage), orcheckpoints(checkpoint I/O statistics)schema_name: Schema to analyze (default:public)top_n: Number of top I/O-intensive objects to show (default: 20)min_size_gb: Minimum object size in GB to include (default: 1)
MCP Prompts
The server includes pre-defined prompt templates for guided tuning sessions:
Prompt | Description |
| Systematic slow query investigation workflow |
| Comprehensive index analysis and cleanup |
| Full database health assessment |
| Optimize a specific SQL query |
| Generate a baseline report for comparison |
MCP Resources
Static Resources
pgtuner://docs/tools- Complete tool documentationpgtuner://docs/workflows- Common tuning workflows guidepgtuner://docs/prompts- Prompt template documentation
Dynamic Resource Templates
pgtuner://table/{schema}/{table_name}/stats- Table statisticspgtuner://table/{schema}/{table_name}/indexes- Table index informationpgtuner://query/{query_hash}/stats- Query performance statisticspgtuner://settings/{category}- PostgreSQL settings (memory, checkpoint, wal, autovacuum, connections, all)pgtuner://health/{check_type}- Health checks (connections, cache, locks, replication, bloat, all)
PostgreSQL Extension Setup
HypoPG Extension
HypoPG enables testing indexes without actually creating them. This is extremely useful for:
Testing if a proposed index would be used by the query planner
Comparing execution plans with different index strategies
Estimating storage requirements before committing
Enable HypoPG in Database
HypoPG enables testing hypothetical indexes without creating them on disk.
-- Create the extension
CREATE EXTENSION IF NOT EXISTS hypopg;
-- Verify installation
SELECT * FROM hypopg_list_indexes();pg_stat_statements Extension
The pg_stat_statements extension is required for query performance analysis. It tracks planning and execution statistics for all SQL statements executed by a server.
Step 1: Enable the Extension in postgresql.conf
Add the following to your postgresql.conf file:
# Required: Load pg_stat_statements module
shared_preload_libraries = 'pg_stat_statements'
# Required: Enable query identifier computation
compute_query_id = on
# Maximum number of statements tracked (default: 5000)
pg_stat_statements.max = 10000
# Track all statements including nested ones (default: top)
# Options: top, all, none
pg_stat_statements.track = top
# Track utility commands like CREATE, ALTER, DROP (default: on)
pg_stat_statements.track_utility = onNote: After modifying
shared_preload_libraries, a PostgreSQL server restart is required.
Step 2: Create the Extension in Your Database
-- Connect to your database and create the extension
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
-- Verify installation
SELECT * FROM pg_stat_statements LIMIT 1;pgstattuple Extension
The pgstattuple extension is required for bloat detection tools (analyze_table_bloat, analyze_index_bloat, get_bloat_summary). It provides functions to get tuple-level statistics for tables and indexes.
-- Create the extension
CREATE EXTENSION IF NOT EXISTS pgstattuple;
-- Verify installation
SELECT * FROM pgstattuple('pg_class') LIMIT 1;Performance Impact Considerations
Setting | Overhead | Recommendation |
| Low (~1-2%) | Always enable |
| Low-Medium (~2-5%) | Enable in production, test first |
| Low | Enable for function-heavy workloads |
| Medium | Enable only when investigating planning issues |
| Low | Recommended for slow query identification |
Tip: Use
pg_test_timingto measure the timing overhead on your specific system before enablingtrack_io_timing.
Example Usage
Find and Analyze Slow Queries
# Get top 10 slowest queries
slow_queries = await get_slow_queries(limit=10, order_by="total_time")
# Analyze a specific query's execution plan
analysis = await analyze_query(
query="SELECT * FROM orders WHERE user_id = 123",
analyze=True,
buffers=True
)Get Index Recommendations
# Analyze workload and get recommendations
recommendations = await get_index_recommendations(
max_recommendations=5,
min_improvement_percent=20,
include_hypothetical_testing=True
)
# Recommendations include CREATE INDEX statements
for rec in recommendations["recommendations"]:
print(rec["create_statement"])Database Health Check
# Run comprehensive health check
health = await check_database_health(
include_recommendations=True,
verbose=True
)
print(f"Health Score: {health['overall_score']}/100")
print(f"Status: {health['status']}")
# Review specific areas
for issue in health["issues"]:
print(f"{issue}")Find Unused Indexes
# Find indexes that can be dropped
unused = await find_unused_indexes(
schema_name="public",
include_duplicates=True
)
# Get DROP statements
for stmt in unused["recommendations"]:
print(stmt)Docker
docker pull dog830228/pgtuner_mcp
# Streamable HTTP mode (recommended for web applications)
docker run -p 8080:8080 \
-e DATABASE_URI=postgresql://user:pass@host:5432/db \
dog830228/pgtuner_mcp --mode streamable-http
# Streamable HTTP stateless mode (for serverless)
docker run -p 8080:8080 \
-e DATABASE_URI=postgresql://user:pass@host:5432/db \
dog830228/pgtuner_mcp --mode streamable-http --stateless
# SSE mode (legacy web applications)
docker run -p 8080:8080 \
-e DATABASE_URI=postgresql://user:pass@host:5432/db \
dog830228/pgtuner_mcp --mode sse
# stdio mode (for MCP clients like Claude Desktop)
docker run -i \
-e DATABASE_URI=postgresql://user:pass@host:5432/db \
dog830228/pgtuner_mcp --mode stdioRequirements
Python: 3.10+
PostgreSQL: 12+ (recommended: 14+)
Extensions:
pg_stat_statements(required for query analysis)hypopg(optional, for hypothetical index testing)
Dependencies
Core dependencies:
mcp[cli]>=1.12.0- Model Context Protocol SDKpsycopg[binary,pool]>=3.1.0- PostgreSQL adapter with connection poolingpglast>=7.10- PostgreSQL query parser
Optional (for HTTP modes):
starlette>=0.27.0- ASGI frameworkuvicorn>=0.23.0- ASGI server
Integration Testing
Integration tests exercise every MCP tool against a live PostgreSQL via Docker.
Quickstart
make up PG=16 # start PG16 container
make test-integration # run integration suite (defaults to PG=16)
make down # tear downSupported PG versions: 14, 15, 16, 17 (e.g., make up PG=17).
CI runs the suite on every PR across all four PG versions via .github/workflows/integration.yml.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Available Tools
14 toolsanalyze_index_bloatARead-onlyIdempotent
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:
Leaf page density (avg_leaf_density) - lower values indicate more bloat
Fragmentation percentage
Empty and deleted pages
Helps identify indexes that:
Need REINDEX to improve performance
Have high fragmentation
Are wasting storage space
Requires the pgstattuple extension: CREATE EXTENSION IF NOT EXISTS pgstattuple;
Note: Also supports GIN indexes (pgstatginindex) and Hash indexes (pgstathashindex).
| Name | Required | Description | Default |
|---|---|---|---|
| index_name | No | Name of a specific index to analyze | |
| table_name | No | Analyze all indexes on this table | |
| schema_name | No | Schema name (default: public) | public |
| min_index_size_gb | No | Minimum index size in GB to include (default: 5) | |
| min_bloat_percent | No | Only show indexes with bloat above this percentage (default: 20) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false, covering safety and idempotency. The description adds valuable context beyond this: it specifies the tool analyzes only user indexes (excluding system ones), requires the pgstattuple extension, and lists the types of statistics returned (leaf page density, fragmentation percentage, empty/deleted pages), which helps the agent understand the tool's scope and prerequisites without contradicting annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with clear sections: purpose, scope exclusion, statistics details, use cases, prerequisites, and additional support. It is appropriately sized and front-loaded with key information, though the note about GIN/Hash indexes at the end could be integrated more seamlessly, and some sentences are slightly verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (5 parameters, no output schema), the description is mostly complete: it explains the tool's purpose, scope, statistics, use cases, and prerequisites. However, it lacks details on output format (e.g., what the return data looks like) and does not mention performance implications or limitations (e.g., impact on database during analysis), leaving minor gaps in contextual understanding.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the input schema fully documents all five parameters (index_name, table_name, schema_name, min_index_size_gb, min_bloat_percent). The description does not add any parameter-specific details beyond what the schema provides, such as explaining interactions between parameters or usage examples, so it meets the baseline of 3 without compensating for gaps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool analyzes index bloat using pgstatindex, specifies it focuses on user/client indexes while excluding system indexes, and distinguishes it from sibling tools like analyze_table_bloat and get_bloat_summary by its specific focus on index-level analysis rather than table-level or summary-level analysis.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for when to use this tool (to identify indexes needing REINDEX, with high fragmentation, or wasting storage) and mentions it supports GIN and Hash indexes via other functions. However, it does not explicitly state when not to use it or directly compare it to alternatives like find_unused_indexes or get_index_recommendations among the siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
analyze_queryAIdempotent
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:
Execution plan with actual vs estimated rows
Timing breakdown by operation
Buffer usage and I/O statistics
Potential performance issues and recommendations
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.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL query to analyze | |
| analyze | No | Whether to actually execute the query (EXPLAIN ANALYZE vs EXPLAIN) | |
| buffers | No | Include buffer usage statistics | |
| verbose | No | Include verbose output with additional details | |
| format | No | Output format for the execution plan | json |
| settings | No | Include information about configuration parameters |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds valuable behavioral context beyond annotations. While annotations indicate idempotentHint=true and destructiveHint=false, the description clarifies that 'This actually executes the query!' and provides specific warnings about data modification queries. It also explains the tool's approach (EXPLAIN ANALYZE) and what analysis it provides, which annotations don't cover.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded with the core purpose, followed by implementation details, analysis components, and critical warnings. Every sentence adds value: the first states purpose, second explains method, third lists analysis areas, fourth provides crucial safety guidance. No wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (executes queries, provides performance analysis) and rich annotations, the description is mostly complete. It explains what the tool does, how it works, what it analyzes, and critical safety considerations. The main gap is lack of output format details (no output schema exists), but the description compensates somewhat by listing analysis components.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the input schema already documents all 6 parameters thoroughly. The description doesn't add significant parameter-specific information beyond what's in the schema, though it implies the 'query' parameter is central and mentions 'analyze_only=false' (referring to the 'analyze' parameter). Baseline 3 is appropriate when schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Analyze a SQL query's execution plan and performance characteristics' with specific details about what it provides (execution plan analysis, timing breakdown, buffer usage, performance issues). It distinguishes from siblings like 'explain_with_indexes' by emphasizing actual execution with EXPLAIN ANALYZE and comprehensive performance analysis.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit usage guidance: 'For SELECT queries this is safe, but be careful with INSERT/UPDATE/DELETE - use analyze_only=false for those.' This clearly indicates when to use caution and mentions an alternative approach (setting analyze=false) for non-SELECT queries, helping distinguish from read-only analysis tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
analyze_table_bloatARead-onlyIdempotent
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:
Dead tuple count and percentage
Free space within the table
Physical vs logical table size
This helps identify tables that:
Need VACUUM to reclaim space
Need VACUUM FULL to reclaim disk space
Have high bloat affecting performance
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).
| Name | Required | Description | Default |
|---|---|---|---|
| table_name | No | Name of the table to analyze (required if not using schema-wide scan) | |
| schema_name | No | Schema name (default: public) | public |
| use_approx | No | Use pgstattuple_approx for faster but approximate results (recommended for large tables) | |
| min_table_size_gb | No | Minimum table size in GB to include in schema-wide scan (default: 5) | |
| include_toast | No | Include TOAST table analysis if applicable |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already indicate readOnlyHint=true, destructiveHint=false, and idempotentHint=true, covering safety and idempotency. The description adds valuable context beyond this: it warns about performance impact (full table scan on large tables), mentions the need for extension installation, and clarifies scope (excludes system tables). No contradictions with annotations exist.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with clear sections (purpose, scope, statistics, use cases, prerequisites, and cautions). It's appropriately detailed for a complex tool, though slightly verbose. Every sentence adds value, such as explaining exclusion of system tables and performance considerations.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (5 parameters, no output schema) and rich annotations, the description is largely complete. It covers purpose, usage, behavioral traits, and context. However, it doesn't detail the output format or example results, which could be helpful since there's no output schema. This minor gap prevents a perfect score.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the input schema fully documents all 5 parameters. The description adds some semantic context by explaining the purpose of use_approx (for large tables) and the focus on user tables, but it doesn't provide additional parameter details beyond what's in the schema. This meets the baseline for high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool analyzes table bloat using the pgstattuple extension, specifying it focuses on user/client tables while excluding system tables. It distinguishes itself from sibling tools like 'get_bloat_summary' or 'get_table_stats' by emphasizing tuple-level statistics and bloat analysis for maintenance decisions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit guidance on when to use this tool (for identifying tables needing VACUUM or VACUUM FULL due to bloat) and when to consider alternatives (using pgstattuple_approx for large tables via use_approx=true). It also mentions prerequisites (pgstattuple extension installation) and cautions about full table scans on large tables.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
analyze_wait_eventsARead-onlyIdempotent
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:
Lock: Waiting for locks on tables/rows
IO: Waiting for disk I/O
CPU: Waiting for CPU time
Client: Waiting for client communication
Extension: Waiting in extension code
This helps identify:
I/O bottlenecks
Lock contention patterns
Resource saturation
| Name | Required | Description | Default |
|---|---|---|---|
| active_only | No | Only include active (running) queries |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds valuable behavioral context beyond what annotations provide. While annotations indicate read-only, non-destructive, and idempotent operations, the description explains what wait events represent (Lock, IO, CPU, Client, Extension) and what insights can be gained (I/O bottlenecks, lock contention patterns, resource saturation). This helps the agent understand the tool's analytical focus and output interpretation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and appropriately sized. It starts with the core purpose, adds an important note about scope, then provides explanatory context about wait events and insights. Every sentence adds value without redundancy. The bulleted lists efficiently convey information without unnecessary verbosity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's analytical nature, the absence of an output schema, and comprehensive annotations, the description provides good contextual completeness. It explains what wait events are, what they indicate, and what insights can be derived. However, it doesn't describe the format or structure of the analysis results, which would be helpful since there's no output schema provided.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage for the single parameter 'active_only', the schema already fully documents this parameter. The description doesn't add any additional parameter information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no parameter info in the description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Analyze PostgreSQL wait events to identify bottlenecks.' It specifies the resource (PostgreSQL wait events), the verb (analyze), and distinguishes it from siblings by focusing on client backend processes while excluding system background processes. This differentiation from tools like 'get_active_queries' or 'get_slow_queries' is explicit.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for when to use this tool: 'to help identify bottlenecks in your application queries.' It explicitly excludes system background processes, which helps differentiate it from general monitoring tools. However, it doesn't name specific alternatives among the sibling tools or provide explicit 'when-not-to-use' guidance beyond the exclusion mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
check_database_healthARead-onlyIdempotent
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:
Connection statistics and pool usage
Cache hit ratios (buffer and index)
Lock contention and blocking queries
Replication status (if configured)
Transaction wraparound risk
Disk space usage
Background writer statistics
Checkpoint frequency
Returns a health score with detailed breakdown and recommendations.
| Name | Required | Description | Default |
|---|---|---|---|
| include_recommendations | No | Include actionable recommendations | |
| verbose | No | Include detailed statistics |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already indicate read-only, non-destructive, and idempotent behavior, which the description does not contradict. The description adds valuable context by specifying the exclusion of PostgreSQL system tables from analysis and detailing the aspects analyzed (e.g., lock contention, replication status), which goes beyond the annotations to clarify scope and focus.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded, starting with the core purpose, followed by a note on scope, a bulleted list of analyzed aspects, and a summary of the output. Each sentence adds value without redundancy, making it efficient and easy to parse.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of a health check tool with no output schema, the description provides a thorough overview of what is analyzed and the output format (health score with breakdown and recommendations). It compensates well for the lack of output schema, though it could benefit from more explicit usage guidelines relative to siblings.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with clear documentation for both parameters ('include_recommendations' and 'verbose'). The description mentions that the tool 'returns a health score with detailed breakdown and recommendations,' which aligns with the parameters but does not add significant meaning beyond what the schema already provides, meeting the baseline for high coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool performs a 'comprehensive database health check' on PostgreSQL, specifying it analyzes user/client tables while excluding system tables. It distinguishes itself from sibling tools like 'get_table_stats' or 'analyze_index_bloat' by covering multiple aspects (e.g., connection statistics, cache ratios, replication) rather than focusing on a single metric.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for overall database monitoring and health assessment, with the note about excluding system tables providing some context. However, it does not explicitly state when to use this tool versus alternatives like 'get_bloat_summary' or 'review_settings', nor does it mention prerequisites or exclusions beyond the table scope.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
explain_with_indexesARead-onlyIdempotent
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:
Compare execution plans with and without specific indexes
Test if a proposed index would be used
Estimate the performance impact of new indexes
Returns both the original and hypothetical execution plans for comparison.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL query to explain | |
| hypothetical_indexes | No | List of hypothetical indexes to test | |
| analyze | No | Whether to use EXPLAIN ANALYZE (executes the query) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds valuable behavioral context beyond what annotations provide. While annotations indicate read-only, non-destructive, and idempotent operations, the description clarifies that this tool 'requires HypoPG extension for hypothetical testing' and that it 'returns both the original and hypothetical execution plans for comparison.' This provides important implementation details and output behavior that annotations don't cover.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is perfectly structured and concise - it starts with the core purpose, explains the unique value proposition, provides clear usage scenarios in bullet points, and ends with what the tool returns. Every sentence adds value with zero wasted words, and it's appropriately front-loaded with the most important information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with rich annotations (readOnlyHint, idempotentHint, destructiveHint all specified) and complete schema coverage, the description provides excellent context about the tool's unique capabilities and constraints. The only minor gap is the lack of output schema, but the description does specify what the tool returns ('both the original and hypothetical execution plans'), which partially compensates.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the input schema already documents all parameters thoroughly. The description doesn't add significant parameter semantics beyond what's in the schema, though it does provide context about the 'hypothetical_indexes' parameter's purpose ('to test without actually creating them'). This meets the baseline expectation when schema coverage is complete.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('Run EXPLAIN on a query') and resources ('hypothetical indexes'), distinguishing it from siblings like analyze_query or get_index_recommendations. It explicitly mentions the unique capability of testing indexes without creating them, which sets it apart from other analysis tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit guidance on when to use this tool ('to compare execution plans', 'test if a proposed index would be used', 'estimate performance impact'), and it implicitly distinguishes from alternatives by mentioning the HypoPG extension requirement. The sibling tools list shows clear alternatives like analyze_query (without hypothetical testing) and manage_hypothetical_indexes (which likely creates actual indexes).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
find_unused_indexesARead-onlyIdempotent
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:
Indexes with zero or very few scans since last stats reset
Duplicate indexes (same columns in same order)
Overlapping indexes (one index is a prefix of another)
Removing unused indexes can:
Reduce storage space
Speed up INSERT/UPDATE/DELETE operations
Reduce vacuum and maintenance overhead
| Name | Required | Description | Default |
|---|---|---|---|
| schema_name | No | Schema to analyze (default: public) | public |
| min_size_mb | No | Minimum index size in MB to include | |
| include_duplicates | No | Include analysis of duplicate/overlapping indexes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already indicate read-only, non-destructive, and idempotent behavior, which the description does not contradict. The description adds valuable context beyond annotations: it specifies scope limitations (excludes system catalogs, focuses on custom tables), identifies what gets analyzed (zero/few scans, duplicates, overlaps), and lists benefits of acting on results (storage reduction, speed improvements). However, it lacks details on rate limits or exact output format.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and appropriately sized, with a clear purpose statement upfront, followed by a note on scope, a bulleted list of what it identifies, and a bulleted list of benefits. Every sentence adds value without redundancy, and it is front-loaded with the core functionality.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (analysis tool with 3 parameters), rich annotations (read-only, idempotent), and no output schema, the description is mostly complete: it covers purpose, scope, what it identifies, and benefits. However, it does not detail the output format or potential limitations (e.g., analysis time, database impact), leaving a minor gap for an agent to fully understand results.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents all parameters (schema_name, min_size_mb, include_duplicates) with descriptions and defaults. The description does not add further meaning or syntax details for these parameters, such as how 'min_size_mb' affects analysis or examples of schema names. Baseline 3 is appropriate as the schema handles parameter documentation adequately.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('find', 'analyzes', 'identifies') and resources ('indexes'), distinguishing it from siblings like 'analyze_index_bloat' or 'get_index_recommendations' by focusing on unused/duplicate detection rather than bloat or recommendations. It explicitly lists what it identifies: indexes with few scans, duplicates, and overlapping indexes.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context on when to use this tool: for analyzing user/client indexes on custom tables, excluding system catalogs. It implicitly suggests usage for performance optimization (e.g., 'Removing unused indexes can...'), but does not explicitly state when not to use it or name specific alternatives among siblings, such as 'analyze_index_bloat' for different analysis types.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_active_queriesARead-onlyIdempotent
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:
All active queries and their duration
Idle transactions that may be holding locks
Blocked queries waiting for locks
Connection state breakdown
Useful for:
Identifying long-running queries
Finding queries that might need optimization
Detecting stuck transactions
Troubleshooting lock contention
| Name | Required | Description | Default |
|---|---|---|---|
| min_duration_seconds | No | Minimum query duration in seconds to include | |
| include_idle | No | Include idle connections | |
| include_system | No | Include system/background processes | |
| database | No | Filter by specific database |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already provide readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false, covering safety and idempotency. The description adds valuable behavioral context beyond annotations: it explains default filtering behavior (excludes system/background processes), specifies what types of queries are shown (active queries, idle transactions, blocked queries, connection states), and mentions the tool's analytical purpose for optimization and troubleshooting. No contradiction with annotations exists.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded: the first sentence states the core purpose, followed by a 'Note:' section for important clarifications, a 'Shows:' bullet list for output details, and a 'Useful for:' section for usage context. Every sentence adds value without redundancy, and the bullet points enhance readability.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (4 parameters, no output schema), the description is largely complete. It explains the tool's purpose, usage guidelines, behavioral traits, and output scope. However, without an output schema, it doesn't detail the exact structure of returned data (e.g., fields, formats), which is a minor gap. The annotations provide safety context, and the description compensates well for the lack of output schema with the 'Shows:' section.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with all 4 parameters well-documented in the schema itself. The description doesn't add significant parameter semantics beyond what's in the schema, though it implies the tool's default behavior aligns with parameter defaults (e.g., excluding system processes unless include_system=true). This meets the baseline of 3 for high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Get information about currently active queries and connections.' It specifies the resource (active queries and connections) and distinguishes from siblings like 'get_slow_queries' by focusing on currently running queries rather than historical slow ones. The 'Shows:' section further elaborates on what information is retrieved.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit guidance on when to use this tool: 'Useful for: Identifying long-running queries, Finding queries that might need optimization, Detecting stuck transactions, Troubleshooting lock contention.' It also distinguishes from siblings by noting this tool focuses on active queries while tools like 'get_slow_queries' likely focus on historical performance. The 'Note:' section clarifies default exclusions (system processes) and when to include them.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_bloat_summaryARead-onlyIdempotent
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:
Top bloated tables by wasted space
Top bloated indexes by estimated bloat
Total reclaimable space estimates
Priority maintenance recommendations
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.
| Name | Required | Description | Default |
|---|---|---|---|
| schema_name | No | Schema to analyze (default: public) | public |
| top_n | No | Number of top bloated objects to show (default: 10) | |
| min_size_gb | No | Minimum object size in GB to include (default: 5) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds valuable behavioral context beyond annotations: it discloses the tool's scope limitation (excludes PostgreSQL system objects), technical implementation details (uses pgstattuple_approx and pgstatindex), and prerequisites (requires pgstattuple extension). While annotations cover safety aspects (readOnlyHint, destructiveHint), the description enriches understanding of what the tool actually does and its constraints.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and appropriately sized. It starts with the core purpose, provides important notes and scope limitations, lists what the tool provides, mentions implementation details, and ends with usage guidance. Every sentence adds value without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity and the absence of an output schema, the description provides substantial context about what the tool returns (high-level overview with specific categories) and its behavioral characteristics. The annotations cover safety aspects well, and the description adds important operational context, though it could potentially provide more detail about output format.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the input schema already fully documents all three parameters. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline expectation but doesn't provide extra semantic value for parameter understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('get', 'analyzes', 'provides') and resources ('database bloat across tables and indexes'). It distinguishes from siblings by focusing specifically on comprehensive bloat analysis rather than granular analysis (like analyze_table_bloat or analyze_index_bloat) or other database functions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit usage guidance with a 'Best for:' section that states 'Quick assessment of database bloat and maintenance priorities.' It also distinguishes from alternatives by noting it analyzes only user/client tables and indexes, excluding system objects, which helps differentiate it from other analysis tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_index_recommendationsARead-onlyIdempotent
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:
Identifies slow queries and their access patterns
Extracts columns used in WHERE, JOIN, ORDER BY, and GROUP BY clauses
Generates candidate indexes (single-column and composite)
If HypoPG is available, tests indexes without creating them
Uses a greedy optimization algorithm to select the best index set
Note: This tool focuses on user/client tables only and excludes system catalog tables (pg_catalog, information_schema, pg_toast).
The recommendations consider:
Query frequency and total execution time
Estimated improvement from each index
Index size and maintenance overhead
Avoiding redundant indexes
| Name | Required | Description | Default |
|---|---|---|---|
| workload_queries | No | Optional list of specific queries to analyze. If not provided, uses pg_stat_statements. | |
| max_recommendations | No | Maximum number of index recommendations to return | |
| min_improvement_percent | No | Minimum improvement percentage for a recommendation to be included | |
| include_hypothetical_testing | No | Whether to test indexes using HypoPG (if available) | |
| target_tables | No | Optional list of tables to focus on |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already provide readOnlyHint=true, destructiveHint=false, and idempotentHint=true, indicating safe, non-destructive operations. The description adds valuable context beyond annotations: it explains the sophisticated 5-step algorithm, mentions HypoPG testing, and details what factors the recommendations consider (query frequency, improvement estimates, index size, avoiding redundancy).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with clear sections: purpose statement, algorithm breakdown, scope limitations, and recommendation factors. While comprehensive, it could be slightly more concise by combining some of the numbered algorithm steps into fewer sentences without losing clarity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (sophisticated algorithm, 5 parameters) and rich annotations, the description provides substantial context about behavior, scope, and methodology. However, without an output schema, it doesn't describe the format or structure of the recommendations returned, which is a minor gap for a recommendation-generating tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the input schema already documents all 5 parameters thoroughly. The description doesn't add significant parameter-specific information beyond what's in the schema, though it provides context about workload analysis and table focus that relates to parameters like 'workload_queries' and 'target_tables'.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool 'Get AI-powered index recommendations for your database' with specific details about analyzing query workload and recommending indexes to improve performance. It distinguishes from siblings like 'find_unused_indexes' or 'analyze_index_bloat' by focusing on generating new index recommendations rather than analyzing existing ones.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context about when to use this tool: for analyzing query workload and getting index recommendations. It mentions exclusions (system catalog tables) but doesn't explicitly state when to use alternatives like 'explain_with_indexes' or 'manage_hypothetical_indexes' for specific scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_slow_queriesARead-onlyIdempotent
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:
Query text (normalized)
Total execution time
Number of calls
Mean execution time
Rows returned
Shared buffer hits/reads for cache analysis
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of slow queries to return (default: 10) | |
| min_calls | No | Minimum number of calls for a query to be included (default: 1) | |
| min_total_time_ms | No | Minimum total execution time in milliseconds (default: 0) | |
| order_by | No | Column to order results by | total_time |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds valuable behavioral context beyond what annotations provide. While annotations declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, the description adds that it 'Requires the pg_stat_statements extension to be enabled' and specifies what types of queries are excluded (system catalog queries). It also details the specific metrics returned, providing important operational context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and front-loaded with the core purpose, followed by prerequisites, scope limitations, and detailed output information. Every sentence adds value without redundancy. The bulleted list of returned metrics is particularly efficient for conveying complex information clearly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a read-only analysis tool with good annotations but no output schema, the description provides comprehensive context about what the tool does, prerequisites, scope limitations, and detailed output format. The main gap is the lack of output schema, but the description compensates well by explicitly listing all returned metrics with their semantic meaning.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the input schema already fully documents all 4 parameters with descriptions, defaults, and constraints. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline expectation but doesn't provide additional semantic context about how parameters interact or affect results.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Retrieve slow queries from PostgreSQL using pg_stat_statements' with specific details about what it returns ('top N slowest queries ordered by total execution time'). It distinguishes from siblings like 'get_active_queries' by focusing on historical performance data rather than currently running queries.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for when to use this tool: analyzing slow queries with pg_stat_statements enabled, focusing on user/application queries while excluding system catalog queries. However, it doesn't explicitly mention when NOT to use it or name specific alternatives among the sibling tools for different performance analysis needs.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_table_statsARead-onlyIdempotent
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:
Table size (data, indexes, total)
Row counts and dead tuple ratio
Last vacuum and analyze times
Sequential vs index scan ratios
Cache hit ratios
This helps identify tables that may need maintenance (VACUUM, ANALYZE) or have performance issues.
| Name | Required | Description | Default |
|---|---|---|---|
| schema_name | No | Schema to analyze (default: public) | public |
| table_name | No | Specific table to analyze (optional, analyzes all tables if not provided) | |
| include_indexes | No | Include index statistics | |
| order_by | No | Order results by this metric | size |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds valuable behavioral context beyond what annotations provide. While annotations already indicate it's read-only, non-destructive, and idempotent, the description adds important details: it analyzes only user-created tables (excluding system tables), focuses on application custom tables, and explains what kind of maintenance issues it helps identify. No contradiction with annotations exists.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and appropriately sized. It starts with the core purpose, provides important exclusion notes, lists what information is returned, and ends with the practical value. Every sentence adds meaningful information with zero waste.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a read-only analysis tool with good annotations and comprehensive input schema, the description provides excellent context about scope (user tables only), output content (specific statistics listed), and practical application (identifying maintenance needs). The main gap is the lack of output schema, but the description compensates by detailing what information is returned.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 100% schema description coverage, the input schema already documents all parameters thoroughly. The description doesn't add significant parameter-specific information beyond what's in the schema, though it does provide context about what tables are analyzed (user-created vs system tables) which relates to the schema_name parameter's usage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Get detailed statistics for user/client database tables' with specific details about what statistics are returned (table size, row counts, scan ratios, etc.). It distinguishes from sibling tools by focusing on table statistics rather than index analysis, query analysis, or other database health checks.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for when to use this tool: 'This helps identify tables that may need maintenance (VACUUM, ANALYZE) or have performance issues.' It also notes what tables are excluded (system tables). However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
manage_hypothetical_indexesA
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:
create: Create a new hypothetical index by specifying table and columns
list: List all current hypothetical indexes
drop: Drop a specific hypothetical index
reset: Drop all hypothetical indexes
estimate_size: Estimate the size of a hypothetical index
check: Check HypoPG extension status and availability
hide: Hide an existing real index from the query planner (useful for testing what-if scenarios)
unhide: Unhide a previously hidden index
list_hidden: List all currently hidden indexes
explain_with_index: Create a hypothetical index and explain a query with before/after comparison
This is useful for:
Testing if an index would improve a query
Comparing different index strategies
Estimating index storage requirements
Testing query performance without specific existing indexes (hide)
Simulating index removal scenarios
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform | |
| table | No | Table name (required for create, estimate_size, explain_with_index) | |
| columns | No | Column names for the index (required for create, estimate_size, explain_with_index) | |
| index_type | No | Type of index to create | btree |
| unique | No | Whether the index should be unique | |
| index_id | No | Index OID (required for drop, hide, unhide) | |
| query | No | SQL query to explain (required for explain_with_index) | |
| schema | No | Schema name for the table (optional, for create and explain_with_index) | |
| where | No | Partial index WHERE condition (optional, for create) | |
| include | No | Columns to include in INCLUDE clause (optional, for create) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations indicate readOnlyHint=false, destructiveHint=false, etc., covering basic safety. The description adds valuable behavioral context beyond annotations: it explains that indexes are in-memory only (not persisted), lists specific actions like 'reset' that drop all indexes, and mentions testing scenarios without affecting real indexes. No contradiction with annotations exists.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with clear sections (overview, actions list, use cases) and avoids redundancy. However, it's moderately lengthy due to enumerating 10 actions and use cases; some sentences could be more condensed while maintaining clarity, slightly affecting efficiency.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (10 parameters, multiple actions) and lack of output schema, the description provides comprehensive context on actions and use cases. It compensates well for missing output details by explaining what each action does, though it could briefly mention expected return types or error handling for full completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, providing full parameter documentation. The description adds minimal parameter semantics beyond the schema, mainly by listing actions and their purposes without detailing parameter interactions or constraints. This meets the baseline for high schema coverage but doesn't enhance understanding significantly.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool manages HypoPG hypothetical indexes for testing, specifying it creates in-memory indexes to test query plans without creating real ones. It distinguishes from siblings by focusing on hypothetical index management rather than analysis, recommendations, or real index operations found in tools like 'explain_with_indexes' or 'find_unused_indexes'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly lists 10 specific actions with their purposes and includes a 'This is useful for' section detailing scenarios like testing query improvements, comparing strategies, and simulating index removal. It provides clear when-to-use guidance by contrasting with real index operations and outlining practical testing contexts.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
review_settingsARead-onlyIdempotent
Review PostgreSQL configuration settings and get recommendations.
Analyzes key performance-related settings:
Memory settings (shared_buffers, work_mem, etc.)
Checkpoint settings
WAL settings
Autovacuum settings
Connection settings
Compares against best practices and system resources.
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Category of settings to review | all |
| include_all_settings | No | Include all settings, not just performance-related ones |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already provide readOnlyHint=true, destructiveHint=false, and idempotentHint=true, covering safety and idempotency. The description adds valuable context about what gets analyzed (specific setting categories) and the comparison methodology (against best practices and system resources), which goes beyond the annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is efficiently structured with a clear purpose statement followed by bullet points of analyzed categories and a final sentence explaining the comparison methodology. Every sentence adds value with zero wasted words, and information is appropriately front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (configuration analysis with 2 parameters), rich annotations covering safety and idempotency, and 100% schema coverage, the description is mostly complete. The main gap is the lack of output schema, so the description doesn't explain what the recommendations look like, but it adequately covers the tool's purpose and scope.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema fully documents both parameters. The description mentions 'key performance-related settings' and lists categories that map to the enum, but doesn't add significant meaning beyond what's already in the schema descriptions. This meets the baseline for high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('review', 'analyzes', 'compares') and identifies the resource ('PostgreSQL configuration settings'). It distinguishes itself from sibling tools by focusing on configuration analysis rather than query analysis, index management, or performance monitoring.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context for when to use this tool (analyzing PostgreSQL configuration against best practices) but doesn't explicitly state when not to use it or name specific alternatives among the sibling tools. The implicit differentiation from siblings is present but not explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
v1.0.0- Added
analyze_index_bloat - Added
analyze_table_bloat - Changed
find_unused_indexes1 field changed- removed
Input schema / properties / max_scan_ratioRemoved value: -{ - "default": 0.01, - "description": "Maximum scan ratio (scans/rows) to consider an index unused", - "type": "number" -}
- Added
get_bloat_summary - Changed
manage_hypothetical_indexes8 fields changed- changed
Input schema / properties / action / enumPrevious value: -[ - "create", - "list", - "drop", - "reset", - "estimate_size", - "check" -]New value: +[ + "create", + "list", + "drop", + "reset", + "estimate_size", + "check", + "hide", + "unhide", + "list_hidden", + "explain_with_index" +] - changed
Input schema / properties / columns / descriptionPrevious value: -"Column names for the index (required for create, estimate_size)"New value: +"Column names for the index (required for create, estimate_size, explain_with_index)" - added
Input schema / properties / includeAdded value: +{ + "description": "Columns to include in INCLUDE clause (optional, for create)", + "items": { + "type": "string" + }, + "type": "array" +} - changed
Input schema / properties / index_id / descriptionPrevious value: -"Index OID (required for drop)"New value: +"Index OID (required for drop, hide, unhide)" - added
Input schema / properties / queryAdded value: +{ + "description": "SQL query to explain (required for explain_with_index)", + "type": "string" +} - added
Input schema / properties / schemaAdded value: +{ + "description": "Schema name for the table (optional, for create and explain_with_index)", + "type": "string" +} - changed
Input schema / properties / table / descriptionPrevious value: -"Table name (required for create, estimate_size)"New value: +"Table name (required for create, estimate_size, explain_with_index)" - added
Input schema / properties / whereAdded value: +{ + "description": "Partial index WHERE condition (optional, for create)", + "type": "string" +}
11 tool updates
- First observed
analyze_query - First observed
analyze_wait_events - First observed
check_database_health - First observed
explain_with_indexes - First observed
find_unused_indexes - First observed
get_active_queries - First observed
get_index_recommendations - First observed
get_slow_queries - First observed
get_table_stats - First observed
manage_hypothetical_indexes - First observed
review_settings
TDQS
Most tools have distinct purposes, such as analyze_index_bloat for index analysis and get_slow_queries for query retrieval. However, some overlap exists between analyze_table_bloat and get_bloat_summary, which both focus on bloat analysis but at different granularities, potentially causing minor confusion.
All tool names follow a consistent snake_case pattern with clear verb_noun structures, such as analyze_query, get_active_queries, and find_unused_indexes. This uniformity makes the tool set predictable and easy to navigate.
With 14 tools, the server is well-scoped for PostgreSQL performance tuning, covering key areas like bloat analysis, query optimization, and health checks. Each tool serves a specific function without redundancy, fitting the domain appropriately.
The tool set provides comprehensive coverage for performance tuning, including analysis (e.g., bloat, queries), monitoring (e.g., health, active queries), and optimization (e.g., index recommendations, hypothetical testing). No obvious gaps are present, supporting full lifecycle management.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Comprehensive PostgreSQL documentation and best practices, including ecosystem tools
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Hosted MCP server for PostgreSQL diagnostics: slow queries, missing indexes, connection pressure.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables comprehensive PostgreSQL database monitoring, analysis, and management through natural language queries. Provides performance insights, bloat analysis, vacuum monitoring, and intelligent maintenance recommendations across PostgreSQL versions 12-17.34161MIT
- AlicenseNot gradedqualityCmaintenanceProvides AI-driven PostgreSQL database management with secure OAuth 2.1 authentication, enabling users to administer, monitor, and query databases with support for extensions like pgvector, PostGIS, and pg_cron.121-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to analyze and optimize PostgreSQL database performance by identifying missing indexes and suggesting query rewrites. It allows users to retrieve database projects and implement performance fixes directly through natural language in their code editor.162MIT
- AlicenseNot gradedqualityFmaintenanceEnables AI assistants to manage, monitor, and optimize PostgreSQL databases with over 200 specialized tools for operations, security, performance tuning, and diagnostics.298MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/isdaniel/pgtuner_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server