PostgreSQL MCP server with read-write access and transactions

PostgreSQL MCP server with read-write access and transactions

postgresql-mcp-sarmadparvez•bysarmadparvez

An MCP server that connects any standard PostgreSQL database to an AI assistant, offering read-write SQL, atomic multi-statement transactions, and schema inspection with an optional read-only mode.

License: ISC•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Provides a query tool for read-only SELECT statements that runs inside a READ ONLY transaction and returns rows as JSON.
  • •Provides an execute tool for write SQL statements such as INSERT, UPDATE, DELETE, CREATE, and DROP, returning rows affected.
  • •Provides a transaction tool that runs multiple SQL statements atomically and rolls back all statements if any one fails.
  • •Provides schema inspection and table listing tools covering columns, types, nullability, defaults, primary keys, and disk size.

BEST FOR

  • •Using an AI assistant to inspect and modify data in any standard PostgreSQL instance, including local, Supabase, RDS, and self-hosted databases.
  • •Restricting an AI assistant to read-only operations by starting the server in read-only mode.
  • •Running multi-step database changes that must all succeed together or be fully rolled back.

ABOUT POSTGRESQL-MCP-SARMADPARVEZ

PostgreSQL MCP server with read-write access and transactions is cataloged as an MCP server attributed to sarmadparvez. An MCP server that connects any standard PostgreSQL database to an AI assistant, offering read-write SQL, atomic multi-statement transactions, and schema inspection with an optional read-only mode. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: ISC. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for PostgreSQL MCP server with read-write access and transactions are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Which tools are disabled in read-only mode?

Read-only mode disables the execute and transaction tools, leaving only query, schema, and list_tables.

Which databases can this server connect to?

It works with any standard PostgreSQL connection string, including local, self-hosted, Supabase, and AWS RDS instances, without cloud lock-in.

Upstream README

View this exact version on GitHub

README.md · 05874eab641f · Fetched 2026-11-13 11:06:13 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

postgresql-mcp

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.

Features

  • Full read-write SQL access (SELECT, INSERT, UPDATE, DELETE, CREATE, DROP)
  • Atomic multi-statement transactions with automatic rollback on failure
  • Schema inspection: columns, types, nullability, defaults, primary keys
  • Optional read-only mode via ?mode=readonly
  • No cloud lock-in — works with any standard PostgreSQL connection string
  • Single file, minimal dependencies

Why this exists

There 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.

Requirements

  • Node.js 18+
  • A running PostgreSQL database

Installation

npm install -g @sarmadparvez/postgresql-mcp

Or run directly without installing (requires npm 7+ / Node.js 18+):

npx @sarmadparvez/postgresql-mcp <postgresql-connection-string>

Usage

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

Tools

ToolAvailable inDescription
queryAlwaysExecute a read-only SELECT query. Runs inside a READ ONLY transaction. Returns rows as JSON.
executeRead-write modeExecute a write SQL statement (INSERT, UPDATE, DELETE, CREATE, DROP, etc.). Returns rows affected.
schemaAlwaysList columns, types, nullability, defaults, and primary keys for tables in a given schema. Optionally filter to a specific table.
list_tablesAlwaysList all base tables in a schema with their disk size.
transactionRead-write modeExecute multiple SQL statements atomically. Rolls back all statements if any one fails.

Read-Only Mode

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.

Claude Desktop Configuration

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:

  • Replace command with the output of which node
  • Replace the prefix of the script path with the output of npm 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"
      ]
    }
  }
}

Compatible AI Clients

This MCP server works with any client that supports the Model Context Protocol:

Dependencies

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for PostgreSQL MCP server with read-write access and transactions from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/postgresql-mcp-sarmadparvez)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage