Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

MySQL MCP Server

このプロジェクトは、MCP (Model Context Protocol) を使用してMySQLデータベースとやり取りするためのサーバーを提供します。WSL環境でMySQLデータベースにアクセスするためのインターフェースを提供します。

機能

  • MySQLデータベース内のテーブル一覧の取得
  • テーブルからのデータ読み取り(最大100行)
  • SQLクエリの実行(SELECT、SHOW TABLES、INSERT、UPDATE、DELETEなど)

プロジェクト構造

src/mysql_mcp_server/
├── __init__.py        # パッケージ初期化
├── config/           # 設定関連モジュール
│   ├── __init__.py  
│   └── settings.py   # データベース設定
├── database/         # データベース操作モジュール
│   ├── __init__.py  
│   ├── connection.py # DB接続処理
│   └── errors.py     # エラークラス
├── tools/            # ツールモジュール
│   ├── __init__.py  
│   └── sql_tools.py  # SQL実行ツール
└── server.py         # MCPサーバーメイン

インストールと実行

前提条件

  • Python 3.11以上
  • MySQLサーバー(ローカルまたはリモート)
  • 仮想環境(virtualenv)
  • Docker(Dockerを使用する場合)

セットアップ

  1. リポジトリをクローン:

    git clone <repository-url>
    cd mysql_mcp_server
    
  2. 仮想環境を作成し、アクティベート:

    python -m venv .venv
    source .venv/bin/activate  # Linuxの場合
    
  3. 依存関係をインストール:

    pip install -r requirements.txt .
    
  4. セットアップスクリプトを実行して、実行スクリプトに実行権限を付与:

    chmod +x setup.sh
    ./setup.sh
    

実行方法

以下のいずれかの方法でサーバーを実行できます:

1. 直接実行

./run_direct.sh

2. モジュールとして実行

./run_module.sh

3. Dockerコンテナで実行

# Dockerイメージをビルド
docker build -t mysql-mcp-server:latest .

# コンテナを実行
./run_docker.sh

環境変数

