mysql-mcp
Feature-rich MCP server for MySQL and MariaDB with multi-connection support. Connect many instances at once — query schemas, run scripts, test stored procedures with sandbox rollback.
README
MySQL MCP
Feature-rich MCP server for MySQL and MariaDB with multi-connection support. Connect many instances at once — query schemas, run scripts, test stored procedures with sandbox rollback.
- npm:
@raviraj87/mysql-mcp - Runs locally via stdio (any MCP-compatible client)
- Supports MySQL 5.7+, 8.x, MariaDB 10.x–11.x, InnoDB/Aria/MyISAM
Quick start
Connect to the MySQL server — no database required in the URI. Use list_databases, then pass database on each tool call (or set default_database in config).
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@raviraj87/mysql-mcp"],
"env": {
"MYSQL_URI": "mysql://user:pass@localhost:3306"
}
}
}
}
Typical workflow
list_databases— discover databases on the server- Pick a database (agent asks, or you pass it explicitly)
list_tables,query, etc. with"database": "myapp"
Optional: set default_database in YAML so tools skip the database param for that connection.
Multiple connections — copy config.example.yaml → ~/.mysql-mcp.yaml:
default_connection: local
connections:
local:
uri_env: MYSQL_URI
default_database: myapp # optional — omit to choose per tool call
staging:
uri_env: MYSQL_URI_STAGING
prod:
uri_env: MYSQL_URI_PROD
read_only: true
Set URIs in MCP env. Every tool accepts optional connection: "staging".
Extra connections via env:
MYSQL_EXTRA_CONNECTIONS=staging:MYSQL_URI_STAGING,prod:MYSQL_URI_PROD
Server vs database
| Level | Config | Example |
|---|---|---|
| Server | MYSQL_URI host only |
mysql://user:pass@host:3306 |
| Default DB | default_database in YAML (optional) |
myapp |
| Per tool | database param |
{ "database": "nsm", "table": "users" } |
Tools like ping, list_databases, and server_info work without a database. Schema/query tools require database or default_database.
Tools (~55)
Connection: list_connections, ping, server_info, connect
Metadata: list_databases, list_tables, describe_table, show_create_table, list_indexes, list_foreign_keys, table_stats, list_views, list_triggers, list_events
Read: query, query_one, explain, count, sample_rows, distinct_values, export_query
Write: execute, execute_batch, insert_rows, delete_rows, truncate_table
Routines: list_procedures, list_functions, describe_procedure, show_create_procedure, show_create_function, call_procedure, call_function, test_procedure, create_procedure, drop_procedure, routine_overview
Scripts: split_script, validate_script, run_script, test_script, load_script_file, run_script_with_vars
Admin: execute_ddl, create_database, drop_database, create_index, drop_index, show_grants
Diagnostics: processlist, status, variables, innodb_status, replication_status, kill_query, health_check
Composite: explore_table, database_overview, analyze_query, compare_tables, index_health
Stored procedures & scripts
Test a procedure (rollback by default):
{
"tool": "test_procedure",
"arguments": {
"database": "myapp",
"procedure": "sp_create_order",
"params": { "p_customer_id": 42, "p_amount": 99.99 },
"setup_sql": ["INSERT INTO customers (id) VALUES (42)"]
}
}
Test a SQL script:
{
"tool": "test_script",
"arguments": {
"database": "myapp",
"script": "DELIMITER $$\nCREATE PROCEDURE ...\nEND$$\nDELIMITER ;\nCALL my_proc(1);"
}
}
split_script handles DELIMITER changes. Sandbox rollback requires InnoDB/Aria unless compatibility.allow_myisam_sandbox: true.
Safety
- Global or per-connection
read_only max_rowsauto-LIMIT on SELECTquery_timeout_msvia sessionmax_execution_time/max_statement_timeexplain_check— reject full table scansconfirmation_required_tools— destructive ops needconfirmed: truetest_sandbox_default: true— scripts/SP tests roll back unless committedallowed_databasesper connection- Blocks
INTO OUTFILE,LOAD DATA,SHUTDOWN
Install from source
cd mysql-mcp
npm install
npm run build
{
"command": "node",
"args": ["/path/to/mysql-mcp/dist/index.js"]
}
License
Copyright © 2026 Ravi Raj. Licensed under the MIT License.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。