MySQL MCP Server
MySQL MCP サーバー
これは、MySQLデータベースへのアクセスを提供するモデルコンテキストプロトコル(MCP)サーバーです。エージェントがMySQLデータベースに対してSQLクエリを実行できるようにします。
特徴
MySQL データベースに対して SQL クエリを実行します。
データの読み取り(SELECT文)
テーブルの作成 (CREATE TABLE ステートメント)
データの挿入(INSERT INTO ステートメント)
データの更新(UPDATE文)
データの削除(DELETE FROM ステートメント)
クエリ結果をJSON形式で返します
構成可能なデータベース接続設定
一意のIDによるトランザクションログ
Related MCP server: MCP MySQL Server
前提条件
Node.js (v14以上)
MySQLサーバー
MCP SDK
インストール
このリポジトリをクローンまたはダウンロードする
依存関係をインストールします:
cd mysql-mcp-server
npm installサーバーを構築します。
npm run build構成
MySQL MCP サーバーは、構成に次の環境変数を使用します。
MYSQL_HOST: MySQLサーバーのホスト名(デフォルト: 'localhost')MYSQL_PORT: MySQLサーバーのポート(デフォルト: 3306)MYSQL_USER: MySQLユーザー名(デフォルト: 'mcp101')MYSQL_PASSWORD: MySQLパスワード(デフォルト: '123qwe')MYSQL_DATABASE: MySQLデータベース名(デフォルト: 'mcpdb')
データベースのセットアップ
MySQL データベースを作成します。
CREATE DATABASE mcpdb;データベースへのアクセス権を持つ MySQL ユーザーを作成します。
CREATE USER 'mcp101'@'localhost' IDENTIFIED BY '123qwe';
GRANT ALL PRIVILEGES ON mcpdb.* TO 'mcp101'@'localhost';
FLUSH PRIVILEGES;サンプル データを含むテスト テーブルを作成します。
USE mcpdb;
CREATE TABLE test_users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO test_users (name, email) VALUES
('John Doe', 'john@example.com'),
('Jane Smith', 'jane@example.com'),
('Bob Johnson', 'bob@example.com');MCP構成
MySQL MCP サーバーを MCP 設定ファイルに追加します。
VSCode (Claude 拡張機能)
ファイル: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
MySQLの設定に応じて引数を変更します
{
"mcpServers": {
"mysql-mcp-server": {
"autoApprove": [],
"disabled": false,
"timeout": 60,
"command": "node",
"args": [
"/path/to/mysql-mcp-server/build/index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "mcp101",
"MYSQL_PASSWORD": "123qwe",
"MYSQL_DATABASE": "mcpdb"
},
"transportType": "stdio"
}
}
}クロードデスクトップアプリ
ファイル: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"mysql-mcp-server": {
"autoApprove": [],
"disabled": false,
"timeout": 60,
"command": "node",
"args": [
"/path/to/mysql-mcp-server/build/index.js"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "mcp101",
"MYSQL_PASSWORD": "123qwe",
"MYSQL_DATABASE": "mcpdb"
},
"transportType": "stdio"
}
}
}使用法
設定が完了したら、Claudeとの会話でMySQL MCPサーバーを使用できるようになります。例:
「test_users テーブル内のすべてのユーザーを表示できますか?」
Claude はrun_sql_queryツールを使用して次を実行します。
SELECT * FROM test_users利用可能なツール
実行SQLクエリ
MySQL データベースに対して読み取り専用の SQL クエリ (SELECT ステートメントのみ) を実行します。
パラメータ:
query: 実行する SQL SELECT クエリ。
例:
{
"query": "SELECT * FROM test_users"
}テーブルを作成する
MySQL データベースに新しいテーブルを作成します。
パラメータ:
query: 実行する SQL CREATE TABLE クエリ。
例:
{
"query": "CREATE TABLE products (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), price DECIMAL(10,2))"
}挿入データ
MySQL データベースのテーブルにデータを挿入します。
パラメータ:
query: 実行する SQL INSERT INTO クエリ。
例:
{
"query": "INSERT INTO products (name, price) VALUES ('Laptop', 999.99), ('Smartphone', 499.99)"
}更新データ
MySQL データベース内のテーブル内のデータを更新します。
パラメータ:
query: 実行する SQL UPDATE クエリ。
例:
{
"query": "UPDATE products SET price = 899.99 WHERE name = 'Laptop'"
}データを削除
MySQL データベース内のテーブルからデータを削除します。
パラメータ:
query: 実行する SQL DELETE FROM クエリ。
例:
{
"query": "DELETE FROM products WHERE name = 'Smartphone'"
}セキュリティに関する考慮事項
MCP サーバーに適切な権限を持つ専用の MySQL ユーザーを使用します。
データのクエリのみが必要な場合は、読み取り専用権限の使用を検討してください。
データベースの資格情報などの機密情報を安全に保存する
すべての操作は監査のために一意のトランザクションIDで記録されます
Available Tools
6 toolscreate_tableC
Creates a new table in the MySQL database.
Inputs: query (required).
delete_dataC
Deletes data from a table in the MySQL database.
Inputs: query (required).
execute_sqlB
Executes any non-SELECT SQL statement (e.g., ALTER TABLE, DROP, etc.)
Inputs: query (required).
insert_dataC
Inserts data into a table in the MySQL database.
Inputs: query (required).
run_sql_queryA
Executes a read-only SQL query (SELECT statements only) against the MySQL database.
Inputs: query (required).
update_dataC
Updates data in a table in the MySQL database.
Inputs: query (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Most tools have distinct purposes with clear boundaries (e.g., create_table vs. insert_data vs. update_data). However, execute_sql and run_sql_query could cause confusion since both execute SQL statements, differentiated only by read-only vs. non-SELECT operations, which might not be immediately obvious to an agent.
All tool names follow a consistent verb_noun pattern (e.g., create_table, delete_data, execute_sql), with no mixing of conventions. This predictability makes it easy for agents to understand and use the tool set.
With 6 tools, this server is well-scoped for basic MySQL database operations. Each tool serves a clear purpose (e.g., table creation, data manipulation, query execution), and the count is appropriate for covering core functionalities without being overwhelming.
The tool set provides good coverage for basic CRUD operations (create, read, update, delete) and table management. However, there are minor gaps, such as missing tools for listing tables or databases, which could limit agents in exploratory tasks, though core workflows are still supported.
Related MCP Connectors
Hosted MySQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.5329 npmMIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through a standardized interface, providing tools for querying, executing commands, and managing database schemas.7MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.3-
- AlicenseBqualityDmaintenanceA server based on Model Context Protocol that enables AI models to interact with MySQL databases through a standardized interface, supporting features like query execution, table listing, and automated connection management.422 npm10MIT