Postgres MCP logo

Postgres MCP

by JaviMaligno

Query, inspect, analyze, and optionally modify PostgreSQL databases through MCP with read-only defaults and data-redaction controls.

Install Postgres 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": {
    "javimaligno-postgres-mcp": {
      "command": "npx",
      "args": [
        "@javiagui/postgresql-mcp"
      ],
      "env": {
        "POSTGRES_CONNECTIONS": "YOUR_VALUE_HERE",
        "POSTGRES_HOST": "YOUR_VALUE_HERE",
        "POSTGRES_PORT": "YOUR_VALUE_HERE",
        "POSTGRES_USER": "YOUR_VALUE_HERE",
        "POSTGRES_PASSWORD": "YOUR_VALUE_HERE",
        "POSTGRES_DB": "YOUR_VALUE_HERE",
        "POSTGRES_SSLMODE": "YOUR_VALUE_HERE",
        "ALLOW_WRITE_OPERATIONS": "YOUR_VALUE_HERE"
      }
    }
  }
}

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

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Claude Code command
claude mcp add --env POSTGRES_CONNECTIONS=YOUR_VALUE_HERE --env POSTGRES_HOST=YOUR_VALUE_HERE --env POSTGRES_PORT=YOUR_VALUE_HERE --env POSTGRES_USER=YOUR_VALUE_HERE --env POSTGRES_PASSWORD=YOUR_VALUE_HERE --env POSTGRES_DB=YOUR_VALUE_HERE --env POSTGRES_SSLMODE=YOUR_VALUE_HERE --env ALLOW_WRITE_OPERATIONS=YOUR_VALUE_HERE --transport stdio javimaligno-postgres-mcp -- npx @javiagui/postgresql-mcp

Run in your terminal. Add --scope project to share it with your team through .mcp.json.

We couldn’t confirm it starts correctly

We ran the install command but it didn't respond within our test window — this can mean a slow first-time install rather than a real problem.

npx @javiagui/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 .

Overview

JaviMaligno/postgres_mcp connects MCP-compatible clients to PostgreSQL for SQL queries, schema discovery, table analysis, and optional write operations. Its query path is read-only by default, while INSERT, UPDATE, and DELETE require write access to be enabled globally or for a selected database. Connections can be configured by environment variables or database aliases, with credentials kept outside tool arguments. Reach for it when an agent needs structured access to PostgreSQL metadata and controlled database operations.

Use cases

  • Explore PostgreSQL schemas and table relationships
  • Run read-only SQL investigations
  • Inspect query execution plans and table health
  • Analyze indexes, constraints, and database structure
  • Enable controlled writes for selected connections

Key features

  • Read-only SQL queries by default
  • Optional INSERT, UPDATE, and DELETE execution
  • Schema, table, view, function, index, and constraint inspection
  • Query plans and table statistics
  • Multiple aliased PostgreSQL connections
  • PII detection and column-level result masking

Tools15

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

Verified live~1.6k 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

Recent health check succeeded.

27/27 checks healthy over the last 117d

What it can do

From the 15 tools this server returned when we ran it.

Runs commands · 2Can delete or modify data · 1Handles credentials · 1Read-only tools · 13
Network at startup3 connections
Files written at startupNone
Install scriptsNone
npm provenanceSigned build
Package age102 days
Maintainers1

Observed 2026-11-13 in an isolated sandbox. A description of reach, not a security audit.

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

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

Adoption & maintenance

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

GitHub stars12Stargazers on the source repository.
npm downloads465Package downloads in the last 30 days.
Last commit21d agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Tools exposed15Callable tools this server registers over MCP.
Directory activity6 viewsConfig copies, upvotes, and views on AllMCPs.

How Postgres MCP works

What JaviMaligno/postgres_mcp does

JaviMaligno/postgres_mcp exposes PostgreSQL operations through MCP. It supports direct SQL querying, query-plan inspection, schema browsing, and database metadata inspection. Agents can enumerate schemas, tables, views, functions, indexes, and constraints; inspect table definitions and statistics; search for columns; and retrieve database connection information.

The server also supports controlled data modification. The execute tool handles INSERT, UPDATE, and DELETE statements, but write access is disabled by default and must be enabled globally or for the selected connection. The separate query tool is intended for read operations.

