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

mysql-ops-mcp

v1.0.0

Published

MySQL database MCP server: list databases/tables, inspect schema, run queries and CRUD with approval-gated delete/drop. Works with Claude Code, Cursor and other MCP clients.

Readme

MySQL Ops MCP

English | 简体中文

npm version License: MIT

MySQL 数据库 MCP Server。让 Claude Code / Cursor / Codex 等 AI 工具用自然语言操作你的 MySQL——浏览库表、查看结构、执行查询、增删改数据,其中删除类操作(DELETE / DROP)必须经过你明确批准才会执行。

功能特性

  • 🗄️ 结构浏览:列出数据库、列出表、查看表结构、获取表完整信息(索引、建表语句、统计)
  • 🔍 数据查询:对任意数据库执行 SELECT 查询
  • ✏️ 增改操作:建表、插入、更新——每个工具都有 SQL 语句校验
  • 🔐 删除需批准:delete_data 和 drop_table 每次都由客户端弹确认,不会静默执行
  • 🔌 零安装:npx 直接运行,全部通过环境变量配置

安装

需要 Node.js 18+。无需克隆或构建——npx 会在首次使用时自动拉取并运行已发布的 npm 包(见下方配置)。

如需从源码构建(例如二次开发):

git clone https://github.com/GT-dinuo/mysql-ops-mcp.git
cd mysql-ops-mcp
npm install
npm run build

构建产物输出到 dist/,入口为 dist/index.js。

配置

在需要使用本工具的项目中,创建(或追加).mcp.json:

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "mysql-ops-mcp"],
      "env": {
        "DB_HOST": "localhost",
        "DB_PORT": "3306",
        "DB_USER": "root",
        "DB_PASSWORD": "你的密码",
        "DB_DATABASE": "你的数据库名"
      }
    }
  }
}

如果你是从源码构建的,改为指向本地构建产物:"command": "node","args": ["/绝对路径/mysql-ops-mcp/dist/index.js"]。

环境变量

| 变量 | 必填 | 说明 | |------|------|------| | DB_HOST | 否 | MySQL 主机,默认 localhost | | DB_PORT | 否 | 端口,默认 3306 | | DB_USER | 否 | 用户名,默认 root | | DB_PASSWORD | 否 | 密码 | | DB_DATABASE | 否 | 默认数据库;不填则每次调用工具时传 database 参数 |

使用

配置完成后,在 AI 工具中直接用自然语言:

列出所有数据库
查看 users 表的结构
查询最近 10 条订单
获取 users 表的完整信息(索引和建表语句)
往 users 表插入一条测试数据
把刚才那条测试数据删掉   ← 客户端会先弹确认,你批准后才执行

删除类操作(delete_data、drop_table)每次都会经过 MCP 客户端的确认流程,不会发生不可逆的静默执行。

工具列表

| 工具 | 说明 | |------|------| | list_databases | 列出所有数据库 | | list_tables | 列出指定数据库的所有表 | | describe_table | 查看表字段和类型 | | get_table_info | 表完整信息:字段、索引、建表语句、统计 | | query | 执行 SELECT 查询 | | create_table | 建表(仅 CREATE TABLE) | | insert | 插入数据(仅 INSERT) | | update | 更新数据(仅 UPDATE) | | delete_data | 删除数据——需用户批准 | | drop_table | 删除表——需用户批准 | | execute_sql | 执行任意自定义 SQL |

安全说明

  1. 删除操作必须批准:delete_data、drop_table 由 MCP 客户端的工具调用确认把关,逐次批准或拒绝。
  2. 语句校验:每个写工具只接受自己的 SQL 动词(如 query 只接受 SELECT)。
  3. 最小权限账号:生产环境不要用 root 连接,建一个只允许访问目标数据库的专用账号。
  4. 凭据别入库:包含真实密码的 .env / .mcp.json 不要提交到代码仓库(.gitignore 已默认忽略 .env)。

测试连接

配置好 .env(从 env.example 复制)后,可以先验证连接再接入客户端:

cp env.example .env   # 填入真实凭据
npm run test-connection

开发

npm run dev    # watch 模式,改动自动编译
npm run build  # 构建到 dist/
npm start      # 直接运行已构建的 Server

许可证

MIT © 2026 mysql-ops-mcp