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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nala-db-mcp

v1.0.6

Published

A MCP for querying databases using Bun SQL

Readme

nala-db-mcp

A Model Context Protocol (MCP) server for querying databases. Supports SQLite, PostgreSQL, MySQL, and Microsoft SQL Server with read-only access.

Features

  • Multiple Database Support: SQLite, PostgreSQL, MySQL, and MS SQL Server
  • Read-Only Operations: Safe query execution with DML operation blocking
  • MCP Integration: Exposes database querying via the Model Context Protocol
  • CSV Output: Query results returned in CSV format
  • Environment-Based Configuration: Connection via DATABASE_URL environment variable

Usage

You can use this MCP server with any MCP client, such as Cursor or Claude Desktop.

Configuration in Cursor

Add the following configuration to your MCP settings file (typically in your Cursor settings or .cursorrules):

{
  "mcpServers": {
    "nala-db-mcp": {
      "command": "bunx nala-db-mcp",
      "env": {
        "DATABASE_URL": "mssql://sa:test@localhost:1433/test"
      }
    }
  }
}

Replace the DATABASE_URL value with your database connection string:

  • SQLite: sqlite://path/to/database.db
  • PostgreSQL: postgres://user:password@localhost:5432/dbname
  • MySQL: mysql://user:password@localhost:3306/dbname
  • MS SQL Server: mssql://user:password@localhost:1433/dbname

Once configured, the MCP server will be available in your Cursor environment, and you can use the run-query tool to execute read-only SQL queries.

Usage (Local)

For local development or custom integrations, you can install and run the server directly.

Installation

bun install

Configuration

Set your database connection string in the DATABASE_URL environment variable:

# SQLite
export DATABASE_URL="sqlite://path/to/database.db"

# PostgreSQL
export DATABASE_URL="postgres://user:password@localhost:5432/dbname"

# MySQL
export DATABASE_URL="mysql://user:password@localhost:3306/dbname"

# MS SQL Server
export DATABASE_URL="mssql://user:password@localhost:1433/dbname"

Running the Server

bun run start

The MCP server will start and listen on stdio for MCP client connections.

Available Tools

run-query

Executes a read-only SQL query against the configured database.

Input:

  • query (string): SQL query to execute. Must be a SELECT query (no INSERT, UPDATE, DELETE, etc.)

Output:

  • CSV-formatted query results

Example:

SELECT * FROM users WHERE active = 1

Development

Running Tests

# Run all tests
bun test

# Run specific test file
bun test test/db.test.ts

Linting and Formatting

bun run check

This runs Biome with auto-fix enabled for code formatting and linting.

Project Structure

  • index.ts - MCP server setup and tool registration
  • src/db.ts - Database connection logic and utilities
  • test/db.test.ts - Test suite

Security

  • Anything isn't bulletproof, so create a new user with READONLY permissions it's recommended
  • All database connections are read-only
  • DML operations (INSERT, UPDATE, DELETE, etc.) are blocked via regex validation
  • Connection strings support encrypted connections (MS SQL Server uses Encrypt=true)

License

MIT


Built with Bun and the Model Context Protocol SDK