Optional result protections can mask personal data before results reach the model. Detection can cover email addresses, phone numbers, payment cards, IBANs, and several national identifiers. Column deny lists and allow lists provide additional control over which values are exposed.

How it works

The server can use either the TypeScript package, installed through npm, or the Python package, installed through pipx. Both implementations provide the same functionality. It is designed to work with Claude Code, Claude Desktop, Cursor, and other MCP-compatible clients.

A single PostgreSQL connection can be configured with standard connection variables. For multiple databases, POSTGRES_CONNECTIONS defines aliases and connection details. Each tool can receive a database alias; if omitted, the configured default is used. Connections are opened lazily, so an unused configured database does not open a connection.

Credentials come from the environment or connection configuration rather than tool arguments. The list_databases tool reports aliases, hosts, database names, write permissions, and the default connection without returning credentials. Query results are limited by the configured maximum row count, and queries have a configurable timeout.

Setup and configuration

Install the TypeScript implementation with npm install -g @javiagui/postgresql-mcp, or run it directly with npx @javiagui/postgresql-mcp. The Python implementation is available with pipx install postgresql-mcp.

For a single database, configure POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB; POSTGRES_HOST defaults to localhost and POSTGRES_PORT to 5432. POSTGRES_SSLMODE controls SSL behavior. ALLOW_WRITE_OPERATIONS enables writes globally when set appropriately, while QUERY_TIMEOUT and MAX_ROWS control query execution and result size.

Use REDACT_PII, REDACT_COLUMNS, and ALLOWED_COLUMNS to configure result masking. Multi-database configurations can set per-connection write and redaction behavior. POSTGRES_CONNECTIONS and the plain single-connection variables are mutually exclusive.

Tools and capabilities

  • Run read-only SQL with query.
  • Run INSERT, UPDATE, or DELETE with execute when permitted.
  • Inspect plans with explain_query.
  • Explore schemas, tables, views, functions, indexes, and constraints.
  • Inspect table definitions, statistics, view definitions, and database information.
  • Find columns across tables with search_columns.
  • Select a configured database through list_databases and per-tool aliases.
  • Browse database structure through MCP resources and use guided MCP prompts for exploration, query building, and documentation.

Limitations and notes

Write operations require explicit permission and remain controlled per connection when multiple databases are configured. When redaction is enabled, query and explain_query run in a read-only transaction, and results are withheld if masking fails rather than being returned unredacted. Column rules are matched case-insensitively and can use column, table.column, or schema.table.column patterns. Computed expressions have different behavior under deny and allow lists, so strict exposure control is best handled with an allow list and carefully defined source columns.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

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

Frequently Asked Questions about Postgres MCP

JaviMaligno/postgres_mcp is an MCP server that connects AI clients to PostgreSQL databases. Its main tools run read-only queries, execute permitted writes, inspect schemas and tables, analyze query plans and table statistics, and search columns. It can select among configured database aliases without exposing credentials to tool calls.

Install the TypeScript package with `npm install -g @javiagui/postgresql-mcp`, or install the Python package with `pipx install postgresql-mcp`. The TypeScript server can also be launched with `npx @javiagui/postgresql-mcp`. Configure PostgreSQL credentials through environment variables.

Enable writes with `ALLOW_WRITE_OPERATIONS` for a single configuration, or set `allowWrite` on an individual entry in `POSTGRES_CONNECTIONS`. The `execute` tool handles INSERT, UPDATE, and DELETE, and writes remain disabled unless the relevant setting permits them.

Yes. Define multiple connections in `POSTGRES_CONNECTIONS` and assign each an alias. Call `list_databases` to inspect configured aliases, then pass the selected alias as the `database` argument to other tools. One connection can be marked as the default.

Yes. The server works with Cursor, Claude Code, Claude Desktop, and other MCP-compatible clients. Configure the installed TypeScript or Python command in the client and provide the PostgreSQL connection settings through its environment configuration.

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 PreviewPostgres MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/javimaligno-postgres-mcp?style=directory)](https://allmcps.com/mcp/javimaligno-postgres-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/javimaligno-postgres-mcp"><img src="https://allmcps.com/api/badge/javimaligno-postgres-mcp?style=directory" alt="Postgres MCP on AllMCPs" /></a>