1. Conduid
  2. Data
  3. Mysql MCP Server
MCP server · Data

Mysql MCP Server

MCP MySQL Server 是一个基于 @modelcontextprotocol/sdk 的 MySQL 工具服务,支持 SQL 查询、表结构获取、连接检测等功能,适用于 AI 代理、自动化工具等场景。

Unclaimed Apache-2.0 last commit a year ago data
54Fair

Scored 5 months ago · breakdown

About Mysql MCP Server

Mysql MCP Server is an MCP server published by TickHaiJun in the Data category: mCP MySQL Server 是一个基于 @modelcontextprotocol/sdk 的 MySQL 工具服务,支持 SQL 查询、表结构获取、连接检测等功能,适用于 AI 代理、自动化工具等场景。.

The repository has 32 stars and 13 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.

Install

From source
git clone https://github.com/TickHaiJun/mysql-mcp-server

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Ask AI

✦

Ask AI about Mysql MCP Server

Powered by Claude · Grounded in docs

I know everything about Mysql MCP Server. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

Static checks derived from the repository yesterday. Heuristics on the source, not an audit.

  • ✓README presentThe repository ships documentation.
  • ✓License declaredUsable under a stated license.
  • !Tests presentNo tests found. Behaviour changes may go unnoticed between versions.
  • ✓Dependencies pinnedA lockfile pins dependency versions.
  • ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
  • !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.

README

MCP MySQL Server

项目简介

MCP MySQL Server 是一个基于 @modelcontextprotocol/sdk 的 MySQL 工具服务,支持 SQL 查询、表结构获取、连接检测等功能,适用于 AI 代理、自动化工具等场景。

主要功能

  • 执行 SQL 查询(SELECT、INSERT、UPDATE、DELETE)
  • 获取数据库表结构信息
  • 检测数据库连接状态
  • SQL 语句和参数安全校验
  • 优雅的服务启动与关闭

架构说明

  • 入口文件:src/index.js 启动和管理 MCP 服务器实例
  • 服务实现:src/server.js 实现 MCP Server,注册工具、处理请求
  • 数据库管理:src/database.js 管理 MySQL 连接池、执行 SQL、获取表结构
  • 配置管理:src/config.js 支持 .env 环境变量和默认配置
  • 安全校验:src/validators.js 校验 SQL 语句和参数,防止危险操作和注入

安装与使用

  1. 克隆项目
    git clone https://github.com/yourname/mcp-mysql-server.git
    cd mcp-mysql-server
    
  2. 安装依赖
    npm install
    
  3. 配置数据库连接(可选,支持 .env 文件)
    DB_HOST=localhost
    DB_PORT=3306
    DB_USER=root
    DB_PASSWORD=yourpassword
    DB_NAME=yourdatabase
    
  4. 启动服务
    node src/index.js
    

配置说明

  • 支持通过环境变量或 .env 文件配置数据库和服务参数
  • 主要配置项见 src/config.js

主要实现细节

  • 使用 mysql2/promise 实现高效的连接池和异步 SQL 执行
  • 所有 SQL 语句和参数均经过安全校验,防止危险操作和 SQL 注入
  • MCP Server 支持三大工具:
    • execute_sql:执行 SQL 查询
    • get_tables_info:获取所有表及字段结构
    • get_connection_status:检测数据库连接
  • 优雅处理进程信号,支持平滑关闭

安全性说明

  • 禁止 DROP/TRUNCATE/ALTER 等危险操作
  • 检查常见 SQL 注入模式
  • 限制参数数量,防止滥用
  • 禁用多语句执行

在 Cursor 中 验证 开发的 MCP Server 是否能运行

Cursor 添加 MCP Server

通过 Cursor Settings -> MCP Add new global MCP server,可以将 MCP 服务添加为全局可用。这意味着你配置的 MCP 服务将在所有项目中生效。

也可以只针对 项目级别 添加

在项目的 .cursor目录下,新建一个 mcp.json文件进行配置,这样的设置只会对特定项目生效。

mcp server 的格式是如何呢

配置 server 基本格式规范

{
  "mcpServers": {
    "<server-name>": {
      "command": "<启动命令>",
      "args": ["<参数1>", "<参数2>", ...],
      "env": {
        "<环境变量名1>": "<值1>",
        "<环境变量名2>": "<值2>",
        ...
      },
      "transport": "<传输协议>",
      "port": <端口号>,
      "host": "<主机地址>"
    }
  }
}

查询数据库表和字段信息

查看当前数据库是否连接

查询表里数据

看到这里,是不是觉得很神奇?我们用自然语言描述需求,AI助手自动生成并执行SQL,然后分析结果给出结论。

依赖

贡献方式

欢迎提交 Issue 和 PR 参与贡献!

许可证

ISC License

README fetched from the repository yesterday. The original is authoritative.

Questions

About Mysql MCP Server

How do I install Mysql MCP Server?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is Mysql MCP Server safe to use with an AI agent?

Its trust score is 54 out of 100 (fair). It passes 4 of the 6 static security checks run so far; the failures are listed above. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Mysql MCP Server still maintained?

The last commit was a year ago and 1 open issues. That's long enough that you should check whether the maintainer is responding to issues before depending on it.