Enables comprehensive MySQL database management through AI assistants, including database and table operations, data querying, insertion, updates, deletion, and CSV/JSON import/export functionality with built-in SQL injection protection
🚀 MySQL MCP Server
🎯 让 AI 助手轻松管理 MySQL 数据库的强大 MCP 工具
基于 Model Context Protocol (MCP) 的 MySQL 数据库管理工具,让您能够通过 AI 助手(如 Claude)执行各种数据库操作,无需手动编写 SQL 语句。
✨ 功能特性
🔗 连接管理
- ✅ 灵活的数据库连接配置
- ✅ 支持环境变量和参数配置
- ✅ 连接状态检查和管理
- ✅ 安全的连接池管理
🗄️ 数据库操作
- ✅ 列出所有数据库
- ✅ 创建数据库(支持字符集和排序规则)
- ✅ 删除数据库
- ✅ 数据库信息查询
📊 表操作
- ✅ 列出指定数据库的所有表
- ✅ 查看表结构和字段详情
- ✅ 创建表(通过 SQL 语句)
- ✅ 删除表
- ✅ 表信息统计
📝 数据操作
- ✅ 执行 SQL 查询(支持参数化查询)
- ✅ 插入数据(支持批量插入)
- ✅ 更新数据
- ✅ 删除数据
- ✅ 数据导出到 CSV/JSON 文件
- ✅ 从 CSV/JSON 文件导入数据
🛡️ 安全特性
- ✅ SQL 注入防护
- ✅ 危险操作检测
- ✅ 参数化查询支持
- ✅ 权限控制建议
📦 安装
方式一:直接使用(推荐)
在您的 MCP 客户端配置中直接使用 @latest
标签:
方式二:全局安装
方式三:项目安装
🚀 快速开始
1. 配置环境变量
创建 .env
文件:
2. 在 Claude Desktop 中配置
编辑 Claude Desktop 配置文件:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
3. 在其他 MCP 客户端中配置
对于支持 MCP 协议的其他客户端:
💡 使用示例
配置完成后,您可以在 AI 助手中使用自然语言进行数据库操作:
🔗 连接数据库
📋 查看数据库列表
🆕 创建数据库
🔍 查看表结构
📊 执行查询
➕ 插入数据
📤 导出数据
📥 导入数据
🛠️ API 工具列表
工具名称 | 功能描述 |
---|---|
mysql_connect | 连接到 MySQL 数据库 |
mysql_disconnect | 断开数据库连接 |
mysql_list_databases | 列出所有数据库 |
mysql_create_database | 创建数据库 |
mysql_drop_database | 删除数据库 |
mysql_list_tables | 列出表 |
mysql_describe_table | 查看表结构 |
mysql_create_table | 创建表 |
mysql_drop_table | 删除表 |
mysql_query | 执行 SQL 查询 |
mysql_insert | 插入数据 |
mysql_update | 更新数据 |
mysql_delete | 删除数据 |
mysql_export_data | 导出数据 |
mysql_import_data | 导入数据 |
🔧 配置选项
环境变量
变量名 | 描述 | 默认值 | 必需 |
---|---|---|---|
MYSQL_HOST | MySQL 服务器地址 | localhost | ✅ |
MYSQL_PORT | MySQL 端口号 | 3306 | ❌ |
MYSQL_USER | 用户名 | root | ✅ |
MYSQL_PASSWORD | 密码 | - | ✅ |
MYSQL_DATABASE | 默认数据库 | - | ❌ |
MYSQL_CONNECTION_LIMIT | 连接池大小 | 10 | ❌ |
MYSQL_TIMEOUT | 连接超时时间(ms) | 60000 | ❌ |
🛡️ 安全注意事项
- 🔐 密码保护: 确保
.env
文件不被提交到版本控制系统 - 🚫 SQL 注入防护: 工具内置基础 SQL 安全检查,建议使用参数化查询
- 👤 权限控制: 建议为 MCP 服务器创建专用 MySQL 用户并限制权限
- 🌐 网络安全: 生产环境中确保 MySQL 服务器网络访问安全
- 📝 操作审计: 重要操作前会进行安全提示
🤝 贡献
欢迎提交 Issue 和 Pull Request!
- Fork 本项目
- 创建特性分支 (
git checkout -b feature/AmazingFeature
) - 提交更改 (
git commit -m 'Add some AmazingFeature'
) - 推送到分支 (
git push origin feature/AmazingFeature
) - 开启 Pull Request
📄 许可证
本项目基于 MIT License 开源协议。
📞 联系方式
如有问题或建议,欢迎联系:
微信: pickstar_loveXX
⭐ 如果这个项目对您有帮助,请给个 Star 支持一下!
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
Enables AI assistants to manage MySQL databases through natural language commands. Supports database operations, table management, data queries, and import/export functionality with built-in security features.
Related MCP Servers
- AsecurityFlicenseAqualityEnables AI models to perform MySQL database operations through a standardized interface, supporting secure connections, query execution, and comprehensive schema management.Last updated -72027
- AsecurityAlicenseAqualityConnect and interact with MySQL databases seamlessly. Execute SQL queries, manage database connections, and retrieve data directly through AI assistants. Enhance your AI capabilities with structured access to your MySQL data.Last updated -9117MIT License
- -securityFlicense-qualityEnables secure interaction with MySQL databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.Last updated -
- -securityAlicense-qualityProvides secure access to MySQL databases for AI assistants, enabling safe SQL queries, table information retrieval, and data insertion with built-in security protections.Last updated -2692MIT License