MySQL MCP 服务器
一个为AI设计的只读MySQL MCP服务器,适用于Claude、Cursor及自定义智能体。默认安全,无需配置,可直接用于生产环境。
服务介绍
🐬 MySQL MCP Server
🌐 English
A read-only, AI-friendly MySQL MCP Server for Claude, Cursor, and custom agents.
✅ Safe by default
✅ Zero-config
✅ Production-ready
✅ Community-first
✨ Features
- 🔒 Read-only enforcement (no DROP / DELETE / UPDATE)
- 🤖 AI-optimized responses
- 🧩 Tool + Resource + Prompt
- 🚀 Stdio / SSE support
🚀 Quick Start
1.Install uv
curl -LsSf https://astral.sh/uv/install.sh| sh
Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1| iex"
2.Clone & Configure
git clone https://github.com/gordan-code/mysql_mcp.git
cd mysql_mcp
cp .env.example .env
Edit .env with your database credentials
3.Run with uv
uv sync
uv run mysql-mcp
MCP Client Configuration
{
"mcpServers": {
"mysql": {
"command": "uv",
"args": [
"--directory",
"/path/to/mysql_mcp",
"run",
"mysql-mcp"
]
}
}
}
On Windows, replace /path/to/mysql_mcp with your project path, for example D:\\path\\to\\mysql_mcp.
Option B: Traditional pip (Still supported)
git clone https://github.com/gordan-code/mysql_mcp.git
cd mysql_mcp
cp .env.example .env
Edit .env
pip install -e .
mysql-mcp
🧠 What AI Can Do
| Capability | Example |
|---|---|
| List tables | “Show me all tables” |
| Inspect schema | “Describe users table” |
| Run queries | “Top 10 users by created_at” |
| Analyze | “Why is this query slow?” |
🔐 Security
- No write operations
- Configurable row limits
- No raw SQL exposure to logs
- Local-first by default
📄 License
MIT
🌏 中文
一个为 AI Agent 设计的只读 MySQL MCP Server,适用于 Claude、Cursor 及自定义智能体。
✅ 默认安全
✅ 零配置
✅ 可用于生产
✅ 面向社区
✨ 功能特性
- 🔒 强制只读(禁止 DROP / DELETE / UPDATE)
- 🤖 AI 友好响应
- 🧩 Tool + Resource + Prompt
- 🚀 支持 Stdio / SSE
🚀 快速开始
1. 安装uv
curl -LsSf https://astral.sh/uv/install.sh| sh
Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1| iex"
2.克隆并配置环境
git clone https://github.com/gordan-code/mysql_mcp.git
cd mysql_mcp
cp .env.example .env
编辑 .env 文件填入数据库信息
3.使用 uv 启动服务
uv sync
uv run mysql-mcp
MCP 客户端配置
{
"mcpServers": {
"mysql": {
"command": "uv",
"args": [
"--directory",
"/path/to/mysql_mcp",
"run",
"mysql-mcp"
]
}
}
}
方案二:传统pip(仍然支持)
git clone https://github.com/gordan-code/mysql_mcp.git
cd mysql_mcp
cp .env.example .env
编辑.env文件
pip install -e .
python server.py
🧠 AI 能做什么
| 能力 | 示例 |
|---|---|
| 列出表 | “显示所有表” |
| 查看结构 | “描述 users 表” |
| 执行查询 | “按注册时间取前 10 名用户” |
| 分析性能 | “这条 SQL 为什么慢?” |
🔐 安全说明
- 不支持任何写操作
- 可配置返回行数限制
- 日志中不暴露原始 SQL
- 默认本地运行
📄 许可证
MIT