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

@kohlarnhin/mcp-server-mysql

v1.1.0

Published

Model Context Protocol server for MySQL

Downloads

5

Readme

MCP Server MySQL

Model Context Protocol server for MySQL databases.

简介

MCP Server MySQL 是一个用于连接 MySQL 数据库的 Model Context Protocol 服务器。它允许 AI 助手和应用程序通过标准的 MCP 协议接口安全地查询 MySQL 数据库。

功能

  • 提供标准的 MCP 接口,用于执行 MySQL 查询
  • 支持 INSERT, UPDATE 和 READ 操作
  • 内置连接池管理
  • 安全的错误处理和日志记录
  • 使用官方 MCP SDK,兼容 Cursor 和其他 MCP 客户端

安装

全局安装(推荐)

npm install -g @kohlarnhin/mcp-server-mysql

本地安装

npm install @kohlarnhin/mcp-server-mysql

使用方法

直接运行

通过环境变量配置数据库连接信息:

MYSQL_HOST=127.0.0.1 MYSQL_PORT=3306 MYSQL_USER=root MYSQL_PASS=yourpassword MYSQL_DB=yourdb mcp-server-mysql

在 MCP 配置中使用

~/.cursor/mcp.json 中添加以下配置:

{
  "mcpServers": {
    "MySQL": {
      "command": "npx",
      "args": [
        "mcprunner",
        "MYSQL_HOST=127.0.0.1",
        "MYSQL_PORT=3306",
        "MYSQL_USER=root",
        "MYSQL_PASS=yourpassword",
        "MYSQL_DB=yourdb",
        "ALLOW_INSERT_OPERATION=true",
        "ALLOW_UPDATE_OPERATION=true",
        "ALLOW_DELETE_OPERATION=false",
        "--",
        "npx",
        "-y",
        "@kohlarnhin/mcp-server-mysql"
      ],
      "type": "stdio"
    }
  }
}

配置选项

通过环境变量进行配置:

| 环境变量 | 描述 | 默认值 | |----------|------|--------| | MYSQL_HOST | MySQL 服务器主机名 | 127.0.0.1 | | MYSQL_PORT | MySQL 服务器端口 | 3306 | | MYSQL_USER | MySQL 用户名 | root | | MYSQL_PASS | MySQL 密码 | 123456 | | MYSQL_DB | MySQL 数据库名 | oc-dev | | ALLOW_INSERT_OPERATION | 是否允许 INSERT 操作 | true | | ALLOW_UPDATE_OPERATION | 是否允许 UPDATE 操作 | true | | ALLOW_DELETE_OPERATION | 是否允许 DELETE 操作 | false |

工具列表

服务提供以下工具:

  • mcp_MySQL_mysql_query: 执行 SQL 查询并返回结果

示例

在支持 MCP 的应用程序中:

-- 查询示例
SELECT * FROM users LIMIT 10;

-- 插入示例 (如果允许)
INSERT INTO logs (message, level) VALUES ('测试消息', 'info');

版本历史

  • 1.1.0 - 稳定版本发布,修复了文档问题,完善了配置说明
  • 1.0.x - 初始开发版本(已撤回)

注意事项

  1. 安全考虑:默认情况下,DELETE 操作是禁用的。如需启用,请将 ALLOW_DELETE_OPERATION 设置为 true。

  2. 环境变量优先级:命令行传递的环境变量优先级高于系统环境变量。

许可证

MIT