loading…
Search for a command to run...
loading…
MCP server for PostgreSQL with full read-write support, transactions, and schema inspection. Works with any PostgreSQL instance — local, Supabase, AWS RDS, or s
MCP server for PostgreSQL with full read-write support, transactions, and schema inspection. Works with any PostgreSQL instance — local, Supabase, AWS RDS, or self-hosted. Use with Claude, Cursor, Windsurf, and any MCP-compatible AI client.
npm version npm downloads License: ISC
A Model Context Protocol (MCP) server for PostgreSQL with full read-write support, atomic transactions, and schema inspection. Works with Claude Desktop, Cursor, Windsurf, and any MCP-compatible AI client.
Connect any PostgreSQL database — local, Supabase, AWS RDS, or self-hosted — to your AI assistant in seconds.
SELECT, INSERT, UPDATE, DELETE, CREATE, DROP)?mode=readonlyThere are two other PostgreSQL MCP servers worth knowing about, and neither fully covers the general-purpose use case:
Anthropic's official @modelcontextprotocol/server-postgres is strictly read-only — it exposes only a single query tool that runs inside a READ ONLY transaction. No writes, no DDL, no transactions. It was also deprecated and archived in July 2025.
Microsoft's azure-postgresql-mcp does support writes and DDL, but it is built specifically for Azure Database for PostgreSQL Flexible Server. While it technically accepts standard PG* environment variables (so a local connection may work), local use is untested and unsupported. Several tools require Microsoft Entra authentication and Azure-specific APIs that won't function outside Azure. It also pulls in Azure SDK dependencies you don't need for a non-Azure setup. It is currently in Preview.
This server is the alternative for everything else: local PostgreSQL, self-hosted, Supabase, RDS, or any standard PostgreSQL instance. It is a single dependency-light file with no cloud lock-in, full read-write support, atomic multi-statement transactions, and an optional ?mode=readonly flag when you want to restrict access.
npm install -g @sarmadparvez/postgresql-mcp
Or run directly without installing (requires npm 7+ / Node.js 18+):
npx @sarmadparvez/postgresql-mcp <postgresql-connection-string>
postgresql-mcp <postgresql-connection-string>
Examples:
# Read-write access
postgresql-mcp postgresql://user:pass@localhost:5432/mydb
# Read-only mode (disables execute and transaction tools)
postgresql-mcp postgresql://user:pass@localhost:5432/mydb?mode=readonly
Or with npx (requires npm 7+ / Node.js 18+):
npx @sarmadparvez/postgresql-mcp postgresql://user:pass@localhost:5432/mydb
npx @sarmadparvez/postgresql-mcp postgresql://user:pass@localhost:5432/mydb?mode=readonly
| Tool | Available in | Description |
|---|---|---|
query |
Always | Execute a read-only SELECT query. Runs inside a READ ONLY transaction. Returns rows as JSON. |
execute |
Read-write mode | Execute a write SQL statement (INSERT, UPDATE, DELETE, CREATE, DROP, etc.). Returns rows affected. |
schema |
Always | List columns, types, nullability, defaults, and primary keys for tables in a given schema. Optionally filter to a specific table. |
list_tables |
Always | List all base tables in a schema with their disk size. |
transaction |
Read-write mode | Execute multiple SQL statements atomically. Rolls back all statements if any one fails. |
Append ?mode=readonly to the connection string to start the server in read-only mode. This disables the execute and transaction tools, leaving only query, schema, and list_tables.
First, install the package globally:
npm install -g @sarmadparvez/postgresql-mcp
Then find the paths to node and the installed script:
which node
# e.g. /usr/local/bin/node
# nvm users: /Users/yourname/.nvm/versions/node/v22.12.0/bin/node
npm root -g
# e.g. /usr/local/lib/node_modules
# nvm users: /Users/yourname/.nvm/versions/node/v22.12.0/lib/node_modules
Add this to your claude_desktop_config.json:
command with the output of which nodenpm root -g — the suffix /@sarmadparvez/postgresql-mcp/index.js stays the same{
"mcpServers": {
"postgres": {
"command": "/usr/local/bin/node",
"args": [
"/usr/local/lib/node_modules/@sarmadparvez/postgresql-mcp/index.js",
"postgresql://user:pass@localhost:5432/mydb"
]
}
}
}
For read-only access, append ?mode=readonly to the connection string:
{
"mcpServers": {
"postgres-readonly": {
"command": "/usr/local/bin/node",
"args": [
"/usr/local/lib/node_modules/@sarmadparvez/postgresql-mcp/index.js",
"postgresql://user:pass@localhost:5432/mydb?mode=readonly"
]
}
}
}
This MCP server works with any client that supports the Model Context Protocol:
Run in your terminal:
claude mcp add postgresql-mcp -- npx -y @sarmadparvez/postgresql-mcpYes, Postgresql Mcp MCP is free — one-click install via Unyly at no cost.
No, Postgresql Mcp runs without API keys or environment variables.
Self-hosted: the server runs locally on your machine via the install command above.
Open Postgresql Mcp on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Query your database in natural language
by AnthropicA universal database MCP server supporting simultaneous connections to multiple databases. It provides tools for database operations, health analysis, SQL optim
by wenb1n-devThis server enables interaction with PostgreSQL databases through the Model Context Protocol, optimized for the AWS Bedrock AgentCore Runtime. It provides tools
by madhurprashRead-only database access with schema inspection.
by modelcontextprotocolNot sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All data MCPs