
enemyrr/mcp-mysql-server 是从 https://github.com/enemyrr/mcp-mysql-server. 导入的 MCP 服务器候选
概览
enemyrr/mcp-mysql-server 是从 https://github.com/enemyrr/mcp-mysql-server. 导入的 MCP 服务器候选
概述(AI 翻译)
一个模型上下文协议服务器,提供MySQL数据库操作。该服务器使AI模型能够通过标准化接口与MySQL数据库交互。
光标IDE安装与设置
通过Smithery安装
通过Smithery自动安装MySQL数据库服务器for Claude Desktop:
手动安装
-
克隆并构建项目:
-
在光标IDE设置中添加服务器:
- 打开命令面板(Cmd/Ctrl + Shift + P)
- 搜索“MCP: 添加服务器”
- 填写字段:
- 姓名:
mysql - 类型:
command - 指令:
node /absolute/path/to/mcp-mysql-server/build/index.js
注意:用你克隆并构建项目的实际路径替换
/absolute/path/to/。
数据库配置
你可以用三种方式配置数据库连接:
-
.env数据库URL(推荐):
-
.env中的单个参数:
-
通过工具直接连接:
可用工具
1.connect_db
通过URL、工作区路径或直接凭证连接MySQL数据库。
2.查询
使用可选的预备语句参数执行SELECT查询。
3.执行
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
@enemyrr/mcp-mysql-server
A Model Context Protocol server that provides MySQL database operations. This server enables AI models to interact with MySQL databases through a standardized interface.
Installation & Setup for Cursor IDE
Installing via Smithery
To install MySQL Database Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @enemyrr/mcp-mysql-server --client claude
Installing Manually
- Clone and build the project:
git clone https://github.com/enemyrr/mcp-mysql-server.git
cd mcp-mysql-server
npm install
npm run build
- Add the server in Cursor IDE settings:
- Open Command Palette (Cmd/Ctrl + Shift + P)
- Search for “MCP: Add Server”
- Fill in the fields:
- Name:
mysql - Type:
command - Command:
node /absolute/path/to/mcp-mysql-server/build/index.js
- Name:
Note: Replace
/absolute/path/to/with the actual path where you cloned and built the project.
Database Configuration
You can configure the database connection in three ways:
- Database URL in .env (Recommended):
DATABASE_URL=mysql://user:password@host:3306/database
- Individual Parameters in .env:
DB_HOST=localhost
DB_USER=your_user
DB_PASSWORD=your_password
DB_DATABASE=your_database
- Direct Connection via Tool:
use_mcp_tool({
server_name: "mysql",
tool_name: "connect_db",
arguments: {
url: "mysql://user:password@host:3306/database"
// OR
workspace: "/path/to/your/project" // Will use project's .env
// OR
host: "localhost",
user: "your_user",
password: "your_password",
database: "your_database"
}
});
Available Tools
1. connect_db
Connect to MySQL database using URL, workspace path, or direct credentials.
2. query
Execute SELECT queries with optional prepared statement parameters.
use_mcp_tool({
server_name: "mysql",
tool_name: "query",
arguments: {
sql: "SELECT * FROM users WHERE id = ?",
params: [1]
}
});
3. execute
Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.
use_mcp_tool({
server_name: "mysql",
tool_name: "execute",
arguments: {
sql: "INSERT INTO users (name, email) VALUES (?, ?)",
params: ["John Doe", "[email protected]"]
}
});
4. list_tables
List all tables in the connected database.
use_mcp_tool({
server_name: "mysql",
tool_name: "list_tables"
});
5. describe_table
Get the structure of a specific table.
use_mcp_tool({
server_name: "mysql",
安装
npx -y @smithery/cli install @enemyrr/mcp-mysql-server --client claude