
mysql_mcp_servers
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を使用する場合)
セットアップ
-
リポジトリをクローン:
git clone <repository-url> cd mysql_mcp_server
-
仮想環境を作成し、アクティベート:
python -m venv .venv source .venv/bin/activate # Linuxの場合
-
依存関係をインストール:
pip install -r requirements.txt .
-
セットアップスクリプトを実行して、実行スクリプトに実行権限を付与:
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サーバーに接続する場合:
- WSL内のMySQLサーバーが起動していることを確認
- WSL内のMySQLがリモート接続を許可するように設定されていることを確認
-
/etc/mysql/mysql.conf.d/mysqld.cnf
ファイルでbind-addressを0.0.0.0
に変更 - 使用するMySQLユーザーにリモートからのアクセス権限を付与
-
- Windows側のファイアウォールがMySQLポート(デフォルト13306)への接続を許可していることを確認
開発
Noxセッション
このプロジェクトは、テスト、フォーマット、リントのためのNoxセッションを提供しています。
-
Noxをインストール:
pip install nox
-
全てのテストを実行:
nox -s test
-
コードをフォーマット:
nox -s format
-
リントチェックを実行:
nox -s lint
直接テストを実行
pytest tests/
コードカバレッジを確認
pytest --cov=src.mysql_mcp_server tests/
ライセンス
このプロジェクトはMITライセンスの下で公開されています。
相关推荐
🔥 1Panel fournit une interface Web intuitive et un serveur MCP pour gérer des sites Web, des fichiers, des conteneurs, des bases de données et des LLM sur un serveur Linux.
🧑🚀 全世界最好的 LLM 资料总结 (数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Résumé des meilleures ressources LLM du monde.
⛓️RULEGO est un cadre de moteur de règle d'orchestration des composants de nouvelle génération légère, intégrée, intégrée et de nouvelle génération pour GO.
Créez facilement des outils et des agents LLM à l'aide de fonctions Plain Bash / JavaScript / Python.
😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 QQ / 微信 (企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 Dify 、 Claude 、 GEMINI 、 XAI 、 PPIO 、 OLLAMA 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 ChatGlm 、 Sillytraven 、 MCP 等 LLM 的机器人 / Agent | Plateforme de bots de messagerie instantanée basés sur LLM, prend en charge Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack
Reviews

user_KdYmnUTE
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!

user_mOJ7h4oR
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!

user_MQGOTRRh
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!

user_e2enhmi5
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!

user_PuBpsnrX
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!

user_lU4RsjCe
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!

user_37fzMeWR
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!

user_mNnN3wZ4
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!

user_RSBIMOcK
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!

user_VUzRgYYw
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!

user_9js60Vlt
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!

user_ac888yUV
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.

user_teVTpUZA
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!

user_byDlFReR
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.