postgres-mcp-server

v0.1.4
@allensandiego/postgres-mcp-server Checked 4 hours ago Published 3 months ago

Model Context Protocol (MCP) server for PostgreSQL databases

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

list_tables

Discover schemas and their tables/columns without writing a query (FR-002)

ParameterTypeDescription
schemastringOptional schema name to filter tables (defaults to all non-system schemas)

describe_table

Detail the columns, types, and primary keys of a specific table (FR-002)

ParameterTypeDescription
schema *stringSchema name (e.g. 'public')
table *stringTable name

list_databases

Discover databases visible/connectable to the connected user (FR-002a)

list_roles

Discover roles/users and their attributes and memberships (FR-002b)

list_permissions

Discover privileges granted to roles on schemas, tables, and columns (FR-002c)

ParameterTypeDescription
objectTypestringOptional object type filter: 'schema', 'table', or 'column'
schemastringOptional schema filter (e.g. 'public')
tablestringOptional table filter

run_query

Execute a read-only SELECT query and return structured rows (FR-003)

ParameterTypeDescription
sql *stringRead-only SQL query to execute (e.g. SELECT)
limitintegerMaximum number of rows to return (capped by server maxRowLimit)
offsetintegerNumber of rows to skip before returning results
paramsarrayOptional parameterized query values ($1, $2, etc.)
rolestringOptional PostgreSQL role to assume (SET ROLE) for this query only

run_write_query

Execute INSERT/UPDATE/DELETE/DDL statements when write mode is enabled (FR-006)

ParameterTypeDescription
sql *stringSQL write/DDL statement to execute (e.g. INSERT, UPDATE, DELETE, CREATE TABLE)
paramsarrayOptional parameterized query values ($1, $2, etc.)
rolestringOptional PostgreSQL role to assume (SET ROLE) for this write query only

set_role

Set active PostgreSQL role/user for the session (SET ROLE) or reset to default (RESET ROLE)

ParameterTypeDescription
role *stringRole or username to set (e.g. 'analyst', 'app_user', or 'NONE' / 'RESET' to restore default)