MySQL MCP Server
MySQL MCP サーバー
MySQLデータベースとの安全なやり取りを可能にするモデルコンテキストプロトコル(MCP)実装。このサーバーコンポーネントは、AIアプリケーション(ホスト/クライアント)とMySQLデータベース間の通信を容易にし、制御されたインターフェースを通じてデータベースの探索と分析をより安全かつ構造化します。
注: MySQL MCP サーバーは、スタンドアロン サーバーとして使用するように設計されているのではなく、AI アプリケーションと MySQL データベース間の通信プロトコル実装として設計されています。
特徴
利用可能な MySQL テーブルをリソースとして一覧表示する
表の内容を読む
適切なエラー処理でSQLクエリを実行する
環境変数による安全なデータベースアクセス
包括的なログ記録
Related MCP server: PostgreSQL MCP Server
インストール
手動インストール
pip install mysql-mcp-serverSmithery経由でインストール
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実装は、データベースアクセスを必要とします。セキュリティのため、
最小限の権限を持つ専用のMySQLユーザーを作成する
ルート認証情報や管理者アカウントは使用しないでください
必要な操作のみにデータベースアクセスを制限する
監査目的でログを有効にする
データベースアクセスの定期的なセキュリティレビュー
詳細な手順については、 MySQL セキュリティ構成ガイドを参照してください。
制限付きMySQLユーザーの作成
適切な権限の設定
データベースアクセスの監視
セキュリティのベストプラクティス
⚠️ 重要: データベース アクセスを構成するときは、常に最小権限の原則に従ってください。
ライセンス
MIT ライセンス - 詳細については LICENSE ファイルを参照してください。
貢献
リポジトリをフォークする
機能ブランチを作成します(
git checkout -b feature/amazing-feature)変更をコミットします (
git commit -m 'Add some amazing feature')ブランチにプッシュする (
git push origin feature/amazing-feature)プルリクエストを開く
Maintenance
Related MCP Servers
- Flicense-qualityDmaintenanceEnables secure interaction with MySQL databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.
- Alicense-quality-maintenanceProvides AI assistants with safe, controlled access to PostgreSQL databases with read-only defaults, granular permissions, query safety features, and schema introspection capabilities.1
- Flicense-qualityDmaintenanceEnables AI assistants to securely interact with MySQL databases, including listing tables, viewing schemas, and executing read-only SQL queries through natural language.6
- Flicense-qualityCmaintenanceEnables read-only SQL database access for AI assistants, allowing schema exploration and safe query execution without risk of data modification.
Related MCP Connectors
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Connect your AI assistants to Keboola and expose your data, transformations, SQL queries, ...
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/designcomputer/mysql_mcp_server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server