MySQL MCP Server

MIT License
330
  • Linux
  • Apple

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Enables secure interaction with MySQL databases, allowing for listing tables, reading data, and executing SQL queries through a controlled interface for database exploration and analysis.

MySQL MCP サーバー

MySQLデータベースとの安全なやり取りを可能にするモデルコンテキストプロトコル(MCP)実装。このサーバーコンポーネントは、AIアプリケーション(ホスト/クライアント)とMySQLデータベース間の通信を容易にし、制御されたインターフェースを通じてデータベースの探索と分析をより安全かつ構造化します。

: MySQL MCP サーバーは、スタンドアロン サーバーとして使用するように設計されているのではなく、AI アプリケーションと MySQL データベース間の通信プロトコル実装として設計されています。

特徴

  • 利用可能な MySQL テーブルをリソースとして一覧表示する
  • 表の内容を読む
  • 適切なエラー処理でSQLクエリを実行する
  • 環境変数による安全なデータベースアクセス
  • 包括的なログ記録

インストール

手動インストール

pip install mysql-mcp-server

Smithery経由でインストール

Smithery経由で Claude Desktop 用の MySQL MCP Server を自動的にインストールするには:

npx -y @smithery/cli install mysql-mcp-server --client claude

構成

次の環境変数を設定します。

MYSQL_HOST=localhost # Database host MYSQL_PORT=3306 # Optional: Database port (defaults to 3306 if not specified) MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=your_database

使用法

クロード・デスクトップ

これをclaude_desktop_config.jsonに追加します:

{ "mcpServers": { "mysql": { "command": "uv", "args": [ "--directory", "path/to/mysql_mcp_server", "run", "mysql_mcp_server" ], "env": { "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306", "MYSQL_USER": "your_username", "MYSQL_PASSWORD": "your_password", "MYSQL_DATABASE": "your_database" } } } }

Visual Studio Codeを使用

mcp.jsonに以下を追加します:

{ "servers": { "mysql": { "type": "stdio", "command": "uvx", "args": [ "--from", "mysql-mcp-server", "mysql_mcp_server" ], "env": { "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306", "MYSQL_USER": "your_username", "MYSQL_PASSWORD": "your_password", "MYSQL_DATABASE": "your_database" } } }

注: これを動作させるには uv をインストールする必要があります

MCP Inspectorによるデバッグ

MySQL MCP Server はスタンドアロンで実行したり、Python を使用してコマンドラインから直接実行したりすることを目的としていませんが、MCP Inspector を使用してデバッグすることができます。

MCP インスペクターは、MCP 実装をテストおよびデバッグするための便利な方法を提供します。

# Install dependencies pip install -r requirements.txt # Use the MCP Inspector for debugging (do not run directly with Python)

MySQL MCP サーバーは、Claude Desktop などの AI アプリケーションと統合されるように設計されており、スタンドアロンの Python プログラムとして直接実行しないでください。

発達

# Clone the repository git clone https://github.com/yourusername/mysql_mcp_server.git cd mysql_mcp_server # Create virtual environment python -m venv venv source venv/bin/activate # or `venv\Scripts\activate` on Windows # Install development dependencies pip install -r requirements-dev.txt # Run tests pytest

セキュリティに関する考慮事項

  • 環境変数や資格情報をコミットしないでください
  • 必要最小限の権限を持つデータベースユーザーを使用する
  • 本番環境での使用にクエリホワイトリストを実装することを検討する
  • すべてのデータベース操作を監視して記録する

セキュリティのベストプラクティス

このMCP実装は、データベースアクセスを必要とします。セキュリティのため、

  1. 最小限の権限を持つ専用のMySQLユーザーを作成する
  2. ルート認証情報や管理者アカウントは使用しないでください
  3. 必要な操作のみにデータベースアクセスを制限する
  4. 監査目的でログを有効にする
  5. データベースアクセスの定期的なセキュリティレビュー

詳細な手順については、 MySQL セキュリティ構成ガイドを参照してください。

  • 制限付きMySQLユーザーの作成
  • 適切な権限の設定
  • データベースアクセスの監視
  • セキュリティのベストプラクティス

⚠️ 重要: データベース アクセスを構成するときは、常に最小権限の原則に従ってください。

ライセンス

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

貢献

  1. リポジトリをフォークする
  2. 機能ブランチを作成します( git checkout -b feature/amazing-feature
  3. 変更をコミットします ( git commit -m 'Add some amazing feature' )
  4. ブランチにプッシュする ( git push origin feature/amazing-feature )
  5. プルリクエストを開く

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

AI アシスタントが制御されたインターフェースを介してテーブルの一覧表示、データの読み取り、SQL クエリの実行を行えるようになり、データベースの探索と分析がより安全かつ構造化されます。

  1. Features
    1. Installation
      1. Manual Installation
      2. Installing via Smithery
    2. Configuration
      1. Usage
        1. With Claude Desktop
        2. With Visual Studio Code
        3. Debugging with MCP Inspector
      2. Development
        1. Security Considerations
          1. Security Best Practices
            1. License
              1. Contributing
                ID: vijdhok35p