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

pg-mcp-server

v0.3.0

Published

A Model Context Protocol server for PostgreSQL databases

Readme

Postgres MCP Server

A Model Context Protocol server for PostgreSQL databases. Enables LLMs to query and analyze PostgreSQL databases through a controlled interface.

https://github.com/user-attachments/assets/6571c20c-91c9-4a6e-8332-13b587b79fbf

Installation

Install MCP Server

Add to your MCP client settings:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["--yes", "pg-mcp-server", "--transport", "stdio"],
      "env": {
        "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
      }
    }
  }
}

Configuration

  • DATABASE_URL - PostgreSQL connection string (required)
  • DANGEROUSLY_ALLOW_WRITE_OPS - Enable writes (default: false)
  • DEBUG - Enable debug logging (default: false)
  • PG_SSL_ROOT_CERT - Optional path to a TLS CA bundle (e.g., AWS RDS global bundle)

Usage

Transports

  • Default transport is stdio. Switch to HTTP with the --transport flag.
  • HTTP mode serves the MCP Streamable HTTP endpoint at /mcp on PORT (default 3000).
  • Clients that support Streamable HTTP should connect to http://localhost:3000/mcp.

Start commands:

# stdio transport (default, via installed CLI)
pg-mcp-server --transport=stdio

# http transport
pg-mcp-server --transport=http

Tools

  • query - Execute SQL queries
    { "sql": "SELECT * FROM users WHERE active = true LIMIT 10" }

Resources

  • postgres://tables - List all tables
  • postgres://table/{schema}/{table} - Get table schema and sample data

Example Prompts

Here's an example prompt to test if your MCP server is working:

Show me the first 5 users from the database

Data Analysis & Notebooks

For data analysis and exploration, I've added a Cursor rule for using the MCP server together with notebooks in .cursor/rules/notebooks.mdc:

Quick Start with Docker

# Start PostgreSQL with sample data
bun run db:start

# Test with MCP Inspector
bun run inspector

# Stop PostgreSQL
bun run db:stop

Sample tables included: users, products, orders, order_items

Development

# Clone and install
git clone https://github.com/ericzakariasson/pg-mcp-server.git
cd pg-mcp-server
bun install

# Run (stdio transport)
bun run index.ts -- --transport=stdio
DEBUG=true bun run index.ts -- --transport=stdio

# Run (http transport)
bun run index.ts -- --transport=http
DEBUG=true bun run index.ts -- --transport=http
bun test                      # Run tests

Use local build in MCP client settings:

bun run build:js
{
  "mcpServers": {
    "postgres": {
      "command": "node",
      "args": ["/absolute/path/to/pg-mcp-server/lib/index.js", "--transport", "stdio"],
      "env": {
        "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
      }
    }
  }
}

Releases

This repo auto-creates a GitHub Release when you push a tag that matches the version in package.json:

  1. Update CHANGELOG.md and bump the version in package.json.
  2. Commit the changes on main (or your release branch).
  3. Create and push a matching tag:
VERSION=$(jq -r .version package.json)
git tag v"$VERSION"
git push origin v"$VERSION"

The GitHub Actions workflow will validate that the tag (e.g. v0.1.0) matches package.json, then use gh to create a release with generated notes, and publish to npm.

License

MIT - see LICENSE