MySQL MCP サーバー
MySQL データベースと対話するための MCP サーバー。
このサーバーは、読み取り専用クエリ (query) と、最終的にロールバックされる書き込みクエリ (test_execute) の実行をサポートしています。
設定
環境変数
~/.mcp/.envに次の環境変数を追加します。
注:
host.docker.internal、Docker コンテナからホストマシンのサービスにアクセスするための特別な DNS 名です。ホストマシン上で実行されている MySQL サーバーに接続する場合は、この設定を使用してください。別の MySQL サーバーに接続する場合は、適切なホスト名に変更してください。
mcp.json 構成
使用法
サーバーの起動
注:OrbStackを使用している場合は、
host.docker.internalが自動的にサポートされるため、--add-hostオプションは省略できます。Docker Desktopも通常はこれを自動的にサポートしますが、信頼性を高めるために--add-hostオプションを追加することをお勧めします。
利用可能なコマンド
1. 読み取り専用クエリを実行する
応答:
2. クエリ実行のテスト
応答:
3. リストテーブル
応答:
4. 表の説明
応答:
実装の詳細
TypeScriptで実装
mysql2 パッケージを使用
Dockerコンテナとして実行
標準入力を通じてJSONコマンドを受け入れる
標準出力を通じてJSONレスポンスを返します
ホスト MySQL に接続するために
host.docker.internalを使用します (OrbStack と Docker Desktop の両方と互換性があります)
セキュリティに関する考慮事項
機密情報の管理に環境変数を使用する
SQLインジェクションの防止は実装者の責任である
実稼働環境での使用には適切なネットワーク構成が必要
ホストマシンのサービスに接続する際に必要な適切なファイアウォール設定
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
JSON コマンドを介して MySQL データベースと対話できるようにし、読み取り専用クエリ、書き込みクエリのテスト実行、Docker を介したテーブル情報の取得をサポートします。
Related Resources
Related MCP Servers
- -security-license-qualityFacilitates interaction with a local MySQL database via a RESTful API, supporting database queries and real-time updates with integration for Cursor MCP services.Last updated -4
- Asecurity-licenseAqualityConnect and interact with MySQL databases seamlessly. Execute SQL queries, manage database connections, and retrieve data directly through AI assistants. Enhance your AI capabilities with structured access to your MySQL data.Last updated -9017MIT License
- -security-license-qualityEnables secure interaction with MySQL databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.Last updated -
- -security-license-qualityAn executable MySQL server implementation that facilitates database connections and operations with built-in stability features and configuration options.Last updated -