Back to MCP directory
publicPublicdnsLocal runtime

mysql-database-server-g7v

一个为MySQL数据库提供只读访问的MCP服务器,允许LLM检查数据库模式并安全执行查询。

article

README

🚀 mcp-server-mysql

这是一个适用于MySQL数据库的模型上下文协议(Model Context Protocol)服务器,允许大型语言模型(LLM)检查数据库模式并执行只读查询。

🚀 快速开始

mcp-server-mysql 是一个支持大型语言模型与 MySQL 数据库交互的服务器,可让模型安全地检查数据库模式和执行只读查询。

✨ 主要特性

  • 🔍 支持对 MySQL 数据库进行只读访问。
  • 📋 具备数据库模式检查功能。
  • 🛡️ 所有查询都在 READ ONLY 事务内安全执行。
  • 🐳 支持 Docker 部署。
  • 📦 可通过 NPM 包安装使用。

📦 安装指南

使用 Docker

# 构建 Docker 镜像
make docker

# 使用 Docker 运行
docker run -i --rm mcp/mysql mysql://host:port/dbname

通过 Smithery 安装

要自动安装 Claude Desktop 的 MySQL 数据库服务器,请使用 Smithery

npx -y @smithery/cli install @yuru-sha/mcp-server-mysql --client claude

💻 使用示例

与 Claude Desktop 一起使用

claude_desktop_config.json 中添加以下配置:

{
  "mcpServers": {
    "mysql": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp/mysql",
        "mysql://host:port/dbname"
      ]
    }
  }
}

⚠️ 重要提示

当在 macOS 上使用 Docker 时,如果 MySQL 服务器运行在主机网络上,请使用 host.docker.internal

连接 URL 格式

mysql://[user][:password]@host[:port]/database

请将 /database 替换为您的数据库名称。

🔧 开发指南

# 初始设置
make setup

# 构建项目
make build

# 格式化代码
make format

# 运行检查
make lint

📄 许可证

该项目在 MIT License 下发布。

🛡️ 安全说明

此服务器强制执行只读访问以保护您的数据库。所有查询均在 READ ONLY 事务内执行。

💡 使用建议

为了增强安全性,我们建议创建一个只读用户。

👥 贡献说明

欢迎贡献!请随意提交 Pull Request。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client