MySQL_MCP
这是一个功能强大且易用的MySQL数据库MCP(Model Context Protocol)服务器,让你的AI助手可以安全地进行完整的数据库操作,支持多数据库连接管理、增删改查、事务管理和智能回滚功能。
claude mcp add --transport http guangxiangdebizi-mysql_mcp http://localhost:3001/mcp
How to use
MySQL MCP Server provides a StreamableHTTP MCP interface to securely manage and operate multiple MySQL databases through AI-assisted commands. It supports dynamic connection management, multi-database switching, and full CRUD SQL operations. Tools exposed include add_connection, list_connections, select_database, remove_connection for managing database connections, and execute_query, show_tables, describe_table, show_databases for performing SQL operations and inspecting database structures. If you configure credentials via the header-based setup, your database credentials are kept out of reach from the AI, while the server handles the actual connections. You can also let AI dynamically add connections without preconfiguring credentials, enabling flexible, on-demand access to databases.
To use the server, ensure it is running and connect your MCP client (Claude Desktop, Cursor, etc.) to the /mcp endpoint. Use the provided tools to add and manage connections, then execute queries against the active database. The system supports multiple databases concurrently, so you can switch contexts with select_database and continue querying across different databases as needed.
How to install
Prerequisites:
- Node.js 18+
- npm or pnpm
- MySQL 5.7+ / 8.0+
Installation steps:
# 1. Clone the repository
git clone https://github.com/guangxiangdebizi/MySQL_MCP.git
cd MySQL_MCP
# 2. Install dependencies
npm install
# 3. Build the project (if applicable)
npm run build
# 4. Start the MCP server
npm start
Notes:
- Ensure a running MySQL instance(s) matching your intended configuration.
- If you modify environment variables, restart the server to apply changes.
Additional notes
Tips and common considerations:
- For security, prefer Header pre-configuration to avoid exposing credentials to AI. If using AI dynamic connections, ensure proper access controls on the MySQL side.
- The server supports multiple databases concurrently and includes automatic reconnection and keep-alive behaviors in newer versions.
- If you encounter port conflicts, adjust the PORT in .env or the server configuration and restart.
- Refer to the troubleshooting section in the README for guidance on module resolution, SSE timeouts, and port issues.
- When using dynamic connections, understand that credentials may be stored only in the MCP server or in the client configuration depending on the mode you choose.
Related MCP Servers
context7
Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
mcp-apple-notes
Talk with your notes in Claude. RAG over your Apple Notes using Model Context Protocol.
mcp -langfuse
Model Context Protocol (MCP) Server for Langfuse Prompt Management. This server allows you to access and manage your Langfuse prompts through the Model Context Protocol.
mem0
✨ mem0 MCP Server: A memory system using mem0 for AI applications with model context protocl (MCP) integration. Enables long-term memory for AI agents as a drop-in MCP server.
mcp -chart-minio
mcp-server-chart私有化部署方案
cco
Real-time audit and approval system for Claude Code tool calls.