Skip to main content

database-mcp-postgres

PyPI CI License: MIT

MCP server giving AI clients safe, structured access to a PostgreSQL database. Two tools, guardrails on by default.

Quick start (Claude Desktop / Claude Code / Cursor)

{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": ["database-mcp-postgres"],
      "env": {
        "POSTGRES_HOST": "127.0.0.1",
        "POSTGRES_USER": "youruser",
        "POSTGRES_PASSWORD": "yourpassword",
        "POSTGRES_DATABASE": "yourdb"
      }
    }
  }
}

Configuration

Sources, highest precedence first: flags, --config YAML, environment variables, defaults.

Environment variables

POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DATABASE, or a full DATABASE_URL (postgres://user:pass@host:5432/db, inline credentials discouraged). libpq's native PGHOST/PGUSER/PGPASSWORD/PGDATABASE also work.

Password without plaintext

  • POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password (Docker/Kubernetes secrets convention)
  • In YAML: connection.password: ${POSTGRES_PASSWORD} (env expansion, never a literal)

The password is held in a non-printable type and redacted from all output.

Tools

  • execute_sql: run a single SQL statement. Returns a summary line and compact JSON {columns, rows}.
  • search_objects: list tables with estimated row counts, or describe one table (columns, indexes, foreign keys).

Guardrails

  • Read-only by default, enforced twice: a SQL guard plus the default_transaction_read_only=on startup parameter at the server. Pass --allow-write to enable writes.
  • Results capped at maxRows (default 1000, MAX_ROWS).
  • Statements exceeding queryTimeoutMs (default 30000, QUERY_TIMEOUT_MS) are aborted server-side via statement_timeout.

Full contract: docs/tool-contract.md


mcp-name: io.github.arifulislamat/database-mcp-postgres

Metadata

Release files for database-mcp-postgres 0.2.1

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

Source distribution (sdist)

Source distribution for database-mcp-postgres 0.2.1
File Size Uploaded Provenance
database_mcp_postgres-0.2.1.tar.gz 5.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for database-mcp-postgres 0.2.1
File Interpreter ABI Platform
database_mcp_postgres-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / database_mcp_postgres-0.2.1.tar.gz

Download URL database_mcp_postgres-0.2.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f7b322e5cb7d050961d5aeb97961b2b1a2d75208665fac2e37d5e8faba0302b3
BLAKE2b-256 checksum
How to use checksums
d797fa8adfeca7d6d4cf48f512cd7af10a93efce5aa3d54a84cc3d3fe43b9561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / database_mcp_postgres-0.2.1-py3-none-any.whl

Download URL database_mcp_postgres-0.2.1-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c43532661dd1ef5d2220a802aaaa8b2c2a0f6d004ba5326f367634ca6894645d
BLAKE2b-256 checksum
How to use checksums
a9c8696ba9c594c946a22aaa3e438950fe522305fd8b15665794fe497e609a6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for database-mcp-postgres 0.2.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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