About crystaldba/postgres-mcp
crystaldba/postgres-mcp is an MCP server published by crystaldba in the Data category: postgres MCP Pro provides configurable read/write access and performance analysis for you and your AI agents. Conduid read 9 tools from its source: analyze_db_health, analyze_query_indexes, analyze_workload_indexes, execute_sql, explain_query, get_object_details and 3 more. No package is published for it, so it installs from a source checkout.
The repository has 3.5K stars and 401 forks, is licensed MIT, and its last commit was on 30 Nov 2026. The latest release is v0.3.0 (16 May 2025): Release v0.3.0 adds windows support and index optimization by LLM. It follows v0.2.1 (17 Apr 2025), and the 4 most recent releases go back to v0.1.1 (8 Apr 2025). It passes 5 of the 6 static checks Conduid ran on the repository; it does not pass Scoped permissions. Its topics include postgres.
Install
git clone https://github.com/crystaldba/postgres-mcpTools (9)
analyze_db_healthPerforms comprehensive health checks including: buffer cache hit rates, connection health, constraint validation, index health (duplicate/unused/invalid), sequence limits, and vacuum health.| Parameter | Type | Description |
|---|---|---|
| health_type | string | Optional. Valid values are: {', '.join(sorted([t.value for t in HealthType]))}. |
analyze_query_indexesAnalyzes a list of specific SQL queries (up to 10) and recommends optimal indexes for them.| Parameter | Type | Description |
|---|---|---|
| max_index_size_mb | integer | Max index size in MB |
| method | string | Method to use for analysis |
| queries * | array | List of Query strings to analyze |
analyze_workload_indexesAnalyzes the database workload to identify resource-intensive queries, then recommends optimal indexes for them.| Parameter | Type | Description |
|---|---|---|
| max_index_size_mb | integer | Max index size in MB |
| method | string | Method to use for analysis |
execute_sqlExecutes SQL statements on the database, with read-only limitations when connected in restricted mode.explain_queryGets the execution plan for a SQL query describing how PostgreSQL will process it and exposing the query planner's cost model. Can be invoked with hypothetical indexes to simulate the behavior after adding indexes.| Parameter | Type | Description |
|---|---|---|
| analyze | boolean | When True, actually runs the query to show real execution statistics instead of estimates. Takes longer but provides more accurate information. |
| hypothetical_indexes | array | A list of hypothetical indexes to simulate. Each index must be a dictionary with these keys: - 'table': The table name to add the index to (e.g., 'users') - 'columns': List of column names to include in the index (e.g., ['email'] or ['last_name', 'first_name']) - 'using': Optional index method (default: 'btree', other options include 'hash', 'gist', etc.) Examples: [ {"table": "users", "columns": ["email"], "using": "btree"}, {"table": "orders", "columns": ["user_id", "created_at"]} ] If there is no hypothetical index, you can pass an empty list. |
| sql * | string | SQL query to explain |
get_object_detailsProvides information about a specific database object, for example, a table's columns, constraints, and indexes.| Parameter | Type | Description |
|---|---|---|
| object_name * | string | Object name |
| object_type | string | Object type: 'table', 'view', 'sequence', or 'extension' |
| schema_name * | string | Schema name |
get_top_queriesReports the slowest SQL queries based on total execution time using `pg_stat_statements` data.| Parameter | Type | Description |
|---|---|---|
| limit | integer | Number of queries to return when ranking based on mean_time or total_time |
| sort_by | string | Ranking criteria: 'total_time' for total execution time or 'mean_time' for mean execution time per call, or 'resources' for resource-intensive queries |
list_objectsLists database objects (tables, views, sequences, extensions) within a specified schema.| Parameter | Type | Description |
|---|---|---|
| object_type | string | Object type: 'table', 'view', 'sequence', or 'extension' |
| schema_name * | string | Schema name |
list_schemasLists all database schemas available in the PostgreSQL instance.Security checks
- ✓README presentThe repository's README runs to about 4.9K words.
- ✓License declaredThe repository declares the MIT license.
- ✓Tests presentA test suite exists in the repository.
- ✓Dependencies pinnedA lockfile pins dependency versions.
- ✓No dynamic code executionScanned 26 source files and found no eval, dynamic Function or shell execution.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
Releases
README
The repository's README runs to about 4.9K words, fetched 14 days ago. The original in the repository is authoritative.
Read full README