
MySQL
STDIOMySQL database connection and query service for Cursor AI
MySQL database connection and query service for Cursor AI
为Cursor提供MySQL数据库连接与查询能力的MCP服务
MySQL MCP服务是一个基于Node.js开发的API服务,为Cursor AI提供直接访问MySQL数据库的能力。该服务遵循MCP(Model Control Platform)协议规范,使AI能够通过标准化接口执行SQL查询、获取表结构信息,以及执行数据操作。
git clone https://github.com/lichuanrong7/mysql-mcp-server.git cd mysql-mcp-server
npm install
创建或编辑 .env
文件,添加以下配置:
# 服务器配置
PORT=3100
# 数据库配置
DB_HOST=你的数据库地址
DB_PORT=3306
DB_USER=你的数据库用户名
DB_PASSWORD=你的数据库密码
DB_NAME=你的数据库名称
# 开发模式启动 npm run dev # 生产模式启动 npm start
项目提供了便捷的启动和停止脚本:
启动服务:
./start.sh
停止服务:
./stop.sh
docker build -t mysql-mcp-server .
docker-compose up -d
/manifest.json
/openapi.yaml
/api/mysql/query
/api/mysql/schema
/api/mysql/ddl
执行SQL查询:
curl -X POST http://localhost:3100/api/mysql/query \ -H "Content-Type: application/json" \ -d '{"query":"SELECT * FROM users LIMIT 10"}'
获取表结构:
curl -X GET http://localhost:3100/api/mysql/schema?table=users
http://localhost:3100/manifest.json
MCP服务激活后,你可以在Cursor中使用自然语言操作数据库:
服务无法启动
lsof -i :3100
./logs/mysql-mcp-*.log
数据库连接失败
API请求失败
curl http://localhost:3100/manifest.json
本项目使用 MIT 许可证 - 详细信息请查看 LICENSE 文件
欢迎提交问题和贡献代码。请确保遵循以下步骤:
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)