# dave-wind
## 基本信息
- Slug: `dave-wind-mysql-mcp-server`
- Source: modelscope
- Publisher: @dave-wind/mysql-mcp-server
- Categories: databases / developer-tools / code-execution
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@dave-wind/mysql-mcp-server
## 简介
暂无描述。
## MCP Server 详情

# @davewind/mysql-mcp-server

一个提供对MySQL数据库只读访问的Model Context Protocol服务器。该服务器使LLM能够检查数据库模式并执行只读查询。

### 主要特性
1. 只读数据库访问：通过SQL验证和只读事务强制执行只读操作  
2. 模式发现：自动识别并公开数据库表结构  
3. SQL查询执行：提供一个查询工具，接受并执行SELECT语句  
4. Model Context Protocol合规性：实现MCP规范，以便与兼容的LLM无缝集成  
5. 简单配置：设置简单，所需配置最少  

### 工具

- **query**
  - 对连接的数据库执行只读SQL查询
  - 输入: `sql` (字符串): 要执行的SQL查询
  - 所有查询都在只读事务中执行

### 资源

服务器为数据库中的每个表提供模式信息：

- **表模式** (`mysql://user:password@localhost:3306/database`)
  - 每个表的JSON模式信息
  - 包括列名和数据类型
  - 从数据库元数据中自动发现

### 安装
bash
npm install @davewind/mysql-mcp-server -g


## 配置
MCP设置配置文件：

> 推荐使用

json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@davewind/mysql-mcp-server", "mysql://user:password@localhost:port/database"],
    }
  }
}


### 测试
> 替换 `mysql://user:password@localhost:port/` 并运行 `npm run inspector`
js
  "scripts": {
    "inspector": "npx @modelcontextprotocol/inspector@0.10.2 build/index.js mysql://user:password@localhost:port/database
  }


### 环境

js
node v18 +


### 系统架构
> MySQL MCP Server作为LLM和MySQL数据库之间的中介，根据Model Context Protocol处理请求。
<p>
  <img src="./docs/High-Level Architecture.png" alt=""/>
</p>

### 组件交互
<p>
  <img src="./docs/component-Interaction.png" alt=""/>
</p>

### 组件交互
<p>
  <img src="./docs/component-Interaction.png" alt=""/>
</p>

### 安全模型
> MySQL MCP Server实现了一个严格的安全模型，以确保数据库访问是只读的。
<p>
  <img src="./docs/Security Model.png" alt=""/>
</p>

安全措施包括：

1. SQL查询验证，仅允许SELECT语句
2. 在只读事务中执行所有查询
3. 不支持数据修改操作（INSERT, UPDATE, DELETE等）
4. 不支持数据库模式修改（CREATE, ALTER, DROP等）

### 与LLM的集成
> MySQL MCP Server设计为与任何支持Model Context Protocol的LLM系统一起工作。它通过遵循MCP规范的stdio上的JSON-RPC进行通信。
<p>
  <img src="./docs/Integration with LLMs.png" alt=""/>
</p>

## 许可证

MIT

