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

@arieffian/postgres-mcp-server

v0.2.0

Published

MCP server exposing safe, read-only-by-default PostgreSQL access.

Readme

postgres-mcp-server

CI npm License: MIT

An MCP server for safely querying PostgreSQL from an LLM. Read-only by default, multi-connection with named aliases, Postgres-session-enforced safety.

Quickstart

Create ~/.config/postgres-mcp/config.json:

{
  "connections": {
    "local": {
      "url_env": "LOCAL_DATABASE_URL",
      "mode": "read"
    }
  }
}

Add to your MCP client config (Claude Desktop, Cursor, Windsurf, Zed):

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@arieffian/postgres-mcp-server"],
      "env": { "LOCAL_DATABASE_URL": "postgres://user:pw@localhost/db" }
    }
  }
}

Restart the client and ask: "Ping the local Postgres and list its tables."

Modes

Every connection declares its mode statically in config. Escalation requires editing config and restarting.

| Mode | SELECT | INSERT/UPDATE/DELETE | DDL | Notes | |-------|:------:|:--------------------:|:---:|-------| | read | ✓ | ✗ | ✗ | Default. SET default_transaction_read_only = on at the session level. | | write | ✓ | ✓ | ✗ | Writes must go through begin_transaction → execute → commit. | | admin | ✓ | ✓ | ✓ | Same tx flow as write; DDL also permitted. |

Tools

Meta

  • ping, list_connections

SQL

  • query — read-only SELECT via server-side cursor
  • begin_transaction, commit, rollback — tx lifecycle
  • execute — INSERT/UPDATE/DELETE/DDL inside an open tx

Schema introspection (Phase 2, new in 0.2.0)

  • list_databases, list_schemas
  • list_tables — includes regular, partitioned, and foreign tables (via kind field); row count is clamped to 0 for never-analyzed tables
  • list_indexes, list_constraints — per-table catalog listings
  • list_functions — excludes functions installed by extensions
  • describe_table — composite: columns, PK, FKs, indexes, constraints in one call

Observability — ships in Phase 3.

Safety

Five layers — see docs/safety.md. Highlights:

  • Read-only enforced by the Postgres session, not by parsing SQL — we do not trust our own parser.
  • Statement timeout per connection (default 30s).
  • Every SELECT wrapped in a server-side cursor; results capped by row count and byte size.
  • Writes require an explicit transaction; no autocommit.
  • Bound parameter values are never logged. Credentials in URLs are redacted.

Configuration

Discovery order (first hit wins):

  1. --config <path> CLI flag
  2. $POSTGRES_MCP_CONFIG env var
  3. $XDG_CONFIG_HOME/postgres-mcp/config.json (fallback ~/.config/postgres-mcp/config.json)
  4. ./postgres-mcp.config.json

Contributing

Requires Node ≥ 20. Local dev: npm install, npm test. Integration tests use testcontainers and need a working Docker daemon.

Publishing

Set NPM_TOKEN in the repo's GitHub Actions secrets. Changesets automatically opens a release PR on push to main; merging it publishes to npm with provenance.

License

MIT