MySQL查询服务器 / MySQL Query Server
About
MySQL query server based on the MCP sse.Multi-level SQL risk control & injection protection Docker support for quick deployment
Explore
- 基于FastMCP框架,异步高性能
- 支持高并发的数据库连接池,参数灵活可调
- 支持SSE实时推送
- 丰富的MySQL元数据与结构查询API
- 自动事务管理与回滚
- 多级SQL风险控制与注入防护
- 数据库隔离安全:防止跨数据库访问,支持三级访问控制
- 敏感信息自动隐藏与自定义
- 灵活的环境变量配置
- 完善的日志与错误处理
- Docker支持,快速部署
- Built on FastMCP framework, high-performance async
- Connection pool for high concurrency, with flexible parameter tuning
- SSE real-time push support
- Rich MySQL metadata & schema query APIs
- Automatic transaction management & rollback
- Multi-level SQL risk control & injection protection
- Database Isolation Security: Prevents cross-database access with 3-level access control
- Automatic and customizable sensitive info masking
- Flexible environment variable configuration
- Robust logging & error handling
- Docker support for quick deployment
---
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MySQL查询服务器 / MySQL Query ServerCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
pip install -r requirements.txt
复制.env.example为.env,并根据实际情况修改。
Copy .env.example to .env and modify as needed.
| 变量名 / Variable | 说明 / Description | 默认值 / Default |
|--------------------------|------------------------------------------------------|------------------|
| HOST | 服务器监听地址 / Server listen address | 127.0.0.1 |
| PORT | 服务器监听端口 / Server listen port | 3000 |
| MYSQL_HOST | MySQL服务器地址 / MySQL server host | localhost |
| MYSQL_PORT | MySQL服务器端口 / MySQL server port | 3306 |
| MYSQL_USER | MySQL用户名 / MySQL username | root |
| MYSQL_PASSWORD | MySQL密码 / MySQL password | (空/empty) |
| MYSQL_DATABASE | 要连接的数据库名 / Database name | (空/empty) |
| DB_CONNECTION_TIMEOUT | 连接超时时间(秒) / Connection timeout (seconds) | 5 |
| DB_AUTH_PLUGIN | 认证插件类型 / Auth plugin type | mysql_native_password |
| DB_POOL_ENABLED | 是否启用连接池 / Enable connection pool (true/false) | true |
| DB_POOL_MIN_SIZE | 连接池最小连接数 / Pool min size | 5 |
| DB_POOL_MAX_SIZE | 连接池最大连接数 / Pool max size | 20 |
| DB_POOL_RECYCLE | 连接回收时间(秒) / Pool recycle time (seconds) | 300 |
| DB_POOL_MAX_LIFETIME | 连接最大存活时间(秒, 0=不限制) / Max lifetime (sec) | 0 |
| DB_POOL_ACQUIRE_TIMEOUT | 获取连接超时时间(秒) / Acquire timeout (seconds) | 10.0 |
| ENV_TYPE | 环境类型(development/production) / Env type | development |
| ALLOWED_RISK_LEVELS | 允许的风险等级(逗号分隔) / Allowed risk levels | LOW,MEDIUM |
| ALLOW_SENSITIVE_INFO | 允许查询敏感字段 / Allow sensitive info (true/false) | false |
| SENSITIVE_INFO_FIELDS | 自定义敏感字段模式(逗号分隔) / Custom sensitive fields | (空/empty) |
| MAX_SQL_LENGTH | 最大SQL语句长度 / Max SQL length | 5000 |
| BLOCKED_PATTERNS | 阻止的SQL模式(逗号分隔) / Blocked SQL patterns | (空/empty) |
| ENABLE_QUERY_CHECK | 启用查询安全检查 / Enable query check (true/false) | true |
| ENABLE_DATABASE_ISOLATION | 启用数据库隔离 / Enable database isolation (true/false) | false |
| DATABASE_ACCESS_LEVEL | 数据库访问级别 / Database access level (strict/restricted/permissive) | permissive |
| LOG_LEVEL | 日志级别(DEBUG/INFO/...) / Log level | DEBUG |
> 注/Note: 部分云MySQL需指定DB_AUTH_PLUGIN为mysql_native_password。
本系统完全支持 MySQL 8.0 的认证机制。MySQL 8.0 默认使用 caching_sha2_password 认证插件,提供更高的安全性。
This system fully supports MySQL 8.0 authentication mechanisms. MySQL 8.0 uses caching_sha2_password by default for enhanced security.
| 认证插件 / Plugin | 安全性 / Security | 兼容性 / Compatibility | 依赖要求 / Dependencies |
|------------------|-------------------|------------------------|------------------------|
| mysql_native_password | 中等 / Medium | 高 / High | 无 / None |
| caching_sha2_password | 高 / High | 中等 / Medium | cryptography |
生产环境 / Production(推荐 / Recommended):
DB_AUTH_PLUGIN=caching_sha2_password
开发环境 / Development(简化配置 / Simplified):
DB_AUTH_PLUGIN=mysql_native_password
使用 caching_sha2_password 时需要安装 cryptography 包(已包含在 requirements.txt 中):
When using caching_sha2_password, the cryptography package is required (already included in requirements.txt):
pip install cryptography
- 所有MySQL相关API工具均采用自动注册机制:
- 无需手动在主入口维护注册代码,新增/删除工具只需在src/tools/目录下实现register_xxx_tool(s)函数即可。
- 系统启动时自动扫描并注册,极大提升可维护性和扩展性。
- All MySQL-related API tools are registered automatically:
- No need to manually maintain registration code in the main entry. To add or remove a tool, simply implement a register_xxx_tool(s) function in the src/tools/ directory.
- The system scans and registers tools automatically at startup, greatly improving maintainability and extensibility.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mysql\u67e5\u8be2\u670d\u52a1\u5668 / mysql query server": {
"mysql-mcp-server-sse": {
"command": "docker",
"args": [
"pull",
"mangooer/mysql-mcp-server-sse:latest"
]
}
}
}
}
McpServers
{
"mysql-mcp-server-sse": {
"command": "docker",
"args": [
"pull",
"mangooer/mysql-mcp-server-sse:latest"
]
}
}
---
1. 项目简介 / Project Introduction
本项目是基于MCP框架的MySQL查询服务器,支持通过SSE协议进行实时数据库操作,具备完善的安全、日志、配置和敏感信息保护机制,适用于开发、测试和生产环境下的安全MySQL数据访问。
This project is a MySQL query server based on the MCP framework, supporting real-time database operations via SSE protocol. It features comprehensive security, logging, configuration, and sensitive information protection mechanisms, suitable for secure MySQL data access in development, testing, and production environments.
---
2. 主要特性 / Key Features
- 基于FastMCP框架,异步高性能
- 支持高并发的数据库连接池,参数灵活可调
- 支持SSE实时推送
- 丰富的MySQL元数据与结构查询API
- 自动事务管理与回滚
- 多级SQL风险控制与注入防护
- 数据库隔离安全:防止跨数据库访问,支持三级访问控制
- 敏感信息自动隐藏与自定义
- 灵活的环境变量配置
- 完善的日志与错误处理
- Docker支持,快速部署
- Built on FastMCP framework, high-performance async
- Connection pool for high concurrency, with flexible parameter tuning
- SSE real-time push support
- Rich MySQL metadata & schema query APIs
- Automatic transaction management & rollback
- Multi-level SQL risk control & injection protection
- Database Isolation Security: Prevents cross-database access with 3-level access control
- Automatic and customizable sensitive info masking
- Flexible environment variable configuration
- Robust logging & error handling
- Docker support for quick deployment
---
3. 快速开始 / Quick Start
Docker 方式 / Docker Method
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



