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

@dhank77/mcp-universal-db

v1.0.5

Published

MCP universal database library

Readme

MCP Universal Database Server

A Model Context Protocol (MCP) server that provides universal database connectivity and operations. This server supports multiple database types and offers a comprehensive set of tools for database management.

Features

This MCP server provides the following tools for database operations:

🔌 Connection Management

  • connection: Manage database connections with support for connect, disconnect, and status operations
  • Supports lazy connection initialization
  • Multi-database type support (MySQL, PostgreSQL, SQLite, etc.)

📊 Data Operations

Query Operations

  • query: Execute SELECT queries on the database
    • Support for parameterized queries
    • Safe SQL execution with prepared statements
    • Flexible parameter binding

CRUD Operations

  • create: Insert new records into tables
    • Key-value pair data insertion
    • Confirmation required for safety
  • update: Update existing records in tables
    • Conditional updates with WHERE clauses
    • Key-value pair data updates
    • Confirmation required for safety
  • delete: Delete records from tables
    • Conditional deletion with WHERE clauses
    • Confirmation required for safety

Schema Operations

  • readSchema: Read database schema information
    • Get schema for specific tables or all tables
    • Comprehensive table structure information

Configuration

The server supports multiple configuration formats through environment variables. Create a .env file based on the provided .env.example:

Format 1: DSN Direct

DATABASE_URL=mysql://user:pass@localhost:3306/mydb
SUPABASE_DB_URL=postgres://user:[email protected]:5432/postgres

Format 2: Laravel Style

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=laravel_user
DB_PASSWORD=secret

Format 3: WordPress Style

DB_NAME=wordpress
DB_USER=wp_user
DB_PASS=wp_password
DB_HOST=localhost
DB_PORT=3306

Format 4: Multi Database with Prefix

DB1_CONNECTION=mysql
DB1_HOST=localhost
DB1_PORT=3306
DB1_DATABASE=app1_db
DB1_USERNAME=app1_user
DB1_PASSWORD=app1_pass

DB2_CONNECTION=postgres
DB2_HOST=localhost
DB2_PORT=5432
DB2_DATABASE=app2_db
DB2_USERNAME=app2_user
DB2_PASSWORD=app2_pass

Format 5: Docker Style

MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DATABASE=docker_mysql
MYSQL_USER=mysql_user
MYSQL_PASSWORD=mysql_pass

POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=docker_postgres
POSTGRES_USER=postgres_user
POSTGRES_PASSWORD=postgres_pass

Format 6: Django Style

DJANGO_DB_ENGINE=django.db.backends.postgresql
DJANGO_DB_HOST=localhost
DJANGO_DB_PORT=5432
DJANGO_DB_NAME=django_db
DJANGO_DB_USER=django_user
DJANGO_DB_PASSWORD=django_pass

MCP Client Configuration

To connect to this MCP server from an MCP-compatible client, add the following configuration:

{
  "mcpServers": {
    "dbmcp": {
      "command": "npx",
      "args": [
        "-y",
        "@dhank77/mcp-universal-db",
        "--transport",
        "stdio"
      ],
      "env": {
        "DOTENV_CONFIG_PATH": "./.env"
      }
    }
  }
}

Make sure your .env file is in the same directory as your MCP client configuration.

Installation

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build
  4. Configure your database connection in .env file
  5. Start the server:
    npm start

Usage

This server is designed to work with MCP-compatible clients. The server communicates via stdio transport and provides all database operations through the MCP protocol.

Example Tool Calls

Check Connection Status

{
  "tool": "connection",
  "params": {
    "action": "status"
  }
}

Execute a Query

{
  "tool": "query",
  "params": {
    "sql": "SELECT * FROM users WHERE age > ?",
    "params": [18]
  }
}

Insert a Record

{
  "tool": "create",
  "params": {
    "table": "users",
    "data": {
      "name": "John Doe",
      "email": "[email protected]",
      "age": 25
    },
    "confirm": true
  }
}

Update Records

{
  "tool": "update",
  "params": {
    "table": "users",
    "data": {
      "age": 26
    },
    "where": {
      "id": 1
    },
    "confirm": true
  }
}

Delete Records

{
  "tool": "delete",
  "params": {
    "table": "users",
    "where": {
      "id": 1
    },
    "confirm": true
  }
}

Read Schema

{
  "tool": "readSchema",
  "params": {
    "table": "users"
  }
}

Safety Features

  • Confirmation Required: All destructive operations (create, update, delete) require explicit confirmation
  • Parameterized Queries: Support for prepared statements to prevent SQL injection
  • Connection Management: Proper connection lifecycle management
  • Error Handling: Comprehensive error handling and reporting

Supported Databases

  • MySQL
  • PostgreSQL
  • SQLite
  • And other databases supported by the underlying connection libraries

Development

Build

npm run build

Test

npm test

Development Mode

npm run dev

License

MIT License