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 分