database MCP Server
这是一个功能强大且易用的MySQL数据库MCP(Model Context Protocol)服务器,让你的AI助手可以安全地进行完整的数据库操作,支持多数据库连接管理、增删改查、事务管理和智能回滚功能。
Discovered via smithery and last synced 4mo ago.
1. Install the package
npx @neigezhujiayi/mysql-mcp-server
2. Add to claude_desktop_config.json
{
"mcpServers": {
"neigezhujiayi-mysql-mcp-server": {
"command": "npx",
"args": [
"@neigezhujiayi/mysql-mcp-server"
]
}
}
}Config file location: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) / %APPDATA%\Claude\claude_desktop_config.json (Windows)
📄 样本数据 (前5行): [ { "id": 1, "name": "张三", "email": "[email protected]", "created_at": "2024-01-15T10:30:00.000Z" }, ... ] ``` #### 4. 智能事务管理 ``` 自动功能: - INSERT/UPDATE/DELETE操作自动开启事务 - 自动生成精确的回滚查询 - 记录每个操作的详细信息 - 支持选择性回滚到任意步骤 回滚查询示例: INSERT → DELETE FROM table WHERE id = ? UPDATE → UPDATE table SET col1=?, col2=? WHERE condition DELETE → INSERT INTO table (col1, col2) VALUES (?, ?) ``` ## ☁️ Smithery云部署 ### 🚀 快速部署到Smithery [Smithery](https://smithery.ai) 是专门为MCP服务器设计的云平台,可以一键部署您的MySQL MCP Server。 #### 🔧 部署步骤 1. **Fork项目到您的GitHub** ```bash https://github.com/guangxiangdebizi/MySQL_MCP ``` 2. **登录Smithery平台** - 访问 [Smithery.ai](https://smithery.ai) - 使用GitHub账号登录 3. **连接GitHub仓库** - 点击 "Deploy Server" - 选择您Fork的 `MySQL_MCP` 仓库 - 确认部署配置 4. **使用部署的服务器** ```json { "mcpServers": { "mysql-database": { "url": "https://server.smithery.ai/your-server-id/sse", "type": "sse" } } } ``` ## 🛠️ 安装教程 ### 📋 环境要求 - ✅ **Node.js 18+** - [下载地址](https://nodejs.org/) - ✅ **MySQL 5.7+ 或 8.0+** - 确保数据库服务正在运行 - ✅ **VSCode** - [下载地址](https://code.visualstudio.com/) - ✅ **Cline扩展** - 在VSCode扩展市场搜索"Cline"安装 ### 🚀 方法1: NPM安装(推荐) ```bash # 全局安装 npm install -g @neigezhujiayi/mysql-mcp-server # 验证安装 guangxiang-mysql-mcp --help ``` ### 🔧 方法2: 源码安装 ```bash # 下载项目 git clone https://github.com/guangxiangdebizi/MySQL_MCP.git cd MySQL_MCP # 2. 安装依赖 npm install # 3. 构建项目 npm run build # 4. 测试安装 npm test ``` ## ⚙️ 配置方法 ### 📌 方法1: NPM包配置(推荐) 使用npm全局安装后,在Cline设置中添加: ```json { "mcpServers": { "mysql-database": { "command": "guangxiang-mysql-mcp", "env": {} } } } ``` ### 📌 方法2: 本地项目配置 如果使用npx或本地安装: ```json { "mcpServers": { "mysql-database": { "command": "npx", "args": ["@neigezhujiayi/mysql-mcp-server"], "env": {} } } } ``` ### 📌 方法3: 源码配置 从源码安装后,在Cline设置中添加: ```json { "mcpServers": { "mysql-database": { "command": "node", "args": ["C:/path/to/my-awesome-mcp/dist/index.js"], "env": {} } } } ``` ### 📌 方法4: HTTP/SSE模式配置 ```json { "mcpServers": { "mysql-database": { "url": "http://localhost:3101/sse", "type": "sse" } } } ``` 启动服务器: ```bash npm run start-gateway ``` ## 🎮 使用指南 ### 🚀 基础连接 #### 单数据库连接(3.0保持兼容) ``` 请帮我连接到MySQL数据库: - 主机: localhost - 端口: 3306 - 用户名: root - 密码: your_password - 数据库: test_db ``` #### 🆕 多数据库连接(3.0新功能) ``` # 连接第一个数据库(自动成为活跃连接) 请连接到生产数据库: - 主机: prod.mysql.com - 数据库: production_db - 连接ID: prod # 连接第二个数据库 请连接到测试数据库: - 主机: test.mysql.com - 数据库: test_db - 连接ID: test # 查看所有连接 请列出所有数据库连接 # 切换活跃连接 请切换到test连接 # 指定连接执行操作 请在prod连接上查询用户表 ``` ### 📊 查看数据库结构 ``` # 查看所有表概览 请显示数据库中的所有表 # 查看特定表详情 请描述users表的结构 ``` ### 🔄 执行CRUD操作 ```sql -- 查询数据 SELECT * FROM users WHERE age > 25 LIMIT 10 -- 插入数据 INSERT INTO users (name, email, age) VALUES ('张三', '[email protected]', 28) -- 更新数据 UPDATE users SET age = 29 WHERE email = '[email protected]' -- 删除数据 DELETE FROM users WHERE id = 123 ``` ### 🛡️ 事务安全操作 ``` # 查看事务历史 请显示当前事务的操作历史 # 回滚到特定步骤 请回滚到第3步操作之前 # 完全回滚 请完全回滚所有未提交的操作 # 提交事务 请提交当前事务 ``` ## 🔄 事务管理 ### 自动事务管理 - **自动开启**: INSERT/UPDATE/DELETE操作自动开启事务 - **智能记录**: 记录每个操作的详细信息和回滚查询 - **精确回滚**: 支持回滚到任意操作步骤 ### 事务历史示例 ``` 📋 事务历史记录 🔹 步骤 1 (2024-01-15 10:30:15) 类型: INSERT
完全回滚
断开数据库连接
显示所有表及结构概览
显示事务历史
提交事务
回滚到指定步骤
回滚事务
PRI
连接MySQL数据库
YES
显示表详细结构和样本数据
开始事务
**万能SQL执行工具**
varchar(255)
NULL
Use this skill when designing database schemas, optimizing queries, creating indexes, planning migrations, or choosing between database technologies. Triggers on schema design, normalization, indexing strategies, query optimization, EXPLAIN plans, migrations, partitioning, replication, connection pooling, and any task requiring database architecture or performance decisions.
Database Workflow Bundle workflow skill. Use this skill when the user needs Database development and operations workflow covering SQL, NoSQL, database design, migrations, optimization, and data engineering and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.
database-admin workflow skill. Use this skill when the user needs Expert database administrator specializing in modern cloud databases, automation, and reliability engineering and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.
AppDeploy Skill workflow skill. Use this skill when the user needs Deploy web apps with backend APIs, database, and file storage. Use when the user asks to deploy or publish a website or web app and wants a public URL. Uses HTTP API via curl and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.
open-source agentic AI data assistant for the next generation of AI + Data products.
MCP Toolbox for Databases is an open source MCP server for databases.
Data Agent Ready Warehouse : One for Analytics, Search, AI, Python Sandbox. — rebuilt from scratch. Unified architecture on your S3.
Second Brain is an agentic framework that acts as an operating system, using local file intelligence, workflow automation, and LLMs to complete tasks and communicate over multiple modalities and messaging platforms.
Learn how to use the database-engineering Claude skill. Complete guide with installation instructions and examples.
Learn how to use the azure-postgres-ts-v2 Claude skill. Complete guide with installation instructions and examples.
Learn how to use the database-architect-v3 Claude skill. Complete guide with installation instructions and examples.