
Mysql
io.github.marcelo-ochoa由 GitHub 帳號 marcelo-ochoa 發布v1.0.7更新於 Oct 24, 2026
An MCP server for MySQL databases.
概覽
本機 MCP 伺服器,讓助理以唯讀方式存取 MySQL 資料庫:執行與解讀查詢、檢視資料表統計與結構,並產生效能報告。
- 可以做什麼
- 在唯讀交易中執行唯讀 SQL 查詢
- 解讀查詢執行計畫並以 JSON 回傳
- 取得指定資料表的資料表、索引與欄位統計
- 產生類似 Oracle AWR 的效能報告,含 InnoDB 指標、熱門查詢與最佳化建議
- 讀取每張資料表的 schema 資源,包含欄位名稱與資料型別
- 在執行中重新連線到其他 MySQL 主機、資料庫與憑證
- 適用情境
- 適合讓助理探索既有 MySQL 資料庫、用 SQL 回答問題、調校慢查詢,或在不授予寫入權限的前提下產生效能概況。
- 執行需求
- 以 stdio 在本機執行,可透過 npx(需 Node.js)或已發布的 Docker 映像啟動。需要可連線的 MySQL 伺服器,以及包含主機、連接埠與資料庫的連線字串,可作為選用的啟動參數或透過 mysql-connect 工具提供。憑證來自 MYSQL_USER 與 MYSQL_PASSWORD 環境變數或連線工具。啟用 performance_schema 時 mysql-awr 報告最完整。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mysql,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
MySQL Database
A Model Context Protocol server that provides read-only access to MySQL databases. This server enables LLMs to inspect database schemas, execute and explain read-only queries, and analyze performance metrics.
Components
Tools
-
mysql-query
- Execute read-only SQL queries against the connected MySQL database
- Input:
sql(string): The SQL query to execute - All queries are executed within a READ ONLY transaction
-
mysql-explain
- Explain plan SQL queries against the connected MySQL database
- Input:
sql(string): The SQL query to explain - Returns execution plan in JSON format
-
mysql-stats
- Get statistics for a given table in the current connected database
- Input:
name(string): The table name - Returns comprehensive table, index, and column statistics
-
mysql-connect
- Reconnect using new credentials
- Input:
connectionString(string): MySQL connect string (e.g., host.docker.internal:3306/mydb) - Input:
user(string): Username (e.g., root) - Input:
password(string): Password
Example: mysql-connect host.docker.internal:3306/hr root my_2025
- mysql-awr
- Generate a MySQL performance report similar to Oracle AWR
- Includes database statistics, InnoDB metrics, top queries (requires performance_schema), table/index statistics, connection info, and optimization recommendations
- No input required
Resources
The server provides schema information for each table in the MySQL database:
- Table Schemas (
mysql://<database>/<table>/schema)- JSON schema information for each table
- Includes column names and data types
- Automatically discovered from MySQL database metadata
Configuration
The MySQL server uses environment variables or the mysql-connect tool for secure credential management:
MYSQL_USER: MySQL username (optional if usingmysql-connect)MYSQL_PASSWORD: MySQL password (optional if usingmysql-connect)
Connection String
The connection string should contain only the host, port, and database information (without embedded credentials). Providing it as a command-line argument is optional. If omitted at startup, you must use the mysql-connect tool to establish a connection before using other functionality.
Supported connection string formats:
mysql://host:port/dbnamehost:port/dbname
Usage with Claude Desktop
To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your claude_desktop_config.json:
Docker
- When running Docker on macOS, use
host.docker.internalif the MySQL server is running on the host network (e.g., localhost) - Credentials are passed via environment variables
MYSQL_USERandMYSQL_PASSWORD
Note: You can still provide the connection string as a final argument if you want to connect automatically on startup: "args": [..., "mochoa/mcp-mysql", "host.docker.internal:3306/mydb"].
NPX
Replace /mydb with your database name.
Note: Replace the following placeholders with your actual values:
myuserandmypasswordwith your MySQL credentialslocalhost:3306with your MySQL server host and portmydbwith your database name
Usage with VS Code
For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open User Settings (JSON).
Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.
Note that the
mcpkey is not needed in the.vscode/mcp.jsonfile.
Docker
Note: When using Docker and connecting to a MySQL server on your host machine, use host.docker.internal instead of localhost in the connection URL.
Note: You can add an input for mysql_url and append it to args if you want to connect on startup.
NPX
Usage with Antigravity Code Editor
Put this in ~/.gemini/antigravity/mcp_config.json
Performance Schema
For optimal performance monitoring with the mysql-awr tool, ensure that the Performance Schema is enabled in your MySQL configuration:
The Performance Schema provides detailed query statistics and performance metrics. If it's not enabled, the AWR report will still generate but with limited query-level statistics.
Building
Docker:
NPM:
Demo Prompts
Sample prompts to try with the MySQL MCP server:
- Connect to host.docker.internal:3306/mydb using root as user and password123 as password using mysql mcp server
- Query all tables in the current database
- Get stats for the
userstable - Explain the execution plan for: SELECT * FROM users WHERE email = '[email protected]'
- Generate a performance report using mysql-awr
- Based on the AWR report, what optimizations would you recommend?
Demos
See Demos for usage examples with Claude Desktop, Docker AI, Gemini CLI, and Antigravity Code Editor.
MySQL AWR in action
See MySQL AWR in action for an example of a performance report generated by the mysql-awr tool, highlighting specific optimization opportunities.
Change Log
See Change Log for the history of changes.
Sources
As usual, the code of this extension is at GitHub, feel free to suggest changes and make contributions.
📜 License
This project is licensed under the Apache License, Version 2.0 for new contributions, with existing code under MIT - see the LICENSE file for details.
來源:src/mysql/README.md,提交 bd2ce8f
工具
0版本歷史
1- v1.0.7最新Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。