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

sierra-db-query

v1.0.2

Published

Sierra DB Query - A Model Context Protocol (MCP) server for PostgreSQL database management

Readme

Sierra DB Query

smithery badge

A Model Context Protocol (MCP) server that provides comprehensive PostgreSQL database management capabilities for AI assistants.

Features

10 powerful tools for complete PostgreSQL database management:

Core Tools

  • Schema Management - Tables, columns, ENUMs, views
  • Query Execution - SELECT operations with count/exists support
  • Data Mutations - INSERT/UPDATE/DELETE/UPSERT operations
  • SQL Execution - Arbitrary SQL with transaction support

Analysis & Monitoring

  • Database Analysis - Configuration, performance, and security analysis
  • Real-time Monitoring - Active queries, locks, connection stats, replication

Database Object Management

  • Index Management - Create, drop, reindex, analyze usage
  • Constraint Management - Foreign keys, unique, check, primary key constraints
  • Function Management - Create, drop, and list PostgreSQL functions
  • User Management - Create users, manage permissions, grant/revoke access

Quick Start

Prerequisites

  • Node.js >= 18.0.0
  • Access to a PostgreSQL server
  • (Optional) An MCP client like Cursor or Claude for AI integration

Option 1: Install via Smithery (Recommended)

npx -y @smithery/cli install @Yaswanth-ampolu/sierra-db-query --client claude

Option 2: npm

# Install globally
npm install -g @sierra/db-query

# Or run directly with npx
npx @sierra/db-query --connection-string "postgresql://user:pass@localhost:5432/db"

Add to your MCP client configuration:

{
  "mcpServers": {
    "sierra-db-query": {
      "command": "npx",
      "args": [
        "@sierra/db-query",
        "--connection-string", "postgresql://user:password@host:port/database"
      ]
    }
  }
}

Option 3: Docker

# Build the Docker image
docker build -t sierra-db-query .

# Run with environment variable
docker run -i --rm \
  -e POSTGRES_CONNECTION_STRING="postgresql://user:password@host:port/database" \
  sierra-db-query

Add to your MCP client configuration:

{
  "mcpServers": {
    "sierra-db-query": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "sierra-db-query"
      ],
      "env": {
        "POSTGRES_CONNECTION_STRING": "postgresql://user:password@host:port/database"
      }
    }
  }
}

Option 4: Manual Installation (Development)

git clone https://github.com/Yaswanth-ampolu/sierra-db-query.git
cd sierra-db-query
npm install
npm run build

Add to your MCP client configuration:

{
  "mcpServers": {
    "sierra-db-query": {
      "command": "node",
      "args": [
        "/path/to/sierra-db-query/build/index.js",
        "--connection-string", "postgresql://user:password@host:port/database"
      ]
    }
  }
}

Available Tools

| Tool | Description | |------|-------------| | sierra_manage_schema | Schema management - tables, columns, ENUMs, views | | sierra_execute_query | SELECT queries with count/exists operations | | sierra_execute_mutation | INSERT/UPDATE/DELETE/UPSERT operations | | sierra_execute_sql | Arbitrary SQL execution with transaction support | | sierra_analyze_database | Configuration, performance, security analysis | | sierra_monitor_database | Real-time monitoring - queries, locks, connections | | sierra_manage_indexes | Index management - create, drop, reindex, analyze | | sierra_manage_constraints | Constraint management - FK, unique, check, PK | | sierra_manage_functions | Function management - create, drop, list | | sierra_manage_users | User and permission management |

Example Usage

// Analyze database performance
{ "analysisType": "performance" }

// Create a table with constraints
{
  "operation": "create_table",
  "tableName": "users",
  "columns": [
    { "name": "id", "type": "SERIAL PRIMARY KEY" },
    { "name": "email", "type": "VARCHAR(255) UNIQUE NOT NULL" }
  ]
}

// Query data with parameters
{
  "operation": "select",
  "query": "SELECT * FROM users WHERE created_at > $1",
  "parameters": ["2024-01-01"],
  "limit": 100
}

// Insert new data
{
  "operation": "insert",
  "table": "users",
  "data": {"name": "John Doe", "email": "[email protected]"},
  "returning": "*"
}

// Monitor active queries
{
  "operation": "active_queries",
  "includeIdle": false
}

CLI Options

# With connection string
sierra-db-query --connection-string "postgresql://user:password@host:5432/database"

# With tools configuration
sierra-db-query --tools-config ./tools-config.json

# HTTP mode (for Smithery deployment)
sierra-db-query --http --port 7409

Tools Configuration

Create a tools-config.json to enable specific tools:

{
  "enabledTools": [
    "sierra_manage_schema",
    "sierra_execute_query",
    "sierra_execute_mutation",
    "sierra_analyze_database"
  ]
}

Features Highlights

Security Focused

  • SQL injection prevention with parameterized queries
  • Connection string validation
  • Non-root Docker user for security

Production Ready

  • Flexible connection options (CLI args, env vars, per-tool config)
  • Connection pooling for performance
  • Comprehensive error handling
  • Docker support for containerized deployment

Developer Friendly

  • TypeScript with full type safety
  • Zod schema validation
  • Clear error messages

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

# Clean build
npm run clean

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Create a Pull Request

License

MIT License - see LICENSE file for details.

Author

Yaswanth Ampolu - [email protected]