postgresql-mcp

v1.2.2
postgresql-mcp Checked 3 hours ago Published 28 days ago

MCP server for PostgreSQL database operations - query, explore schemas, and analyze tables

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_databases

List configured database aliases without exposing credentials.

query

Execute a SQL query against the PostgreSQL database. This tool is READ-ONLY by default. Use the 'execute' tool for write operations. Args: sql: SQL query to execute (SELECT statements only) Returns: Query results with rows, columns, and metadata

ParameterTypeDescription
sql *string
database

execute

Execute a write SQL statement (INSERT, UPDATE, DELETE). WARNING: This tool modifies data. Use with caution. Only available when the selected connection allows writes via `allowWrite`, or via the legacy ALLOW_WRITE_OPERATIONS setting. Args: sql: SQL statement to execute Returns: Execution result with affected row count

ParameterTypeDescription
sql *string
database

explain_query

Get the execution plan for a SQL query (EXPLAIN). Args: sql: SQL query to explain analyze: If true, actually runs the query to get real execution stats (EXPLAIN ANALYZE). Use with caution on slow queries. Returns: Execution plan in JSON format with cost estimates

ParameterTypeDescription
sql *string
analyzeboolean
database

list_schemas

List all schemas in the PostgreSQL database. Returns: List of schemas with name and owner

ParameterTypeDescription
database

list_tables

List all tables in a specific schema. Args: schema: Schema name to list tables from (default: public) Returns: List of tables with name and type

ParameterTypeDescription
database
schemastring

describe_table

Describe the structure of a table including columns, types, and constraints. Args: table_name: Name of the table to describe schema: Schema name (default: public) Returns: Table structure with columns, primary keys, and foreign keys

ParameterTypeDescription
table_name *string
database
schemastring

table_stats

Get statistics for a table (row count, size, bloat). Args: table_name: Name of the table schema: Schema name (default: public) Returns: Table statistics including row count, sizes, and vacuum info

ParameterTypeDescription
table_name *string
database
schemastring

list_indexes

List all indexes for a table. Args: table_name: Name of the table schema: Schema name (default: public) Returns: List of indexes with name, columns, type, and size

ParameterTypeDescription
table_name *string
database
schemastring

list_constraints

List all constraints for a table (PK, FK, UNIQUE, CHECK). Args: table_name: Name of the table schema: Schema name (default: public) Returns: List of constraints with type, columns, and references

ParameterTypeDescription
table_name *string
database
schemastring

list_views

List all views in a schema. Args: schema: Schema name (default: public) Returns: List of views with name

ParameterTypeDescription
database
schemastring

describe_view

Get the definition and columns of a view. Args: view_name: Name of the view schema: Schema name (default: public) Returns: View definition SQL and column list

ParameterTypeDescription
view_name *string
database
schemastring

list_functions

List all functions and procedures in a schema. Args: schema: Schema name (default: public) Returns: List of functions with name, arguments, and return type

ParameterTypeDescription
database
schemastring

get_database_info

Get database and connection information. Returns: Database version, connection info, and settings

ParameterTypeDescription
database

search_columns

Search for columns by name across all tables. Args: search_term: Column name pattern to search (case-insensitive) schema: Optional schema to limit search (default: all user schemas) Returns: List of matching columns with table information

ParameterTypeDescription
search_term *string
database
schema