Mcp Mysql Connector

io.github.daedalus由 GitHub 帳號 daedalus 發布v0.1.1更新於 Oct 25, 2026

MCP server exposing MySQL database functionalities as tools

已驗證STDIO僅桌面資料庫開發者工具

概覽

AI 產生的概覽

一個本機 MCP 伺服器,讓 AI 助理能連線 MySQL,並執行查詢、管理資料庫、資料表、索引與使用者。

可以做什麼
連線、中斷 MySQL,檢查連線狀態,提交或回復交易。執行原始 SQL 查詢並回傳結果。列出、建立、刪除與檢查資料庫和資料表,檢視資料表結構。檢視、建立與刪除欄位和索引。建立與刪除 MySQL 使用者,授予與撤銷權限,檢視權限。讀取伺服器狀態,並以資源形式提供資料庫與資料表中繼資料。
適用情境
適合需要讓助理直接操作 MySQL 執行個體的場合:瀏覽資料表結構、執行臨時查詢,或在開發與維運時建立資料庫、資料表與使用者。
執行需求
以 Python 套件形式在本機執行(Python 3.11+)。需要可連線的 MySQL 伺服器與憑證,可透過 connect 工具或 MYSQL_HOST、MYSQL_PORT、MYSQL_USER、MYSQL_PASSWORD、MYSQL_DATABASE 環境變數提供。僅限桌面端,不支援網頁執行。
安裝前請注意
助理可以執行任意 SQL,建立或刪除資料庫、資料表、索引與使用者,並變更權限,因此可能造成破壞性操作。資料庫憑證會傳給此伺服器,並可能存放在環境變數中。建議使用最小權限的 MySQL 帳號而非 root。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Mysql Connector,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

mcp-mysql-connector

MCP server exposing MySQL database functionalities as tools for LLM agents.

mcp-name: io.github.daedalus/mcp-mysql-connector

[PyPI] [Python] [Coverage] [Ruff]

Overview

mcp-mysql-connector is a Model Context Protocol (MCP) server that provides MySQL database operations as tools for LLM agents. It allows AI assistants to interact with MySQL databases through a standardized protocol, enabling:

  • Database and table management
  • Query execution
  • User authentication and privilege management
  • Schema introspection
  • Transaction control

Install

bash
pip install mcp-mysql-connector

Quick Start

Running the Server

bash
# Run with stdio transport (default)mcp-mysql-connector
# Or run programmaticallypython -c "from mcp_mysql import mcp; mcp.run()"

Configuration

Connect to MySQL using the connect tool:

json
{  "host": "localhost",  "port": 3306,  "user": "root",  "password": "your_password",  "database": "your_database"}

MCP Tools

Connection Management

ToolDescription
connectConnect to a MySQL database
disconnectDisconnect from MySQL
is_connectedCheck connection status
commitCommit current transaction
rollbackRollback current transaction

Query Execution

ToolDescription
execute_queryExecute raw SQL query and return results

Database Operations

ToolDescription
list_databasesList all databases on server
create_databaseCreate a new database
drop_databaseDrop a database
database_existsCheck if database exists

Table Operations

ToolDescription
list_tablesList tables in a database
describe_tableGet table schema
create_tableCreate a new table
drop_tableDrop a table
table_existsCheck if table exists

Column & Index Operations

ToolDescription
show_columnsShow column details
show_indexesShow index details
create_indexCreate an index
drop_indexDrop an index

User Management

ToolDescription
create_userCreate a MySQL user
drop_userDrop a MySQL user
grant_privilegesGrant privileges to user
revoke_privilegesRevoke privileges from user
show_privilegesShow user privileges

Server Information

ToolDescription
server_statusGet MySQL server status

MCP Resources

The server provides dynamic resources for database and table metadata:

  • database://{name} - Database metadata including table list
  • table://{db}/{table} - Table metadata including schema, columns, and indexes

Usage Examples

Connect and Query

# First, connect to databaseconnect(host="localhost", user="root", password="secret", database="mydb")
# Execute a queryexecute_query(sql="SELECT * FROM users WHERE active = true")
# List all tableslist_tables(database="mydb")

Create Database and Table

# Create a databasecreate_database(name="newapp")
# Create a tablecreate_table(name="users", schema="id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255), email VARCHAR(255) UNIQUE")

User Management

# Create a new user with passwordcreate_user(username="app_user", host="localhost", password="secure_password")
# Grant privilegesgrant_privileges(privileges="SELECT,INSERT,UPDATE,DELETE", on="newapp.*", username="app_user", host="localhost")

Transaction Control

# Start transactionexecute_query(sql="BEGIN")
# Execute operationsexecute_query(sql="INSERT INTO accounts (balance) VALUES (100)")
# Commit or rollbackcommit()  # or rollback()

Environment Variables

The server supports configuration via environment variables:

bash
export MYSQL_HOST=localhostexport MYSQL_PORT=3306export MYSQL_USER=rootexport MYSQL_PASSWORD=secretexport MYSQL_DATABASE=mydb

Development

bash
# Clone repositorygit clone https://github.com/daedalus/mcp-mysql-connector.gitcd mcp-mysql-connector
# Create virtual environmentpython -m venv venvsource venv/bin/activate
# Install dependenciespip install -e ".[test]"
# Run testspytest
# Format coderuff format src/ tests/
# Lintruff check src/ tests/
# Type checkmypy src/

Architecture

mcp-mysql-connector/├── src/mcp_mysql/│   ├── core/models.py       # Data models (QueryResult, TableSchema, etc.)│   ├── adapters/mysql.py    # MySQL connection & pooling│   ├── services/connection.py  # Connection manager│   ├── tools/mysql_tools.py   # MCP tool implementations│   └── mcp.py              # FastMCP server setup└── tests/                   # Test suite

Requirements

  • Python 3.11+
  • fastmcp >= 2.0.0
  • pymysql >= 1.1.0
  • sqlparse >= 0.4.0

License

MIT License - see LICENSE for details.

來源:README.md,提交 b397ef6

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分