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

@devmels/postgres-db-mcp

v1.0.5

Published

MCP server for PostgreSQL database operations - fetch schema, run queries, and modify data

Readme

@devmels/postgres-db-mcp

A Model Context Protocol (MCP) server that provides PostgreSQL database operations for Large Language Models (LLMs). This server allows LLMs to fetch database schema information, execute read queries, and perform data modifications safely.

Features

  • Database Schema Discovery: Retrieve tables, columns, and foreign key relationships
  • Safe Query Execution: Execute SELECT queries for data retrieval
  • Data Modification: Perform INSERT, UPDATE, and DELETE operations
  • Type Safety: Built with TypeScript and Zod validation
  • Environment Configuration: Secure database connection management

Installation

From npm (Recommended)

npm install -g @devmels/postgres-db-mcp

From source

git clone https://github.com/devtitus/postgres-db-mcp.git
cd postgres-db-mcp
npm install
npm run build

Configuration

Environment Variables

Create a .env file in your project root or set environment variables:

DATABASE_URL=postgresql://username:password@localhost:5432/your_database

Required Environment Variables:

  • DATABASE_URL: PostgreSQL connection string

MCP Server Configuration

Add the server to your MCP settings configuration file:

For npm-installed package:

{
  "mcpServers": {
    "postgres-db": {
      "command": "npx",
      "args": ["-y", "@devmels/postgres-db-mcp"],
      "env": {
        "DATABASE_URL": "postgresql://username:password@localhost:5432/your_database"
      }
    }
  }
}

For local development:

{
  "mcpServers": {
    "postgres-db": {
      "command": "node",
      "args": ["/path/to/your/dist/index.js"],
      "env": {
        "DATABASE_URL": "postgresql://username:password@localhost:5432/your_database"
      }
    }
  }
}

Available Tools

1. get_database_context

Returns comprehensive database schema information including tables, columns, and relationships.

Parameters: None

Example Usage:

Get the database schema and relationships

2. run_read_query

Executes SELECT queries to retrieve data from the database.

Parameters:

  • sql (string): The SELECT SQL query to execute

Example Usage:

SELECT * FROM users WHERE active = true LIMIT 10;

3. run_write_query

Executes INSERT, UPDATE, or DELETE queries to modify database data.

Parameters:

  • sql (string): The SQL query to execute (INSERT, UPDATE, DELETE only)

Example Usage:

INSERT INTO users (name, email) VALUES ('John Doe', '[email protected]');

Usage Examples

Getting Database Context

Can you show me the structure of my PostgreSQL database?
What tables and relationships exist in my database?

Reading Data

Show me the first 10 users from the users table
Get all active orders from the orders table

Modifying Data

Add a new user with name 'Jane Smith' and email '[email protected]'
Update the status of order #123 to 'completed'
Delete inactive user accounts older than 1 year

Security Considerations

  • Read-Only Operations: Use run_read_query for safe data retrieval
  • Write Operations: run_write_query should be used carefully as it modifies data
  • Input Validation: All queries are validated before execution
  • Connection Security: Use secure connection strings with proper authentication

Development

Building from Source

npm run build

Running Locally

npm start

Testing

npm test

Requirements

  • Node.js >= 18.0.0
  • PostgreSQL database
  • MCP-compatible client (Claude Desktop, VS Code extensions, etc.)

License

ISC License - see LICENSE file for details

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Support

For issues and questions:

  • GitHub Issues: https://github.com/devtitus/postgres-db-mcp/issues
  • Email: [email protected]

Changelog

v1.0.0

  • Initial release
  • Database schema discovery
  • Read and write query execution
  • TypeScript support
  • MCP SDK integration