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

@gongrzhe/server-db-query-builder

v1.0.0

Published

Database Query Builder MCP App Server with interactive SQL editor and results viewer

Downloads

97

Readme

Database Query Builder MCP Server

Interactive SQL editor with query execution, results table, and database schema exploration.

Features

  • Execute SQL Queries - Run arbitrary SQL queries against a PostgreSQL database with real-time results in a structured table view
  • Schema Exploration - List all tables in the database with column counts and estimated row statistics
  • Table Introspection - View detailed column definitions including data types, nullability, defaults, and primary key constraints
  • Auto-Limiting - SELECT queries are automatically limited to 1,000 rows to prevent memory issues
  • Execution Metrics - Track query execution time and row counts for performance monitoring
  • Safety Features - Statement timeout (30 seconds) prevents long-running queries from hanging

Installation

npm install @gongrzhe/server-db-query-builder

Usage

As a CLI

npx @gongrzhe/server-db-query-builder

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "db-query-builder": {
      "command": "npx",
      "args": ["-y", "@gongrzhe/server-db-query-builder"]
    }
  }
}

Claude Code Configuration

claude mcp add db-query-builder -- npx -y @gongrzhe/server-db-query-builder

Tools

execute-query

Executes a SQL query against the connected PostgreSQL database and returns the results.

Input:

  • sql (string): The SQL query to execute

Output:

  • columns: Array of column definitions with name and data type
  • rows: Array of result rows
  • rowCount: Number of rows returned
  • executionTimeMs: Query execution time in milliseconds
  • wasTruncated: Boolean indicating if results were truncated to 1,000 rows
  • error (optional): Error message if query failed

list-tables

Lists all tables in the connected PostgreSQL database with column counts and estimated row counts.

Input: None

Output:

  • tables: Array of table objects with:
    • schemaName: Schema name (e.g., "public")
    • tableName: Table name
    • columnCount: Number of columns
    • estimatedRows: Approximate number of rows

describe-table

Returns the column definitions for a specific table, including data types, nullability, defaults, and primary key status.

Input:

  • tableName (string): Name of the table to describe
  • schemaName (string, optional): Schema name (defaults to "public")

Output:

  • schemaName: Schema name
  • tableName: Table name
  • columns: Array of column definitions with:
    • columnName: Column name
    • dataType: PostgreSQL data type
    • nullable: Boolean indicating if column allows NULL
    • defaultValue: Default value if set, otherwise null
    • isPrimaryKey: Boolean indicating if column is a primary key

Configuration

Set the DATABASE_URL environment variable to connect to a PostgreSQL database:

export DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
npx @gongrzhe/server-db-query-builder

The server will warn if DATABASE_URL is not set, but will start and fail gracefully when queries are attempted.

Example Prompt

Show me all tables in the database and run SELECT * FROM users LIMIT 10

License

MIT