npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rexymayderio/postgres-mcp

v1.1.0

Published

MCP server for PostgreSQL schema introspection and query execution

Downloads

227

Readme

PostgreSQL MCP Server

MCP server for PostgreSQL: schema introspection, SELECT (with lock confirmation), gated writes/DDL/transactions, templates, and EXPLAIN.

Quick Start (npx)

Secrets belong in agent mcp.json env (mcpServers.*.env) — not project .env. Do not create a project .env for runtime credentials.

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@rexymayderio/postgres-mcp"],
      "env": {
        "PGHOST": "localhost",
        "PGPORT": "5432",
        "PGDATABASE": "your_database_name",
        "PGUSER": "your_username",
        "PGPASSWORD": "your-password"
      }
    }
  }
}

Optional: DATABASE_URL, PGSSL=true, PG_STATEMENT_TIMEOUT_MS, PG_MAX_ROWS.

Privilege scope: use a least-privilege Postgres role. Prefer a SELECT-only user for read-heavy agents; use a separate write role when writes are required.

Tools

| Tool | Notes | |------|-------| | list_schemas | Non-system schemas | | list_tables | Estimated rows (reltuples); exact_counts=true for COUNT(*) | | describe_table | Columns, PK, FKs, indexes | | list_relationships | FK graph | | read_query | SELECT only; LIMIT-capped; FOR UPDATE/FOR SHARE need confirmed | | write_query | INSERT/UPDATE/DELETE — strong confirm (separate from reads/DDL) | | schema_query | CREATE/ALTER/DROP — strong confirm (separate from DML) | | transaction_query | Multi-statement — per-statement risk preview + strong confirm | | list_templates / run_template | Safe parameterized helpers | | explain_query | Plan-only by default; analyze=true needs confirmed |

Writes are separate tools from reads. Agents must not use read_query for DML/DDL.

Strong confirmation

MCP has no native UI modal. Mutating tools return an impact preview and do not execute until called again with the same sql and confirmed: true.

Client operators should require approval on write_query, schema_query, and transaction_query (destructiveHint / non-readOnly).

Safety

  • Comment-aware SQL classification (WITH … INSERT is not read-only)
  • Multi-statement blocked on read_query
  • statement_timeout on connections
  • Confirmation previews explain impact before mutating or locking
  • Errors redacted (no password/URL dumps)

Local development

npm install
npm test
npm run build
# Smoke (pass env inline — never create a repo .env):
# PGHOST=… PGDATABASE=… PGUSER=… PGPASSWORD=… npm run test:connections

Risks

  • Row content is untrusted (prompt injection)
  • transaction_query can still run privileged SQL after confirmation — use a scoped DB role
  • Shared bot identity across sessions

Deferred

  • Aurora IAM / RDS Data API
  • Splitting read vs write into separate MCP packages