Connects to MySQL databases and executes SELECT queries for read-only data access, with support for querying tables, filtering data, and performing aggregations.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP MySQL Servershow me the top 10 customers by total purchase amount"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP MySQL Server
一个用于连接和查询MySQL数据库的MCP (Model Context Protocol) 服务器。
功能特性
通过 SSE (Server-Sent Events) 提供 HTTP 接口
连接MySQL数据库
执行 SELECT 查询(只读访问)
安全的只读模式,不支持 INSERT/UPDATE/DELETE 操作
安装
使用 uv(推荐)
使用 pip
使用方法
启动服务器
配置参数
环境变量:
MYSQL_HOST- MySQL 服务器地址(默认: localhost)MYSQL_PORT- MySQL 端口(默认: 3306)MYSQL_USER- 数据库用户名(默认: root)MYSQL_PASSWORD- 数据库密码(默认: 空)MYSQL_DATABASE- 数据库名称(默认: 空)QUERY_TIMEOUT- 查询超时时间,单位秒(默认: 30)MCP_HOST- MCP 服务器地址(默认: 0.0.0.0)MCP_PORT- MCP 服务器端口(默认: 8000)
在 Claude Desktop 中配置
在 Claude Desktop 配置文件中添加以下配置:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
可用工具
query - 执行 SELECT 查询
sql: 要执行的 SELECT 语句(仅支持 SELECT 查询,保证只读访问)
示例
连接后,你可以:
"查询 users 表的所有数据:SELECT * FROM users"
"查询特定条件:SELECT name, email FROM users WHERE id > 10"
"统计数据:SELECT COUNT(*) FROM orders WHERE status='completed'"
注意: 为了数据安全,本服务器只支持 SELECT 查询,不支持 INSERT、UPDATE、DELETE 等写操作。
安全注意事项
请妥善保管数据库凭据
建议使用只读账户
不要在公共仓库中提交包含密码的配置文件