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

query-mcp

v1.0.3

Published

A Model Context Protocol (MCP) server that provides read-only access to SQL databases, with enhanced schema discovery, business definitions, and natural language SQL generation. This server enables LLMs and tools to inspect database schemas, execute read-

Downloads

12

Readme

Query MCP

A Model Context Protocol (MCP) server that provides read-only access to SQL databases, with enhanced schema discovery, business definitions, and natural language SQL generation. This server enables LLMs and tools to inspect database schemas, execute read-only queries, and interact with business definitions.

Components

Tools

  • list_tables

    • List all tables in the connected database.
    • Output: Array of table names.
  • describe_table

    • Describe columns, relationships, and sample data for a given table.
    • Input: table (string): Table name.
    • Output: Schema, relationships, samples, and column stats.
  • run_query

    • Execute a read-only SQL SELECT query.
    • Input: sql (string): SQL query.
    • Output: Query result rows.
  • generate_sql

    • Generate a SQL query from a natural language question, using schema and definitions.
    • Input: question (string), context (optional).
    • Output: SQL query.
  • get_definition

    • Retrieve the business definition for a term.
    • Input: term (string).
    • Output: Definition text.
  • store_definition

    • Store or update a business definition for a term.
    • Input: term (string), value (string).
    • Output: Success status.
  • refresh_metadata

    • Refresh cached database metadata (schemas, samples, stats).
    • Input: table (optional string).
    • Output: Success message.
  • get_all_definitions

    • List all stored business definitions.
    • Output: Array of definitions.

Resources

The server provides schema and business definition resources:

  • Table Metadata (table-metadata://all, table-metadata://{table})

    • JSON schema information for each table, including columns, types, and relationships.
    • Automatically discovered from database metadata.
  • Definitions (definitions://all)

    • All stored business definitions as JSON.

Configuration

Usage with Claude Desktop

To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your claude_desktop_config.json:

Docker

  • When running Docker on macOS, use host.docker.internal if the server is running on the host network (e.g., localhost).
  • Username/password can be added to the PostgreSQL URL: postgresql://user:password@host:port/db-name
{
    "mcpServers": {
        "query-mcp": {
            "command": "docker",
            "args": ["run", "-i", "--rm", "mcp/query-mcp", "postgresql://host.docker.internal:5432/mydb"]
        }
    }
}

NPX

{
    "mcpServers": {
        "query-mcp": {
            "command": "npx",
            "args": ["-y", "query-mcp", "postgresql://localhost/mydb"]
        }
    }
}

Replace /mydb with your database name.

Usage with VS Code

For quick installation, use one of the one-click install buttons below...

Install with NPX in VS Code

Install with Docker in VS Code

For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open User Settings (JSON).

Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.

Note that the mcp key is not needed in the .vscode/mcp.json file.

Docker

Note: When using Docker and connecting to a PostgreSQL server on your host machine, use host.docker.internal instead of localhost in the connection URL.

{
    "mcp": {
        "inputs": [
            {
                "type": "promptString",
                "id": "pg_url",
                "description": "PostgreSQL URL (e.g. postgresql://user:[email protected]:5432/mydb)"
            }
        ],
        "servers": {
            "query-mcp": {
                "command": "docker",
                "args": ["run", "-i", "--rm", "mcp/query-mcp", "${input:pg_url}"]
            }
        }
    }
}

NPX

{
    "mcp": {
        "inputs": [
            {
                "type": "promptString",
                "id": "pg_url",
                "description": "PostgreSQL URL (e.g. postgresql://user:pass@localhost:5432/mydb)"
            }
        ],
        "servers": {
            "query-mcp": {
                "command": "npx",
                "args": ["-y", "query-mcp", "${input:pg_url}"]
            }
        }
    }
}

Building

Docker:

docker build -t mcp/query-mcp -f src/postgres/Dockerfile .

Local Development & Demo

Local Dockerfile

A Dockerfile is provided for building and running the MCP server locally. You can build the image with:

docker build -t mcp/query-mcp -f src/postgres/Dockerfile .

(Update the path above if your Dockerfile is located elsewhere.)

Seed Script

The scripts/seed.ts script can be used to populate your database with sample data for testing and demos.

npm run seed:script

These scripts are useful for quickly setting up and showcasing the capabilities of the Query MCP server.

License

This MCP server is licensed under the ISC License. You are free to use, modify, and distribute the software, subject to the terms and conditions of the ISC License. For more details, please see the LICENSE file in the project repository.