# @sarmadparvez/postgresql-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/sarmadparvez/postgresql-mcp  
**GitHub Stars:** 3  
**npm Downloads (last month):** 346  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/sarmadparvez-postgresql-mcp

## Description
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.

## Tools
Capabilities this server exposes over MCP:

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

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "postgresql-mcp": {
    "command": "npx",
    "args": ["-y","@sarmadparvez/postgresql-mcp"]
  }
}
```

## Documentation

## 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:

```bash
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:

```bash
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.

_Full upstream README: https://allmcps.com/mcp/sarmadparvez-postgresql-mcp/readme_

