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

@kyruntime/mysql-mcp

v1.0.2

Published

MCP server for MySQL database access, enabling AI to query, inspect, and manage MySQL databases via natural language.

Readme

English | 中文 | 한국어 | 日本語

🐬 MySQL MCP Server

An MCP server that connects AI assistants (Cursor, Claude, etc.) to MySQL databases.

Simple setup, ready to use, fast and secure. Talk to your database in natural language.

1. ✨ Features

  • mysql_query — Execute read-only SELECT queries (max 1000 rows)
  • mysql_execute — Execute INSERT / UPDATE / DELETE with transaction support
  • mysql_list_tables — List all tables with engine, rows, size, collation
  • mysql_describe_table — Show table structure (columns, types, keys, comments)
  • mysql_show_indexes — Show all indexes on a table
  • mysql_show_create_table — Export full DDL (CREATE TABLE statement)
  • mysql_explain — Analyze query execution plans (TRADITIONAL / JSON / TREE)
  • mysql_list_databases — List all databases with sizes
  • mysql_database_info — Show version, size, charset, connections, uptime
  • mysql_show_processlist — Show active connections and running queries
  • mysql_use_database — Switch current database (USE db_name)
  • mysql_export_csv — Export table data or query results as CSV

2. 🔒 Security

  • SQL injection pattern detection (DROP, TRUNCATE, OUTFILE, LOAD_FILE, etc.)
  • Query length limit (4096 chars)
  • Table/database name sanitization (whitelist: alphanumeric + underscore)
  • Write operations disabled by default (opt-in via env vars)
  • Transactions with auto-rollback on error
  • Connection pooling (max 10)
  • Parameterized queries where applicable
  • MySQL 8.0+ caching_sha2_password natively supported

3. 🚀 Quick Start

3.1 npx (recommended)

🖥️ Cursor

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

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "npx",
      "args": ["-y", "@kyruntime/mysql-mcp"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASS": "your_password",
        "MYSQL_DB": "your_database",
        "MAX_ROWS": "1000",
        "ALLOW_INSERT_OPERATION": "false",
        "ALLOW_UPDATE_OPERATION": "false",
        "ALLOW_DELETE_OPERATION": "false"
      }
    }
  }
}

🤖 Codex CLI

Add to your ~/.codex/config.toml:

[mcp_servers.mysql-mcp]
command = "npx"
args = ["-y", "@kyruntime/mysql-mcp"]

[mcp_servers.mysql-mcp.env]
MYSQL_HOST = "127.0.0.1"
MYSQL_PORT = "3306"
MYSQL_USER = "root"
MYSQL_PASS = "your_password"
MYSQL_DB = "your_database"
MAX_ROWS = "1000"
ALLOW_INSERT_OPERATION = "false"
ALLOW_UPDATE_OPERATION = "false"
ALLOW_DELETE_OPERATION = "false"

3.2 Clone and run

git clone https://github.com/kyruntime/mysql-mcp.git
cd mysql-mcp
npm install

Then in mcp.json:

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "node",
      "args": ["/path/to/mysql-mcp/index.js"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASS": "your_password",
        "MYSQL_DB": "your_database",
        "MAX_ROWS": "1000",
        "ALLOW_INSERT_OPERATION": "false",
        "ALLOW_UPDATE_OPERATION": "false",
        "ALLOW_DELETE_OPERATION": "false"
      }
    }
  }
}

4. ⚙️ Environment Variables

| Variable | Default | Description | |----------|---------|-------------| | MYSQL_HOST | 127.0.0.1 | Database host | | MYSQL_PORT | 3306 | Database port | | MYSQL_USER | root | Database user | | MYSQL_PASS | (empty) | Database password | | MYSQL_DB | (empty) | Database name | | MAX_ROWS | 1000 | Maximum rows returned by SELECT | | ALLOW_INSERT_OPERATION | false | Enable INSERT | | ALLOW_UPDATE_OPERATION | false | Enable UPDATE | | ALLOW_DELETE_OPERATION | false | Enable DELETE |

5. 💬 Usage Examples

Ask your AI assistant:

"Show me all tables in the database"
"Describe the users table"
"What indexes does the orders table have?"
"Show me the CREATE TABLE for products"
"Find the top 10 orders by amount"
"Is this query using an index? SELECT * FROM orders WHERE user_id = 1"
"What databases are on this server?"
"How big is the database?"
"Are there any slow queries running?"

6. 📋 Requirements

  • Node.js >= 18
  • MySQL 5.7+ or MySQL 8.0+ (recommended)
  • MCP-compatible AI client (Cursor, Claude Desktop, etc.)

7. 🗺️ Roadmap

  • [x] Multi-database switching (USE db_name)
  • [x] Export table data to CSV
  • [ ] Slow query auto-analysis with optimization suggestions

8. 📄 License

MIT