mysql
在 cursor 工具中通过 mysql mcp 服务读取本地 mysql 库,方便通过 AI 来编程开发
claude mcp add --transport stdio lichuanrong7-mysql-mcp-server node server.js \ --env PORT="3100" \ --env DB_HOST="你的数据库地址" \ --env DB_NAME="你的数据库名称" \ --env DB_PORT="3306" \ --env DB_USER="你的数据库用户名" \ --env DB_PASSWORD="你的数据库密码"
How to use
This MCP server implements a MySQL data access layer for Cursor AI using the MCP protocol. It exposes endpoints that allow the AI to execute SQL queries, retrieve table schemas, and inspect or manipulate data via standardized MCP requests. You can access the MCP manifest at /manifest.json and interact with the API through endpoints such as /api/mysql/query for SQL execution and /api/mysql/schema for table structures. To integrate with Cursor, add the service URL http://<your-host>:3100/manifest.json in the MCP extension manager, activate the service, and begin issuing natural-language commands like querying a table, inspecting a schema, or running data operations. The server handles CORS and responds with a consistent API shape suitable for MCP tooling.
How to install
Prerequisites:
- Node.js 14.x or newer
- Git (optional for cloning)
- Access to a MySQL database
Install locally:
- Clone the repository
git clone https://github.com/lichuanrong7/mysql-mcp-server.git
cd mysql-mcp-server
- Install dependencies
npm install
- Configure environment variables Create a .env file with database and server settings, for example:
# 服务器配置
PORT=3100
# 数据库配置
DB_HOST=your-database-host
DB_PORT=3306
DB_USER=your-db-username
DB_PASSWORD=your-db-password
DB_NAME=your-db-name
- Run the server
# 开发模式
npm run dev
# 生产模式
npm start
可选:若使用 Docker,构建镜像并通过 Compose 启动:
docker build -t mysql-mcp-server .
docker-compose up -d
Additional notes
Tips and caveats:
- Ensure your MySQL user has appropriate privileges for the queries you plan to run.
- The server exposes /manifest.json and /openapi.yaml for MCP tooling; keep these accessible to Cursor.
- If the service cannot start due to port conflicts, verify that PORT 3100 (or configured port) is free.
- For production deployments, consider securing DB credentials (e.g., using a secrets manager) and enabling TLS as needed.
- Common issues: invalid DB credentials, network/firewall blocks to the database, or missing environment variables. Check logs under the project logs (e.g., logs/mysql-mcp-*.log) for details.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.