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

@edjl/mysql-mcp

v1.0.8

Published

MySQL read-only tools for MCP (Model Context Protocol)

Readme

MySQL MCP

A Model Context Protocol (MCP) server that provides tools for interacting with MySQL databases.

Features

This MCP server provides the following tools:

Read Operations

  • mysql_databases - List all databases
  • mysql_tables - List all tables in a database
  • mysql_columns - List columns of a table
  • mysql_describe - Show detailed table structure
  • mysql_query - Execute SELECT queries (read-only)
  • mysql_count - Count rows with optional filtering

Write Operations

  • mysql_update - Update rows with safety checks
  • mysql_delete - Delete rows with safety checks

Installation

  1. Clone this repository
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build

Configuration

Option 1: Environment Variables in mcp.json (Recommended)

Add the server to your ~/.cursor/mcp.json:

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "node",
      "args": [
        "/path/to/mysql-mcp/build/index.js"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "default_database"
      }
    }
  }
}

Option 2: Per-Tool Configuration

Each tool accepts connection parameters that override the environment variables:

{
  host: "localhost",      // Optional, defaults to MYSQL_HOST or 'localhost'
  port: 3306,            // Optional, defaults to MYSQL_PORT or 3306
  user: "root",          // Optional, defaults to MYSQL_USER or 'root'
  password: "password",  // Optional, defaults to MYSQL_PASSWORD
  database: "mydb"       // Required for most tools
}

Option 3: System Environment Variables

You can also set system environment variables:

export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=your_password
export MYSQL_DATABASE=default_db

Usage Examples

List all databases

mysql_databases

List tables in a database

mysql_tables database: "myapp"

Query data

mysql_query database: "myapp", query: "SELECT * FROM users WHERE active = 1", limit: 10

Update with dry run

mysql_update database: "myapp", table: "users", set: {status: "inactive"}, where: "last_login < '2023-01-01'", dryRun: true

Delete with safety

mysql_delete database: "myapp", table: "logs", where: "created_at < '2023-01-01'", limit: 1000, dryRun: true

Safety Features

  1. Required WHERE clause: Both UPDATE and DELETE operations require a WHERE clause to prevent accidental operations on all rows
  2. Dry run mode: Preview changes before executing with dryRun: true
  3. Limit support: Restrict the number of affected rows
  4. Query validation: The query tool validates and prevents non-SELECT operations
  5. Connection timeout: 10-second timeout on database connections

Development

Project Structure

mysql-mcp/
├── src/
│   ├── index.ts           # Main server file
│   ├── types.ts           # TypeScript types
│   ├── database/
│   │   └── connection.ts  # Database connection handling
│   └── tools/            # Individual tool implementations
│       ├── databases.ts
│       ├── tables.ts
│       ├── columns.ts
│       ├── describe.ts
│       ├── query.ts
│       ├── count.ts
│       ├── update.ts
│       └── delete.ts
├── package.json
├── tsconfig.json
└── README.md

Adding New Tools

  1. Create a new file in src/tools/
  2. Implement the ToolDefinition interface
  3. Export as default
  4. The tool will be automatically loaded with the mysql_ prefix

License

MIT