Skip to main content

postgresql-mcp (Python)

MCP server for PostgreSQL database operations. Works with Claude Code, Claude Desktop, Cursor, and any MCP-compatible client.

This is the Python implementation. A TypeScript implementation with the same tool set lives in /typescript and is published to npm as @javiagui/postgresql-mcp.

This file used to be a symlink to the repository root README. That made the published source distribution carry a dangling link, which broke the wheel build — so it is a real file now, deliberately kept short. The full documentation is in the repository README.

Install

pipx install postgresql-mcp

Configure

claude mcp add postgres -s user \
  -e POSTGRES_HOST=localhost \
  -e POSTGRES_USER=your_user \
  -e POSTGRES_PASSWORD=your_password \
  -e POSTGRES_DB=your_database \
  -- postgresql-mcp
Variable Required Default Description
POSTGRES_HOST localhost Database host
POSTGRES_PORT 5432 Database port
POSTGRES_USER ✅ Database user
POSTGRES_PASSWORD ✅ Database password
POSTGRES_DB ✅ Database name
POSTGRES_SSLMODE prefer SSL mode
ALLOW_WRITE_OPERATIONS false Enable INSERT/UPDATE/DELETE
QUERY_TIMEOUT 30 Query timeout in seconds
MAX_ROWS 1000 Maximum rows returned per query
REDACT_PII false Mask emails, phones, cards, IBANs and national IDs found in results
REDACT_COLUMNS Comma-separated columns to mask entirely
ALLOWED_COLUMNS Comma-separated allow list: every other column is masked

What it provides

  • 15 tools — query execution, schema exploration, table analysis, EXPLAIN plans
  • 4 prompts — guided workflows for exploration, query building, performance analysis and documentation
  • Named databases — select a configured connection per tool call without exposing credentials
  • Resources — browsable database structure as markdown
  • Read-only by default, with SQL injection prevention and credential protection
  • Personal-data redaction (opt-in) — detection, column deny lists and allow lists, applied before results reach the model (details)

See the full documentation for the complete tool reference, security model, and the installation guide for database permissions and remote connections.

License

MIT

Metadata

Release files for postgresql-mcp 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for postgresql-mcp 1.2.2
File Size Uploaded Provenance Actions
postgresql_mcp-1.2.2.tar.gz 123.3 kB With provenance Details for postgresql_mcp-1.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for postgresql-mcp 1.2.2
File Interpreter ABI Platform Actions
postgresql_mcp-1.2.2-py3-none-any.whl Python 3 none any Details for postgresql_mcp-1.2.2-py3-none-any.whl

Total release size: 154.4 kB

Release files / postgresql_mcp-1.2.2.tar.gz

Download URL postgresql_mcp-1.2.2.tar.gz
Size 123.3 kB
Tags Source
SHA-256 checksum
How to use checksums
01c3809f34228c6e11cc985cd9cacd71bb9d7aec4462586ad3ee84029893dfc9
BLAKE2b-256 checksum
How to use checksums
297a764f221a642fdd2f7aff2546c1e8a829366dc3700a6ae051951f6cee60dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / postgresql_mcp-1.2.2-py3-none-any.whl

Download URL postgresql_mcp-1.2.2-py3-none-any.whl
Size 31.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
860d06d29bb99203a23a4e57b2e5dc76bad3a8a18e8bcfe18d1d0a9ddbc69851
BLAKE2b-256 checksum
How to use checksums
6a1fa8c532d3678a7f209875743bda8525b2e265fa99b7243d2687123f855cc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for postgresql-mcp 1.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for postgresql_mcp-1.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page