Skip to main content
Glama
daedalus

mcp-mysql-connector

by daedalus

mcp-mysql-connector

MySQLデータベースの機能をLLMエージェント向けのツールとして公開するMCPサーバーです。

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

PyPI Python Coverage Ruff

概要

mcp-mysql-connectorは、MySQLデータベース操作をLLMエージェント向けのツールとして提供するModel Context Protocol (MCP)サーバーです。標準化されたプロトコルを通じてAIアシスタントがMySQLデータベースと対話できるようにし、以下を可能にします:

  • データベースとテーブルの管理

  • クエリの実行

  • ユーザー認証と権限管理

  • スキーマのイントロスペクション

  • トランザクション制御

Related MCP server: MCP Server MySQL

インストール

pip install mcp-mysql-connector

クイックスタート

サーバーの実行

# Run with stdio transport (default)
mcp-mysql-connector

# Or run programmatically
python -c "from mcp_mysql import mcp; mcp.run()"

設定

connectツールを使用してMySQLに接続します:

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

MCPツール

接続管理

ツール

説明

connect

MySQLデータベースに接続する

disconnect

MySQLから切断する

is_connected

接続状態を確認する

commit

現在のトランザクションをコミットする

rollback

現在のトランザクションをロールバックする

クエリ実行

ツール

説明

execute_query

生のSQLクエリを実行し結果を返す

データベース操作

ツール

説明

list_databases

サーバー上のすべてのデータベースを一覧表示する

create_database

新しいデータベースを作成する

drop_database

データベースを削除する

database_exists

データベースが存在するか確認する

テーブル操作

ツール

説明

list_tables

データベース内のテーブルを一覧表示する

describe_table

テーブルのスキーマを取得する

create_table

新しいテーブルを作成する

drop_table

テーブルを削除する

table_exists

テーブルが存在するか確認する

カラム・インデックス操作

ツール

説明

show_columns

カラムの詳細を表示する

show_indexes

インデックスの詳細を表示する

create_index

インデックスを作成する

drop_index

インデックスを削除する

ユーザー管理

ツール

説明

create_user

MySQLユーザーを作成する

drop_user

MySQLユーザーを削除する

grant_privileges

ユーザーに権限を付与する

revoke_privileges

ユーザーから権限を剥奪する

show_privileges

ユーザーの権限を表示する

サーバー情報

ツール

説明

server_status

MySQLサーバーのステータスを取得する

MCPリソース

サーバーはデータベースとテーブルのメタデータのための動的リソースを提供します:

  • database://{name} - テーブル一覧を含むデータベースのメタデータ

  • table://{db}/{table} - スキーマ、カラム、インデックスを含むテーブルのメタデータ

使用例

接続とクエリ

# First, connect to database
connect(host="localhost", user="root", password="secret", database="mydb")

# Execute a query
execute_query(sql="SELECT * FROM users WHERE active = true")

# List all tables
list_tables(database="mydb")

データベースとテーブルの作成

# Create a database
create_database(name="newapp")

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

ユーザー管理

# Create a new user with password
create_user(username="app_user", host="localhost", password="secure_password")

# Grant privileges
grant_privileges(privileges="SELECT,INSERT,UPDATE,DELETE", on="newapp.*", username="app_user", host="localhost")

トランザクション制御

# Start transaction
execute_query(sql="BEGIN")

# Execute operations
execute_query(sql="INSERT INTO accounts (balance) VALUES (100)")

# Commit or rollback
commit()  # or rollback()

環境変数

サーバーは環境変数による設定をサポートしています:

export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=secret
export MYSQL_DATABASE=mydb

開発

# Clone repository
git clone https://github.com/daedalus/mcp-mysql-connector.git
cd mcp-mysql-connector

# Create virtual environment
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install -e ".[test]"

# Run tests
pytest

# Format code
ruff format src/ tests/

# Lint
ruff check src/ tests/

# Type check
mypy src/

アーキテクチャ

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

要件

  • Python 3.11+

  • fastmcp >= 2.0.0

  • pymysql >= 1.1.0

  • sqlparse >= 0.4.0

ライセンス

MITライセンス - 詳細はLICENSEを参照してください。

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
1Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    Enables AI models to perform MySQL database operations through a standardized interface, supporting secure connections, query execution, and comprehensive schema management.
    7
    61
    33
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    Enables LLMs to interact with MySQL databases through standardized protocol, supporting database management, table operations, data queries, and modifications with configurable permission controls.
    15
    69
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to safely interact with MySQL/MariaDB databases, supporting read-only queries by default with optional write operations and access control.
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to interact with a MySQL database using natural language, automating SQL tasks like querying, inserting, updating, and deleting data.
    1

View all related MCP servers

Related MCP Connectors

  • Gateway between LLM agents and world data through eight tools and a bundled endpoint catalog.

  • Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.

  • MemoryOracle - 10 agent memory tools: vector store, recall, summarization, redaction.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daedalus/mcp-mysql-connector'

If you have feedback or need assistance with the MCP directory API, please join our Discord server