サーバーは以下の環境変数を使用してMySQLに接続します:

  • MYSQL_HOST: MySQLサーバーのホスト(デフォルト: host.docker.internal
  • MYSQL_PORT: MySQLサーバーのポート(デフォルト: 13306
  • MYSQL_USER: MySQLユーザー名
  • MYSQL_PASSWORD: MySQLパスワード
  • MYSQL_DATABASE: 使用するデータベース名

MCPプロトコル

このサーバーはMCP(Model Control Protocol)を実装しており、以下のエンドポイントを提供します:

  • list_resources: データベース内のテーブル一覧を取得
  • read_resource: 特定のテーブルからデータを読み取り
  • list_tools: 利用可能なツール(SQLクエリの実行)を一覧表示
  • call_tool: SQLクエリを実行

WSL連携

WSL(Windows Subsystem for Linux)環境内のMySQLサーバーに接続する場合:

  1. WSL内のMySQLサーバーが起動していることを確認
  2. WSL内のMySQLがリモート接続を許可するように設定されていることを確認
    • /etc/mysql/mysql.conf.d/mysqld.cnfファイルでbind-addressを0.0.0.0に変更
    • 使用するMySQLユーザーにリモートからのアクセス権限を付与
  3. Windows側のファイアウォールがMySQLポート(デフォルト13306)への接続を許可していることを確認

開発

Noxセッション

このプロジェクトは、テスト、フォーマット、リントのためのNoxセッションを提供しています。

  1. Noxをインストール:

    pip install nox
    
  2. 全てのテストを実行:

    nox -s test
    
  3. コードをフォーマット:

    nox -s format
    
  4. リントチェックを実行:

    nox -s lint
    

直接テストを実行

pytest tests/

コードカバレッジを確認

pytest --cov=src.mysql_mcp_server tests/

ライセンス

このプロジェクトはMITライセンスの下で公開されています。

相关推荐

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • 1Panel-dev
  • 🔥 1Panel proporciona una interfaz web intuitiva y un servidor MCP para administrar sitios web, archivos, contenedores, bases de datos y LLM en un servidor de Linux.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • rulego
  • ⛓️Rulego es un marco de motor de regla de orquestación de componentes de alta generación de alto rendimiento, de alto rendimiento y de alto rendimiento para GO.

  • sigoden
  • Cree fácilmente herramientas y agentes de LLM utilizando funciones Plain Bash/JavaScript/Python.

  • hkr04
  • SDK liviano C ++ MCP (Protocolo de contexto del modelo)

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 Qq / 微信(企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 DiFy 、 Claude 、 Gemini 、 Xai 、 PPIO 、 Ollama 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 Chatglm 、 SillyTraven 、 MCP 等 LLM 的机器人 / Agente | Plataforma de bots de mensajería instantánea basada en LLM, admite Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack

  • dmayboroda
  • Trapo conversacional local con contenedores configurables

  • modelscope
  • Iniciar aplicaciones de múltiples agentes empoderadas con Building LLM de manera más fácil.

  • paulwing
  • Un repositorio de pruebas creado con el servicio MCP

    Reviews

    3.3 (14)
    Avatar
    user_KdYmnUTE
    2025-04-24

    As a dedicated user of mysql_mcp_servers by OTA-EITA, I can confidently say that this product has significantly streamlined our database management tasks. The seamless integrations and robust performance have made it indispensable for our IT operations. Highly recommended for anyone in need of reliable MySQL server solutions!

    Avatar
    user_mOJ7h4oR
    2025-04-24

    As a dedicated user of mysql_mcp_servers, I can confidently say that this product by OTA-EITA has significantly improved my database management tasks. Its robust features and seamless integration have made my work more efficient. Highly recommend it to anyone in need of reliable and powerful database solutions!

    Avatar
    user_MQGOTRRh
    2025-04-24

    The mysql_mcp_servers by OTA-EITA is a game-changer for managing MySQL databases. Its seamless integration and user-friendly interface make it a must-have for any developer or database administrator. Highly recommended for those looking to optimize their database performance!

    Avatar
    user_e2enhmi5
    2025-04-24

    As a devoted user of the mysql_mcp_servers, I must say this product by OTA-EITA is an outstanding solution for managing MySQL databases. Its seamless integration and robust features have significantly improved our efficiency and performance. Highly recommended for anyone looking for a reliable and efficient MySQL management tool!

    Avatar
    user_PuBpsnrX
    2025-04-24

    I have been using mysql_mcp_servers by OTA-EITA for a while now, and it has significantly streamlined my database management tasks. The application is intuitive and robust, making complex operations much more straightforward. Highly recommended for anyone looking to manage MySQL servers efficiently!

    Avatar
    user_lU4RsjCe
    2025-04-24

    As a devoted user of mysql_mcp_servers, I can confidently say that this product has significantly enhanced my database management tasks. It offers robust performance, seamless integration, and unparalleled reliability. OTA-EITA has truly developed an exceptional tool that meets all the essential needs of managing MySQL servers efficiently. Highly recommended for anyone looking to streamline their database operations!

    Avatar
    user_37fzMeWR
    2025-04-24

    As a dedicated user of mysql_mcp_servers, I can confidently say this product by OTA-EITA has significantly improved my database management processes. It's efficient, reliable, and user-friendly, making it an indispensable tool for anyone serious about handling MySQL databases effectively. Highly recommended!

    Avatar
    user_mNnN3wZ4
    2025-04-24

    As a dedicated user of mysql_mcp_servers, I can confidently say that this product by OTA-EITA is exceptional. It offers robust performance, unparalleled reliability, and seamless integration for all your MySQL server needs. The user-friendly interface and comprehensive documentation make it accessible for beginners while powerful enough for advanced users. Highly recommended!

    Avatar
    user_RSBIMOcK
    2025-04-24

    I've been using mysql_mcp_servers by OTA-EITA for a few months now, and I am thoroughly impressed. The seamless integration and robust performance have significantly improved my database management experience. It's evident that a lot of thought has gone into making this product reliable and efficient. Highly recommend for anyone looking for a solid MCP application!

    Avatar
    user_VUzRgYYw
    2025-04-24

    As a dedicated user of mysql_mcp_servers by OTA-EITA, I am extremely impressed with its seamless integration and efficient performance. The user-friendly interface and robust features make database management a breeze. Since using this product, my workflow has become much more streamlined and productive. Highly recommended for anyone seeking reliable MySQL solutions!

    Avatar
    user_9js60Vlt
    2025-04-24

    As a devoted user of mysql_mcp_servers by OTA-EITA, I can confidently say this service is a game-changer for managing MySQL databases. Its robust features and seamless integration have drastically improved our database operations. The user-friendly interface coupled with reliable performance makes it a must-have tool for any database administrator. Highly recommend!

    Avatar
    user_ac888yUV
    2025-04-24

    I've been using mysql_mcp_servers by OTA-EITA for several months now, and I'm thoroughly impressed. The seamless integration and reliable performance have significantly boosted our database management efficiency. Highly recommend for anyone looking to streamline their MySQL operations.

    Avatar
    user_teVTpUZA
    2025-04-24

    As a devoted user of mysql_mcp_servers, I can honestly say this product by OTA-EITA is phenomenal. It has streamlined my database management tasks and improved overall efficiency. The user-friendly interface combined with robust features makes it an essential tool for any serious database administrator. Highly recommend it!

    Avatar
    user_byDlFReR
    2025-04-24

    As a devoted user of MySQL MCP Servers by OTA-EITA, I can genuinely say this product has revolutionized my database management experience. Its seamless integration and efficient performance have greatly enhanced our operational productivity. Highly recommended for anyone in need of robust and reliable MySQL server solutions.