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

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

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

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.1.0
File Size Uploaded
postgresql_mcp-1.1.0.tar.gz 33.9 kB Details

Built distribution (wheel)

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

Total release size: 55.2 kB

Release files / postgresql_mcp-1.1.0.tar.gz

Download URL postgresql_mcp-1.1.0.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
11cacef2e82c9a5f11a23f265e1adc58ac58f3f2c8c3b1334a3207ea31a82570
BLAKE2b-256 checksum
How to use checksums
ff5c4690217dd117eefcf3cd5717975913bba3d820b07c3271649472babdbecd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 3, 2026.

Transparency log

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

Download URL postgresql_mcp-1.1.0-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
364080ca7d15518c454f3b7c05f9e1f9d3cad4cda703e715ee820f59e3127546
BLAKE2b-256 checksum
How to use checksums
1f6608fd4a8e62fbb9b7a7440e76928d6ab8d7b257fa7a23faa64f18036d6d92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

0.2.0

2 release files

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