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. - Retrieve slow queries from pgstatstatements with detailed statistics - Analyze query execution plans with EXPLAIN and EXPLAIN ANALYZE - Identify p
Add this skill
npx mdskills install isdaniel/pgtuner-mcpComprehensive PostgreSQL tuning MCP with excellent tool coverage and detailed setup guidance
1# PostgreSQL Performance Tuning MCP23[](https://pypi.org/project/pgtuner-mcp/)4[](https://pypi.org/project/pgtuner-mcp/)5[](https://www.python.org/downloads/)6[](https://pypi.org/project/pgtuner-mcp/)7[](https://hub.docker.com/r/dog830228/pgtuner_mcp)89<a href="https://glama.ai/mcp/servers/@isdaniel/pgtuner-mcp">10 <img width="380" height="200" src="https://glama.ai/mcp/servers/@isdaniel/pgtuner-mcp/badge" />11</a>1213A 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.1415## Features1617### Query Analysis18- Retrieve slow queries from `pg_stat_statements` with detailed statistics19- Analyze query execution plans with `EXPLAIN` and `EXPLAIN ANALYZE`20- Identify performance bottlenecks with automated plan analysis21- Monitor active queries and detect long-running transactions2223### Index Tuning24- AI-powered index recommendations based on query workload analysis25- Hypothetical index testing with **HypoPG** extension (no disk usage)26- Find unused and duplicate indexes for cleanup27- Estimate index sizes before creation28- Test query plans with proposed indexes before implementing2930### Database Health31- Comprehensive health scoring with multiple checks32- Connection utilization monitoring33- Cache hit ratio analysis (buffer and index)34- Lock contention detection35- Vacuum health and transaction ID wraparound monitoring36- Replication lag monitoring37- Background writer and checkpoint analysis3839### Vacuum Monitoring40- Track long-running VACUUM and VACUUM FULL operations in real-time41- Monitor autovacuum progress and performance42- Identify tables that need vacuuming43- View recent vacuum activity history44- Analyze autovacuum configuration effectiveness4546### I/O Performance Analysis47- Analyze disk read/write patterns across tables and indexes48- Identify I/O bottlenecks and hot tables49- Monitor buffer cache hit ratios50- Track temporary file usage indicating work_mem issues51- Analyze checkpoint and background writer I/O52- PostgreSQL 16+ enhanced pg_stat_io metrics support5354### Configuration Analysis55- Review PostgreSQL settings by category56- Get recommendations for memory, checkpoint, WAL, autovacuum, and connection settings57- Identify suboptimal configurations5859### MCP Prompts & Resources60- Pre-defined prompt templates for common tuning workflows61- Dynamic resources for table stats, index info, and health checks62- Comprehensive documentation resources6364## Installation6566### Standard Installation (for MCP clients like Claude Desktop)6768```bash69pip install pgtuner_mcp70```7172Or using `uv`:7374```bash75uv pip install pgtuner_mcp76```7778### Manual Installation7980```bash81git clone https://github.com/isdaniel/pgtuner_mcp.git82cd pgtuner_mcp83pip install -e .84```8586## Configuration8788### Environment Variables8990| Variable | Description | Required |91|----------|-------------|----------|92| `DATABASE_URI` | PostgreSQL connection string | Yes |93| `PGTUNER_EXCLUDE_USERIDS` | Comma-separated list of user IDs (OIDs) to exclude from monitoring | No |9495**Connection String Format:** `postgresql://user:password@host:port/database`9697### Minimal User Permissions9899To 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.100101#### Basic Permissions (Required for Core Functionality)102103```sql104-- Create a dedicated monitoring user105CREATE USER pgtuner_monitor WITH PASSWORD 'secure_password';106107-- Grant connection to the target database108GRANT CONNECT ON DATABASE your_database TO pgtuner_monitor;109110-- Grant usage on schemas111GRANT USAGE ON SCHEMA public TO pgtuner_monitor;112GRANT USAGE ON SCHEMA pg_catalog TO pgtuner_monitor;113114-- Grant SELECT on user tables and indexes (for table stats and analysis)115GRANT SELECT ON ALL TABLES IN SCHEMA public TO pgtuner_monitor;116ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO pgtuner_monitor;117118-- Grant access to system catalog views (read-only)119GRANT pg_read_all_stats TO pgtuner_monitor; -- PostgreSQL 10+120```121122#### Extension-Specific Permissions123124**For pgstattuple (Bloat Detection):**125126```sql127-- Create the extension (requires superuser or appropriate privileges)128CREATE EXTENSION IF NOT EXISTS pgstattuple;129130-- Grant execution on pgstattuple functions131GRANT EXECUTE ON FUNCTION pgstattuple(regclass) TO pgtuner_monitor;132GRANT EXECUTE ON FUNCTION pgstattuple_approx(regclass) TO pgtuner_monitor;133GRANT EXECUTE ON FUNCTION pgstatindex(regclass) TO pgtuner_monitor;134GRANT EXECUTE ON FUNCTION pgstatginindex(regclass) TO pgtuner_monitor;135GRANT EXECUTE ON FUNCTION pgstathashindex(regclass) TO pgtuner_monitor;136137-- Alternative: Use pg_stat_scan_tables role (PostgreSQL 14+)138GRANT pg_stat_scan_tables TO pgtuner_monitor;139```140141**For HypoPG (Hypothetical Index Testing):**142143```sql144-- Create the extension (requires superuser or appropriate privileges)145CREATE EXTENSION IF NOT EXISTS hypopg;146147-- Grant SELECT on HypoPG views148GRANT SELECT ON hypopg_list_indexes TO pgtuner_monitor;149GRANT SELECT ON hypopg_hidden_indexes TO pgtuner_monitor;150151-- Grant execution on HypoPG functions with proper signatures152GRANT EXECUTE ON FUNCTION hypopg_create_index(text) TO pgtuner_monitor;153GRANT EXECUTE ON FUNCTION hypopg_drop_index(oid) TO pgtuner_monitor;154GRANT EXECUTE ON FUNCTION hypopg_reset() TO pgtuner_monitor;155GRANT EXECUTE ON FUNCTION hypopg_hide_index(oid) TO pgtuner_monitor;156GRANT EXECUTE ON FUNCTION hypopg_unhide_index(oid) TO pgtuner_monitor;157GRANT EXECUTE ON FUNCTION hypopg_relation_size(oid) TO pgtuner_monitor;158159-- Note: HypoPG operations are session-scoped and don't affect the actual database160```161162#### Complete Setup Script163164```sql165-- 1. Create the monitoring user166CREATE USER pgtuner_monitor WITH PASSWORD 'secure_password';167168-- 2. Grant connection and schema access169GRANT CONNECT ON DATABASE your_database TO pgtuner_monitor;170GRANT USAGE ON SCHEMA public TO pgtuner_monitor;171172-- 3. Grant read access to user tables173GRANT SELECT ON ALL TABLES IN SCHEMA public TO pgtuner_monitor;174ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO pgtuner_monitor;175176-- 4. Grant system statistics access177GRANT pg_read_all_stats TO pgtuner_monitor; -- PostgreSQL 10+178179-- Grant access to pg_stat_statements views explicitly180GRANT SELECT ON pg_stat_statements TO pgtuner_monitor;181GRANT SELECT ON pg_stat_statements_info TO pgtuner_monitor;182183-- 5. Install and grant access to extensions (as superuser)184-- pg_stat_statements (required)185CREATE EXTENSION IF NOT EXISTS pg_stat_statements;186187-- pgstattuple (for bloat detection)188CREATE EXTENSION IF NOT EXISTS pgstattuple;189GRANT pg_stat_scan_tables TO pgtuner_monitor; -- PostgreSQL 14+190-- OR grant individual functions:191-- GRANT EXECUTE ON FUNCTION pgstattuple(regclass) TO pgtuner_monitor;192-- GRANT EXECUTE ON FUNCTION pgstattuple_approx(regclass) TO pgtuner_monitor;193-- GRANT EXECUTE ON FUNCTION pgstatindex(regclass) TO pgtuner_monitor;194195-- hypopg (for hypothetical index testing)196CREATE EXTENSION IF NOT EXISTS hypopg;197GRANT SELECT ON hypopg_list_indexes TO pgtuner_monitor;198GRANT SELECT ON hypopg_hidden_indexes TO pgtuner_monitor;199GRANT EXECUTE ON FUNCTION hypopg_create_index(text) TO pgtuner_monitor;200GRANT EXECUTE ON FUNCTION hypopg_drop_index(oid) TO pgtuner_monitor;201GRANT EXECUTE ON FUNCTION hypopg_reset() TO pgtuner_monitor;202GRANT EXECUTE ON FUNCTION hypopg_hide_index(oid) TO pgtuner_monitor;203GRANT EXECUTE ON FUNCTION hypopg_unhide_index(oid) TO pgtuner_monitor;204GRANT EXECUTE ON FUNCTION hypopg_relation_size(oid) TO pgtuner_monitor;205206-- 6. Verify permissions207SET ROLE pgtuner_monitor;208SELECT * FROM pg_stat_statements LIMIT 1;209SELECT * FROM pg_stat_activity WHERE pid = pg_backend_pid();210SELECT * FROM pgstattuple('pg_class') LIMIT 1;211SELECT * FROM hypopg_list_indexes();212RESET ROLE;213```214215### Excluding Specific Users from Monitoring216217You can exclude specific PostgreSQL users from being included in query analysis and monitoring results. This is useful for filtering out:218- Monitoring or replication users219- System accounts220- Internal application service accounts221222Set the `PGTUNER_EXCLUDE_USERIDS` environment variable with a comma-separated list of user OIDs:223224```bash225# Exclude user IDs 16384, 16385, and 16386226export PGTUNER_EXCLUDE_USERIDS="16384,16385,16386"227```228229To find the OID for a specific PostgreSQL user:230231```sql232SELECT usesysid, usename FROM pg_user WHERE usename = 'monitoring_user';233```234235When configured, the following queries are filtered:236- `pg_stat_activity` queries (filters on `usesysid` column)237- `pg_stat_statements` queries (filters on `userid` column)238239This affects tools like `get_slow_queries`, `get_active_queries`, `analyze_wait_events`, `check_database_health`, and `get_index_recommendations`.240241### MCP Client Configuration242243Add to your `cline_mcp_settings.json` or Claude Desktop config:244245```json246{247 "mcpServers": {248 "pgtuner_mcp": {249 "command": "python",250 "args": ["-m", "pgtuner_mcp"],251 "env": {252 "DATABASE_URI": "postgresql://user:password@localhost:5432/mydb"253 },254 "disabled": false,255 "autoApprove": []256 }257 }258}259```260261Or Streamable HTTP Mode262263```json264{265 "mcpServers": {266 "pgtuner_mcp": {267 "type": "http",268 "url": "http://localhost:8080/mcp"269 }270 }271}272```273274## Server Modes275276### 1. Standard MCP Mode (Default)277278```bash279# Default mode (stdio)280python -m pgtuner_mcp281282# Explicitly specify stdio mode283python -m pgtuner_mcp --mode stdio284```285286### 2. HTTP SSE Mode (Legacy Web Applications)287288The 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.289290```bash291# Start SSE server on default host/port (0.0.0.0:8080)292python -m pgtuner_mcp --mode sse293294# Specify custom host and port295python -m pgtuner_mcp --mode sse --host localhost --port 3000296297# Enable debug mode298python -m pgtuner_mcp --mode sse --debug299```300301**SSE Endpoints:**302303| Endpoint | Method | Description |304|----------|--------|-------------|305| `/sse` | GET | SSE connection endpoint - clients connect here to receive server events |306| `/messages` | POST | Send messages/requests to the server |307308**MCP Client Configuration for SSE:**309310For MCP clients that support SSE transport (like Claude Desktop or custom clients):311312```json313{314 "mcpServers": {315 "pgtuner_mcp": {316 "type": "sse",317 "url": "http://localhost:8080/sse"318 }319 }320}321```322323### 3. Streamable HTTP Mode (Modern MCP Protocol - Recommended)324325The streamable-http mode implements the modern MCP Streamable HTTP protocol with a single `/mcp` endpoint. It supports both stateful (session-based) and stateless modes.326327```bash328# Start Streamable HTTP server in stateful mode (default)329python -m pgtuner_mcp --mode streamable-http330331# Start in stateless mode (fresh transport per request)332python -m pgtuner_mcp --mode streamable-http --stateless333334# Specify custom host and port335python -m pgtuner_mcp --mode streamable-http --host localhost --port 8080336337# Enable debug mode338python -m pgtuner_mcp --mode streamable-http --debug339```340341**Stateful vs Stateless:**342- **Stateful (default)**: Maintains session state across requests using `mcp-session-id` header. Ideal for long-running interactions.343- **Stateless**: Creates a fresh transport for each request with no session tracking. Ideal for serverless deployments or simple request/response patterns.344345**Endpoint:** `http://{host}:{port}/mcp`346347## Available Tools348349> **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.350351### Performance Analysis Tools352353| Tool | Description |354|------|-------------|355| `get_slow_queries` | Retrieve slow queries from pg_stat_statements with detailed stats (total time, mean time, calls, cache hit ratio). Excludes system catalog queries. |356| `analyze_query` | Analyze a query's execution plan with EXPLAIN ANALYZE, including automated issue detection |357| `get_table_stats` | Get detailed table statistics including size, row counts, dead tuples, and access patterns |358| `analyze_disk_io_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). |359360### Index Tuning Tools361362| Tool | Description |363|------|-------------|364| `get_index_recommendations` | AI-powered index recommendations based on query workload analysis |365| `explain_with_indexes` | Run EXPLAIN with hypothetical indexes to test improvements without creating real indexes |366| `manage_hypothetical_indexes` | Create, list, drop, or reset HypoPG hypothetical indexes. Supports hide/unhide existing indexes. |367| `find_unused_indexes` | Find unused and duplicate indexes that can be safely dropped |368369### Database Health Tools370371| Tool | Description |372|------|-------------|373| `check_database_health` | Comprehensive health check with scoring (connections, cache, locks, replication, wraparound, disk, checkpoints) |374| `get_active_queries` | Monitor active queries, find long-running transactions and blocked queries. By default excludes system processes. |375| `analyze_wait_events` | Analyze wait events to identify I/O, lock, or CPU bottlenecks. Focuses on client backend processes. |376| `review_settings` | Review PostgreSQL settings by category with optimization recommendations |377378### Bloat Detection Tools (pgstattuple)379380| Tool | Description |381|------|-------------|382| `analyze_table_bloat` | Analyze table bloat using pgstattuple extension. Shows dead tuple counts, free space, and wasted space percentage. |383| `analyze_index_bloat` | Analyze B-tree index bloat using pgstatindex. Shows leaf density, fragmentation, and empty/deleted pages. Also supports GIN and Hash indexes. |384| `get_bloat_summary` | Get a comprehensive overview of database bloat with top bloated tables/indexes, total reclaimable space, and priority maintenance actions. |385386### Vacuum Monitoring Tools387388| Tool | Description |389|------|-------------|390| `monitor_vacuum_progress` | 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. |391392### Tool Parameters393394#### get_slow_queries395- `limit`: Maximum queries to return (default: 10)396- `min_calls`: Minimum call count filter (default: 1)397- `min_mean_time_ms`: Minimum mean (average) execution time in milliseconds filter398- `order_by`: Sort by `mean_time`, `calls`, or `rows`399400#### analyze_query401- `query` (required): SQL query to analyze402- `analyze`: Execute query with EXPLAIN ANALYZE (default: true)403- `buffers`: Include buffer statistics (default: true)404- `format`: Output format - `json`, `text`, `yaml`, `xml`405406#### get_index_recommendations407- `workload_queries`: Optional list of specific queries to analyze408- `max_recommendations`: Maximum recommendations (default: 10)409- `min_improvement_percent`: Minimum improvement threshold (default: 10%)410- `include_hypothetical_testing`: Test with HypoPG (default: true)411- `target_tables`: Focus on specific tables412413#### check_database_health414- `include_recommendations`: Include actionable recommendations (default: true)415- `verbose`: Include detailed statistics (default: false)416417#### analyze_table_bloat418- `table_name`: Name of a specific table to analyze (optional)419- `schema_name`: Schema name (default: `public`)420- `use_approx`: Use `pgstattuple_approx` for faster analysis on large tables (default: false)421- `min_table_size_gb`: Minimum table size in GB to include in schema-wide scan (default: 5)422- `include_toast`: Include TOAST table analysis (default: false)423424#### analyze_index_bloat425- `index_name`: Name of a specific index to analyze (optional)426- `table_name`: Analyze all indexes on this table (optional)427- `schema_name`: Schema name (default: `public`)428- `min_index_size_gb`: Minimum index size in GB to include (default: 5)429- `min_bloat_percent`: Only show indexes with bloat above this percentage (default: 20)430431#### get_bloat_summary432- `schema_name`: Schema to analyze (default: `public`)433- `top_n`: Number of top bloated objects to show (default: 10)434- `min_size_gb`: Minimum object size in GB to include (default: 5)435436#### monitor_vacuum_progress437- `action`: Action to perform - `progress` (monitor active vacuum operations), `needs_vacuum` (find tables needing vacuum), `autovacuum_status` (review autovacuum configuration), or `recent_activity` (view recent vacuum history)438- `schema_name`: Schema to analyze (default: `public`, used with `needs_vacuum` action)439- `top_n`: Number of results to return (default: 20)440441#### analyze_disk_io_patterns442- `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), or `checkpoints` (checkpoint I/O statistics)443- `schema_name`: Schema to analyze (default: `public`)444- `top_n`: Number of top I/O-intensive objects to show (default: 20)445- `min_size_gb`: Minimum object size in GB to include (default: 1)446447## MCP Prompts448449The server includes pre-defined prompt templates for guided tuning sessions:450451| Prompt | Description |452|--------|-------------|453| `diagnose_slow_queries` | Systematic slow query investigation workflow |454| `index_optimization` | Comprehensive index analysis and cleanup |455| `health_check` | Full database health assessment |456| `query_tuning` | Optimize a specific SQL query |457| `performance_baseline` | Generate a baseline report for comparison |458459## MCP Resources460461### Static Resources462- `pgtuner://docs/tools` - Complete tool documentation463- `pgtuner://docs/workflows` - Common tuning workflows guide464- `pgtuner://docs/prompts` - Prompt template documentation465466### Dynamic Resource Templates467- `pgtuner://table/{schema}/{table_name}/stats` - Table statistics468- `pgtuner://table/{schema}/{table_name}/indexes` - Table index information469- `pgtuner://query/{query_hash}/stats` - Query performance statistics470- `pgtuner://settings/{category}` - PostgreSQL settings (memory, checkpoint, wal, autovacuum, connections, all)471- `pgtuner://health/{check_type}` - Health checks (connections, cache, locks, replication, bloat, all)472473## PostgreSQL Extension Setup474475### HypoPG Extension476477HypoPG enables testing indexes without actually creating them. This is extremely useful for:478- Testing if a proposed index would be used by the query planner479- Comparing execution plans with different index strategies480- Estimating storage requirements before committing481482#### Enable HypoPG in Database483484HypoPG enables testing hypothetical indexes without creating them on disk.485486```sql487-- Create the extension488CREATE EXTENSION IF NOT EXISTS hypopg;489490-- Verify installation491SELECT * FROM hypopg_list_indexes();492```493494### pg_stat_statements Extension495496The `pg_stat_statements` extension is **required** for query performance analysis. It tracks planning and execution statistics for all SQL statements executed by a server.497498#### Step 1: Enable the Extension in postgresql.conf499500Add the following to your `postgresql.conf` file:501502```ini503# Required: Load pg_stat_statements module504shared_preload_libraries = 'pg_stat_statements'505506# Required: Enable query identifier computation507compute_query_id = on508509# Maximum number of statements tracked (default: 5000)510pg_stat_statements.max = 10000511512# Track all statements including nested ones (default: top)513# Options: top, all, none514pg_stat_statements.track = top515516# Track utility commands like CREATE, ALTER, DROP (default: on)517pg_stat_statements.track_utility = on518```519520> **Note**: After modifying `shared_preload_libraries`, a PostgreSQL server **restart** is required.521522#### Step 2: Create the Extension in Your Database523524```sql525-- Connect to your database and create the extension526CREATE EXTENSION IF NOT EXISTS pg_stat_statements;527528-- Verify installation529SELECT * FROM pg_stat_statements LIMIT 1;530```531532### pgstattuple Extension533534The `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.535536```sql537-- Create the extension538CREATE EXTENSION IF NOT EXISTS pgstattuple;539540-- Verify installation541SELECT * FROM pgstattuple('pg_class') LIMIT 1;542```543544### Performance Impact Considerations545546| Setting | Overhead | Recommendation |547|---------|----------|----------------|548| `pg_stat_statements` | Low (~1-2%) | **Always enable** |549| `track_io_timing` | Low-Medium (~2-5%) | Enable in production, test first |550| `track_functions = all` | Low | Enable for function-heavy workloads |551| `pg_stat_statements.track_planning` | Medium | Enable only when investigating planning issues |552| `log_min_duration_statement` | Low | Recommended for slow query identification |553554> **Tip**: Use `pg_test_timing` to measure the timing overhead on your specific system before enabling `track_io_timing`.555556## Example Usage557558### Find and Analyze Slow Queries559560```python561# Get top 10 slowest queries562slow_queries = await get_slow_queries(limit=10, order_by="total_time")563564# Analyze a specific query's execution plan565analysis = await analyze_query(566 query="SELECT * FROM orders WHERE user_id = 123",567 analyze=True,568 buffers=True569)570```571572### Get Index Recommendations573574```python575# Analyze workload and get recommendations576recommendations = await get_index_recommendations(577 max_recommendations=5,578 min_improvement_percent=20,579 include_hypothetical_testing=True580)581582# Recommendations include CREATE INDEX statements583for rec in recommendations["recommendations"]:584 print(rec["create_statement"])585```586587### Database Health Check588589```python590# Run comprehensive health check591health = await check_database_health(592 include_recommendations=True,593 verbose=True594)595596print(f"Health Score: {health['overall_score']}/100")597print(f"Status: {health['status']}")598599# Review specific areas600for issue in health["issues"]:601 print(f"{issue}")602```603604### Find Unused Indexes605606```python607# Find indexes that can be dropped608unused = await find_unused_indexes(609 schema_name="public",610 include_duplicates=True611)612613# Get DROP statements614for stmt in unused["recommendations"]:615 print(stmt)616```617618## Docker619620```bash621docker pull dog830228/pgtuner_mcp622623# Streamable HTTP mode (recommended for web applications)624docker run -p 8080:8080 \625 -e DATABASE_URI=postgresql://user:pass@host:5432/db \626 dog830228/pgtuner_mcp --mode streamable-http627628# Streamable HTTP stateless mode (for serverless)629docker run -p 8080:8080 \630 -e DATABASE_URI=postgresql://user:pass@host:5432/db \631 dog830228/pgtuner_mcp --mode streamable-http --stateless632633# SSE mode (legacy web applications)634docker run -p 8080:8080 \635 -e DATABASE_URI=postgresql://user:pass@host:5432/db \636 dog830228/pgtuner_mcp --mode sse637638# stdio mode (for MCP clients like Claude Desktop)639docker run -i \640 -e DATABASE_URI=postgresql://user:pass@host:5432/db \641 dog830228/pgtuner_mcp --mode stdio642```643644## Requirements645646- **Python**: 3.10+647- **PostgreSQL**: 12+ (recommended: 14+)648- **Extensions**:649 - `pg_stat_statements` (required for query analysis)650 - `hypopg` (optional, for hypothetical index testing)651652## Dependencies653654Core dependencies:655- `mcp[cli]>=1.12.0` - Model Context Protocol SDK656- `psycopg[binary,pool]>=3.1.0` - PostgreSQL adapter with connection pooling657- `pglast>=7.10` - PostgreSQL query parser658659Optional (for HTTP modes):660- `starlette>=0.27.0` - ASGI framework661- `uvicorn>=0.23.0` - ASGI server662663## Contributing664665Contributions are welcome! Please feel free to submit a Pull Request.666667<!-- Need to add this line for MCP registry publication -->668<!-- mcp-name: io.github.isdaniel/pgtuner_mcp -->669
Full transparency — inspect the skill content before installing.