Skip to main content
Glama
meanands

SQL MCP Server for Claude Desktop

by meanands

Claude デスクトップ用の SQL MCP サーバー

Claude Desktop を介した、ローカル MySQL データベースへの自然言語インターフェース。この MCP (Machine Communication Protocol) サーバーにより、Claude はローカル MySQL データベースに対して SQL クエリを実行できるため、自然言語でデータベースを操作できるようになります。

特徴

  • Claudeによる自然言語からSQLクエリへの変換

  • ローカル MySQL データベースへの安全な接続

  • 複数のデータベースのサポート

  • データの一貫性を保つためのトランザクション管理

  • パフォーマンス向上のための接続プール

  • すべての種類の SQL クエリ (SELECT、INSERT、UPDATE、DELETE など) のサポート

Related MCP server: MySQL MCP Server

前提条件

  • Python 3.8以上

  • MySQLサーバーがインストールされ、実行中

  • クロードデスクトップアプリケーション

  • 仮想環境(推奨)

インストール

  1. このリポジトリをクローンします:

git clone git@github.com:meanands/mysql-mcp.git
cd mysql-mcp
  1. 仮想環境を作成してアクティブ化します。

# For macOS/Linux
python -m venv venv
source venv/bin/activate

# For Windows
python -m venv venv
venv\Scripts\activate
  1. 依存関係をインストールします:

pip install -r requirements.txt
  1. MySQL 資格情報を使用して、プロジェクト ルートに.envファイルを作成します。

MYSQL_HOST=localhost
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
  1. run.sh内のディレクトリ パスを更新します。

# Open run.sh and replace this line:
cd /Users/yourname/code/sql-mcp
# with your actual project directory path, for example:
cd /Users/yourname/projects/mysql-mcp
  1. 実行スクリプトを実行可能にします。

chmod +x run.sh

Claude Desktopでの設定

  1. Claude DesktopのMCP構成を開く

  2. 次の構成を追加します。

{
  "sql": {
    "command": "/absolute/path/to/your/mysql-mcp/run.sh"
  }
}

/absolute/path/to/your/mysql-mcpプロジェクト ディレクトリへの実際の絶対パスに置き換えます。

使用法

設定が完了すると、Claude Desktop を通じて自然言語でデータベースを操作できるようになります。例:

  1. データベースの選択とテーブルの作成:

Use the 'employees' database and create a table for storing employee information with fields for name, email, and department.
  1. データの挿入:

Insert a new employee named John Doe with email john.doe@example.com in the Engineering department.
  1. データのクエリ:

Show me all employees in the Engineering department.

重要な注意事項

  • run.sh スクリプトと Claude Desktop 構成では常に絶対パスを使用します。

  • MCP サーバーを使用する前に、MySQL サーバーが実行中であることを確認してください。

  • .env ファイルを安全に保ち、バージョン管理にコミットしないでください。

  • MCPサーバーは、デフォルトのプールサイズが5接続である接続プールを使用します。

トラブルシューティング

  1. 「接続拒否」エラーが発生した場合は、MySQLサーバーが動作していることを確認してください。

  2. 認証エラーが発生した場合は、.envファイル内の資格情報を確認してください。

  3. 権限エラーの場合は、MySQLユーザーが実行しようとしている操作に対して適切な権限を持っていることを確認してください。

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

  • 機密性の高い認証情報を .env ファイルに保存する

  • 適切な権限を持つ MySQL ユーザーを使用する (root の使用は避ける)

  • 仮想環境と依存関係を最新の状態に保つ

  • ローカルホスト以外のMySQLサーバーにアクセスする場合はネットワークセキュリティを考慮する

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Connects AI assistants like Claude Desktop directly to MySQL databases, enabling natural language interaction for schema inspection, data querying, CRUD operations, and database administration tasks.
    11 npm
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables Claude Desktop to execute read-only SQL queries on MySQL databases via natural language, with dynamic connection switching and built-in security.
    3
    113 npm
    7
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables Claude Code to directly operate MySQL databases through natural language, supporting multi-environment profiles, security modes, and 11 tools.
    11
    16 npm
    2
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables natural language querying of MySQL databases via Claude Code, allowing SELECT queries, table listing, and schema inspection.
    730 npm
    MIT