mysql-mcp
mysql-mcp
一个轻量级的 MCP 服务器,提供对 MySQL 数据库的安全、只读访问。
功能特性
多数据库 — 连接到多个 MySQL 实例,并可随时切换
只读 — 阻止写入操作(
INSERT、UPDATE、DELETE、DROP等)延迟连接 — 连接池在首次使用时创建,而非启动时创建
原生 MCP — 基于
@modelcontextprotocol/sdk构建,适用于任何 MCP 客户端
Related MCP server: mcp-database
设置
创建一个包含数据库连接的 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 deployed
Maintenance
Related MCP Connectors
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Read-only MCP server for The Quiet Protocol's engines, benchmarks, proof, and business data.
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides read-only access to MySQL databases.4317 npm72MIT
- AlicenseAqualityCmaintenanceRead-only MySQL/MariaDB MCP server for running SELECT queries safely, with automatic read-only enforcement and query limits.36 npmMIT
- AlicenseNot gradedqualityDmaintenanceA readonly MCP server for MySQL databases that ensures safety by whitelisting only SELECT, SHOW, DESCRIBE, and EXPLAIN statements, with table blacklist support and configurable limits.MIT
- AlicenseNot gradedqualityDmaintenanceA secure, read-only MySQL database proxy using MCP protocol, enabling SQL queries and table inspections via HTTP.10 npm1MIT