Postgresql MCP logo

Postgresql MCP

by @sarmadparvez

Connect AI clients to PostgreSQL for read-write SQL, atomic transactions, and schema inspection.

Install Postgresql MCP

Pick your client, then add it in one click or paste the config.

STDIONode.js
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "sarmadparvez-postgresql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@sarmadparvez/postgresql-mcp"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

We couldn’t confirm it starts correctly

The install command installed and started the server, which then stopped for configuration (such as an API key) that our sandbox does not have — expected for servers that connect to your account.

npx -y @sarmadparvez/postgresql-mcp

No response to initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked 10d ago.

Overview

@sarmadparvez/postgresql-mcp exposes PostgreSQL databases to MCP-compatible AI clients through SQL and metadata tools. It connects using a standard PostgreSQL connection string and supports local, Supabase, AWS RDS, and self-hosted instances. Read-write mode provides query, execute, schema, list_tables, and transaction tools, while a readonly connection-string flag disables write operations. Reach for it when an agent needs to inspect or modify a PostgreSQL database without a cloud-specific service.

Use cases

  • Inspect PostgreSQL schemas and table sizes
  • Run read-only SELECT queries through an AI client
  • Apply INSERT, UPDATE, DELETE, or DDL statements
  • Group database changes into atomic transactions
  • Connect AI tools to Supabase, RDS, or self-hosted PostgreSQL

Key features

  • Read-only SQL queries with JSON results
  • Read-write SQL and DDL execution
  • Atomic multi-statement transactions
  • Schema and primary-key inspection
  • Table listings with disk sizes
  • Optional read-only operating mode

Tools5

What Postgresql MCP lets your agent do. Expand a tool for its parameters.

Self-reported~129 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked 3d ago

Recent health check succeeded.

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 11d ago via OSV.dev · @sarmadparvez/postgresql-mcp (npm)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars3Stargazers on the source repository.
npm downloads346Package downloads in the last 30 days.
Last commit7mo agoMost recent push to the default branch.
Install checkRunsOur sandbox started it; it then asked for an API key or config.
Tools exposed5Callable tools this server registers over MCP.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How Postgresql MCP works

What @sarmadparvez/postgresql-mcp does

@sarmadparvez/postgresql-mcp connects an MCP-compatible AI client to a PostgreSQL database and exposes database operations as MCP tools. It supports standard PostgreSQL connection strings for local databases, Supabase, AWS RDS, and self-hosted deployments.

The server covers both database inspection and data modification. Read queries run in a read-only transaction and return rows as JSON. Write statements can modify data or database structure, including inserts, updates, deletes, table creation, and drops. Schema tools provide table structure details, while transaction support groups multiple statements into one atomic operation.

How it works

Start the server with a PostgreSQL connection string as its command-line argument. The MCP client launches the process and communicates with it through the server's MCP interface. A running PostgreSQL database and Node.js 18 or newer are required.

By default, the server exposes read and write operations. Adding ?mode=readonly to the connection string starts a restricted configuration: query, schema, and list_tables remain available, while execute and transaction are disabled.

Transactions accept multiple SQL statements and roll back the complete group if any statement fails. This is useful for changes that must either all succeed or leave the database unchanged.

Setup and configuration

Install the package globally with npm:

Terminal
npm install -g @sarmadparvez/postgresql-mcp

Then launch it with:

bash
postgresql-mcp postgresql://user:pass@localhost:5432/mydb

You can also run it without a global installation using npm 7 or newer:

Terminal
npx @sarmadparvez/postgresql-mcp postgresql://user:pass@localhost:5432/mydb

For read-only access, append ?mode=readonly to the connection string. The package can be configured in Claude Desktop by setting the MCP server command to the Node executable, passing the installed index.js path and the PostgreSQL connection string as arguments. The installation path depends on the global npm location.

Tools and capabilities

  • query: Runs a read-only SELECT inside a READ ONLY transaction and returns JSON rows.
  • execute: Runs write SQL such as INSERT, UPDATE, DELETE, CREATE, and DROP, then reports affected rows.
  • schema: Lists columns, data types, nullability, defaults, and primary keys for a schema, with optional table filtering.
  • list_tables: Lists base tables in a schema and includes their disk size.
  • transaction: Runs multiple SQL statements atomically and rolls them back if one fails.
  • Read-only mode removes execute and transaction from the available tool set.

Limitations and notes

Write access is enabled by default, so use the mode=readonly connection-string option when an AI client should only inspect data. The server requires a reachable PostgreSQL instance and a valid connection string. It is designed around standard PostgreSQL connections rather than a provider-specific API.

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Postgresql MCP

@sarmadparvez/postgresql-mcp is an MCP server that connects AI clients to PostgreSQL databases, including local, Supabase, AWS RDS, and self-hosted instances. Its main tools query data, execute writes, inspect schemas, list tables, and run multiple SQL statements atomically, with an optional read-only mode.

Install it globally with `npm install -g @sarmadparvez/postgresql-mcp`, or run it directly with `npx @sarmadparvez/postgresql-mcp <postgresql-connection-string>`. Node.js 18+ is required, and the npx method requires npm 7 or newer.

Append `?mode=readonly` to the PostgreSQL connection string. The server then keeps `query`, `schema`, and `list_tables` available and disables the `execute` and `transaction` tools.

Yes. The server is listed as compatible with Cursor, Claude Desktop, Windsurf, and other MCP-compatible clients. Configure the client to launch the server with the PostgreSQL connection string as its argument.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewPostgresql MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/sarmadparvez-postgresql-mcp?style=directory)](https://allmcps.com/mcp/sarmadparvez-postgresql-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/sarmadparvez-postgresql-mcp"><img src="https://allmcps.com/api/badge/sarmadparvez-postgresql-mcp?style=directory" alt="Postgresql MCP on AllMCPs" /></a>