- Explore MCP Servers
- mysql-mcp
Mysql Mcp
What is Mysql Mcp
mysql-mcp is a readonly MCP server that allows safe access to a MySQL database through secure read-only query interfaces.
Use cases
Use cases include generating reports from a MySQL database, providing data to machine learning models without risking data integrity, and securely exposing database information through APIs.
How to use
To use mysql-mcp, clone the repository, install the package, and configure the ‘config.json’ file with your MySQL database credentials and settings. Then, run the main script using the specified command.
Key features
Key features include support for readonly queries, connection pooling, automatic result limit, parameterized queries, formatted output, and built-in security checks to prevent non-readonly operations.
Where to use
mysql-mcp can be used in applications that require safe and controlled access to MySQL databases, such as data analysis, reporting tools, and machine learning models.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mysql Mcp
mysql-mcp is a readonly MCP server that allows safe access to a MySQL database through secure read-only query interfaces.
Use cases
Use cases include generating reports from a MySQL database, providing data to machine learning models without risking data integrity, and securely exposing database information through APIs.
How to use
To use mysql-mcp, clone the repository, install the package, and configure the ‘config.json’ file with your MySQL database credentials and settings. Then, run the main script using the specified command.
Key features
Key features include support for readonly queries, connection pooling, automatic result limit, parameterized queries, formatted output, and built-in security checks to prevent non-readonly operations.
Where to use
mysql-mcp can be used in applications that require safe and controlled access to MySQL databases, such as data analysis, reporting tools, and machine learning models.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
MySQL Readonly MCP Server
这是一个基于MCP(Model Context Protocol)的MySQL只读查询服务器,它允许通过安全的只读查询接口访问MySQL数据库。
功能特点
- 支持MySQL数据库的只读查询操作
- 使用连接池管理数据库连接
- 自动限制查询结果数量
- 支持参数化查询
- 提供格式化的查询结果输出
- 内置安全检查,防止非只读操作
环境要求
- Python 3.10+
- MySQL 5.7+
- aiomysql
安装
git clone https://github.com/the-nine-nation/mysql-mcp.git
pip install -e .
使用方法
以cursor为例,将如下字典放入config.json: 其中 sys.executable为python虚拟环境的执行文件,通常名字为python,conda或uv下皆可以
mysql_mcp_py为main.py文件的绝对路径
请注意: 1.MYSQL_RESOURCE_DESC_FILE是一个说明,可以将数据库中一些信息放入其中,例如什么表是做什么用的,能够提升模型理解能力.
2.MYSQL_ENABLED默认可以不用填
安全特性
- 只允许只读操作
- 防止多语句执行
- 自动限制查询结果数量
- 使用参数化查询防止SQL注入
注意事项
- 确保数据库用户只有只读权限
- 资源描述文件是必需的,用于定义可用的查询接口
- 查询结果默认限制为20行,可通过环境变量调整
贡献
欢迎提交Issue和Pull Request。
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










