mysql-mcp
by rlembo06
mysql-mcp
一个轻量级的 MCP 服务器,提供对 MySQL 数据库的安全、只读访问。
功能特性
多数据库 — 连接到多个 MySQL 实例,并可随时切换
只读 — 阻止写入操作(
INSERT、UPDATE、DELETE、DROP等)延迟连接 — 连接池在首次使用时创建,而非启动时创建
原生 MCP — 基于
@modelcontextprotocol/sdk构建,适用于任何 MCP 客户端
设置
创建一个包含数据库连接的 JSON 配置文件:
{
"my-db": {
"host": "db.example.com",
"port": 3306,
"user": "readonly",
"password": "secret",
"database": "mydb",
"environment": "production",
"ssl": false
}
}设置指向该文件的
MYSQL_DATABASES_CONFIG环境变量。运行服务器:
npx tsx index.ts工具
工具 | 描述 |
| 列出所有已配置的数据库及当前活跃的数据库 |
| 切换当前活跃的数据库连接 |
| 执行只读 SQL 查询 |
MCP 客户端配置
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["tsx", "/path/to/mysql-mcp/index.ts"],
"env": {
"MYSQL_DATABASES_CONFIG": "/path/to/databases.json"
}
}
}
}许可证
MIT
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rlembo06/mysql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server