Skip to main content
Glama
devakone

MySQL Query MCP Server

by devakone

MySQLクエリMCPサーバー

npmバージョン ライセンス: MIT

AIアシスタント向けに読み取り専用のMySQLデータベースクエリを提供するモデルコンテキストプロトコル(MCP)サーバー。AI搭載ツールから直接クエリを実行し、データベース構造を探索し、データを調査できます。

サポートされているAIツール

この MCP サーバーは、次のようなモデル コンテキスト プロトコルをサポートする任意のツールで動作します。

  • カーソルIDE : .cursor/mcp.jsonで設定

  • アントロピック・クロード:互換性のあるMCPクライアントで使用

  • その他のMCP対応AIアシスタント: ツールのMCP設定手順に従ってください

Related MCP server: MCP Server for MySQL

機能と制限

何をするのか

  • 読み取り専用のMySQL クエリを実行する (SELECT、SHOW、DESCRIBE のみ)

  • ✅ 定義済みの環境(ローカル、開発、ステージング、本番)で作業する

  • ✅ データベース情報とメタデータを提供する

  • ✅ 利用可能なデータベース環境を一覧表示する

  • ✅ 安全なデータベースアクセスのための SSL 接続をサポート

  • ✅ 長時間実行される操作を防ぐためにクエリタイムアウトを実装する

できないこと

  • ❌ 書き込み操作 (INSERT、UPDATE、DELETE、CREATE、ALTER など) を実行する

  • ❌ カスタム環境名をサポート(ローカル、開発、ステージング、本番環境に限定)

  • ❌ データベース設計またはスキーマ生成機能を提供する

  • ❌ 完全なデータベース管理ツールとして機能する

このツールは、読み取り専用クエリによるデータの調査と探索を目的として特別に設計されています。データベース管理、スキーマ管理、データ変更を目的としたものではありません。

MySQLクエリMCPデモ

クイックインストール

# Install globally with npm
npm install -g mysql-query-mcp-server

# Or run directly with npx
npx mysql-query-mcp-server

セットアップ手順

MCP サーバーを使用するように AI ツールを構成する

MCP 構成ファイル (例: Cursor IDE の場合は.cursor/mcp.json ) を作成または編集します。

基本構成:

{
  "mysql": {
    "name": "MySQL Query MCP",
    "description": "MySQL read-only query access through MCP",
    "type": "bin", 
    "enabled": true,
    "bin": "mysql-query-mcp"
  }
}

データベース資格情報を使用した包括的な構成:

{
  "mysql": {
    "command": "npx",
    "args": ["mysql-query-mcp-server@latest"],
    "env": {
      "LOCAL_DB_HOST": "localhost",
      "LOCAL_DB_USER": "root",
      "LOCAL_DB_PASS": "<YOUR_LOCAL_DB_PASSWORD>",
      "LOCAL_DB_NAME": "your_database",
      "LOCAL_DB_PORT": "3306",
      
      "DEVELOPMENT_DB_HOST": "dev.example.com",
      "DEVELOPMENT_DB_USER": "<DEV_USER>",
      "DEVELOPMENT_DB_PASS": "<DEV_PASSWORD>",
      "DEVELOPMENT_DB_NAME": "your_database",
      "DEVELOPMENT_DB_PORT": "3306",
      
      "STAGING_DB_HOST": "staging.example.com",
      "STAGING_DB_USER": "<STAGING_USER>",
      "STAGING_DB_PASS": "<STAGING_PASSWORD>",
      "STAGING_DB_NAME": "your_database",
      "STAGING_DB_PORT": "3306",
      
      "PRODUCTION_DB_HOST": "prod.example.com",
      "PRODUCTION_DB_USER": "<PRODUCTION_USER>",
      "PRODUCTION_DB_PASS": "<PRODUCTION_PASSWORD>",
      "PRODUCTION_DB_NAME": "your_database",
      "PRODUCTION_DB_PORT": "3306",
      
      "DEBUG": "false",
      "MCP_MYSQL_SSL": "true",
      "MCP_MYSQL_REJECT_UNAUTHORIZED": "false"
    }
  }
}

適切な構成アプローチの選択

MySQL MCP サーバーを構成するには、次の 2 つの方法があります。

  1. バイナリ設定( type: "bin"bin: "mysql-query-mcp" )

    • 使用する場合: パッケージをグローバルにインストールした場合 ( npm install -g mysql-query-mcp-server )

    • 利点: よりシンプルな構成

    • 短所: グローバルインストールが必要

  2. コマンド設定( command: "npx"args: ["mysql-query-mcp-server@latest"] )

    • 使用する場合: グローバルにインストールせずに最新バージョンを使用したい場合

    • 利点: グローバルインストールは不要、すべての構成が 1 つのファイルにまとめられる

    • 短所: より複雑な構成

ワークフローに最適なアプローチを選択してください。どちらの方法も、MCPをサポートするAIアシスタントであれば正常に動作します。

重要な設定に関する注意事項

  • 完全な環境名を使用する必要があります: LOCAL_、DEVELOPMENT_、STAGING_、PRODUCTION_

  • DEV_やPROD_のような略語は機能しません

  • DEBUG、MCP_MYSQL_SSLなどのグローバル設定はすべての環境に適用されます。

  • 少なくとも1つの環境(通常は「ローカル」)を構成する必要があります

  • 使用する予定の環境を設定するだけで済みます

  • セキュリティ上の理由から、本番環境の認証情報には環境変数または安全な認証情報ストレージの使用を検討してください。

設定オプション

環境変数

説明

デフォルト

デバッグ

デバッグログを有効にする

間違い

[ENV]_DB_HOST

環境のデータベースホスト

-

[ENV]_DB_USER

データベースユーザー名

-

[ENV]_DB_PASS

データベースパスワード

-

[ENV]_DB_NAME

データベース名

-

[ENV]_DB_ポート

データベースポート

3306

[ENV]_DB_SSL

SSL接続を有効にする

間違い

MCP_MYSQL_SSL

すべての接続でSSLを有効にする

間違い

MCP_MYSQL_REJECT_UNAUTHORIZED

SSL証明書を検証する

真実

AIアシスタントとの統合

AIアシスタントはMCPサーバーを介してMySQLデータベースと連携できます。以下に例をいくつか示します。

クエリの例:

Can you use the query tool to show me the first 10 users from the database? Use the local environment.
I need to analyze our sales data. Can you run a SQL query to get the total sales per region for last month from the development database?
Can you use the info tool to check what tables are available in the staging database?
Can you list all the available database environments we have configured?

MySQL MCPツールの使用

MySQL Query MCP サーバーは、AI アシスタントが使用できる 3 つの主要なツールを提供します。

1. クエリ

特定の環境に対して読み取り専用の SQL クエリを実行します。

Use the query tool to run:
SELECT * FROM customers WHERE signup_date > '2023-01-01' LIMIT 10;
on the development environment

2. 情報

データベースに関する詳細情報を取得します。

Use the info tool to check the status of our production database.

3. 環境

構成から構成されたすべての環境を一覧表示します。

Use the environments tool to show me which database environments are available.

利用可能なツール

MySQL Query MCP サーバーは、次の 3 つの主要なツールを提供します。

1. クエリ

読み取り専用 SQL クエリを実行します。

-- Example query to run with the query tool
SELECT * FROM users LIMIT 10;

サポートされているクエリタイプ(厳密に限定)

  • SELECT文

  • SHOWコマンド

  • DESCRIBE/DESC テーブル

2. 情報

データベースに関する詳細情報を取得します。

  • サーバーバージョン

  • 接続ステータス

  • データベース変数

  • プロセスリスト

  • 利用可能なデータベース

3. 環境

構成から構成されたすべての環境を一覧表示します。

Use the environments tool to show me which database environments are available.

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

  • ✅ 読み取り専用クエリのみが許可されます (SELECT、SHOW、DESCRIBE)

  • ✅ 各環境には独自の分離された接続プールがあります

  • ✅ SSL接続は本番環境でサポートされています

  • ✅ クエリタイムアウトにより暴走操作を防止

  • ⚠️ データベースの資格情報には安全な資格情報管理の使用を検討してください

トラブルシューティング

接続の問題

接続に問題がある場合:

  1. MCP構成でデータベースの資格情報を確認します

  2. MySQLサーバーが稼働しておりアクセス可能であることを確認する

  3. 接続をブロックするファイアウォールルールを確認する

  4. 設定でDEBUG=trueを設定してデバッグモードを有効にします。

よくあるエラー

エラー: 環境で利用できる接続プールがありません

  • その環境に必要な環境変数がすべて定義されていることを確認してください

  • サポートされている環境名(ローカル、開発、ステージング、本番)のいずれかを使用していることを確認してください。

エラー: クエリの実行に失敗しました

  • SQL構文を確認する

  • サポートされているクエリタイプ(SELECT、SHOW、DESCRIBE)のみを使用していることを確認してください

  • クエリが本当に読み取り専用であることを確認する

より包括的なトラブルシューティングについては、 「トラブルシューティング ガイド」を参照してください。

AI アシスタントとの統合方法の例については、「統合例」を参照してください。

MCP プロトコルの実装の詳細については、 MCP README を参照してください。

貢献

貢献を歓迎します!お気軽にプルリクエストを送信してください。

CI/CDとリリースプロセス

このプロジェクトでは、継続的インテグレーションと自動リリースに GitHub Actions を使用します。

CI/CDワークフロー

CI/CD パイプラインは次の要素で構成されます。

  1. ビルドとテスト: maindevelopブランチへのプッシュごとに、またこれらのブランチへのプルリクエストごとに実行されます。

    • Node.js 16.x および 18.x でコードベースをテストします

    • パッケージが正しくビルドされることを保証する

    • すべてのテストが合格したことを検証する

  2. リリース: 変更がmainブランチにプッシュされ、ビルド/テストジョブが成功したときに実行されます。

    • バージョンアップや変更ログの更新を管理するにはrelease-pleaseを使用します

    • 従来のコミットに基づいてバージョン変更を含むリリース PR を作成します。

    • リリース PR がマージされると自動的に npm に公開されます

リリースプロセス

このプロジェクトはセマンティック バージョニングに従います。

  • メジャーバージョン: 重大な変更 (下位互換性なし)

  • マイナーバージョン: 新機能 (下位互換性あり)

  • パッチバージョン: バグ修正とマイナーな改善

コミットはConventional Commits形式に従う必要があります。

  • feat: add new feature - マイナーバージョンアップ

  • fix: resolve bug - パッチバージョンのアップグレード

  • docs: update documentation - バージョンアップなし

  • chore: update dependencies - バージョンアップなし

  • BREAKING CHANGE: change API - メジャーバージョンのアップグレード

mainにプッシュすると、 release-pleaseコミットを分析し、適切なバージョンのバンプと変更ログエントリを含むリリース PR を自動的に作成または更新します。

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

著者

Abou Koné - エンジニアリングリーダー兼CTO


詳細情報やサポートが必要な場合は、GitHub リポジトリで問題を報告してください。

Available Tools

3 tools
environmentsA

List available MySQL database environments

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description clearly indicates a read-only listing operation with no side effects. With no annotations provided, this straightforward disclosure is sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence with no unnecessary words. It is front-loaded with the action and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, no output schema), the description adequately explains its purpose. It could optionally hint at the format of the list, but not required.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has no parameters, so schema coverage is 100%. The description adds no parameter info, but none is needed; baseline score for zero parameters is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'List' and clearly identifies the resource as 'available MySQL database environments'. It distinguishes from sibling tools 'info' and 'query' by implying this is a listing operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use when the agent needs to see available environments before running queries or getting info, but does not explicitly state when to use or avoid this tool relative to siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

infoC

Get information about MySQL databases

ParametersJSON Schema
NameRequiredDescriptionDefault
environmentYesTarget environment to get information from

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description only implies a read operation ('Get information') without explicit statements about safety or side effects. It fails to disclose any behavioral traits beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, no wasted words, and appropriately sized for a simple tool. It is front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema and the tool's simple nature, the description is too minimal. It does not specify what kind of information is returned or any additional context, leaving the agent underinformed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides 100% coverage with a description for the 'environment' parameter. The tool description adds no additional semantics beyond what is in the schema, earning the baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Get information about MySQL databases,' specifying the verb and resource. However, it does not differentiate from siblings like 'query', which might also retrieve data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'query' or 'environments'. The description does not provide context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

queryA

Execute read-only SQL queries against MySQL databases

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to execute (SELECT and SHOW only)
timeoutNoQuery timeout in milliseconds (default: 30000)
environmentYesTarget environment to run the query against

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description bears full responsibility. It declares read-only behavior but does not elaborate on error handling, authentication, rate limits, or result limits. The constraint 'SELECT and SHOW only' is only in the schema, not the description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no superfluous words. It efficiently conveys the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description lacks details about output format, pagination, or behavior under errors/timeouts. Given no output schema, the agent might need more context. However, for a simple query tool, the description is minimally sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so all parameters have descriptions. The description adds no extra parameter semantics beyond the schema, which is adequate but not additive.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Execute', the resource 'SQL queries', and the context 'against MySQL databases', specifying 'read-only'. This distinguishes it well from its siblings 'environments' and 'info'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implicitly indicates usage for read-only SQL queries but does not explicitly state when to use or avoid it, nor does it mention alternative tools. However, the sibling tools are distinct enough that ambiguity is low.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updates
    • First observedenvironments
    • First observedinfo
    • First observedquery

TDQS

A3.7/5.0
Disambiguation5/5

Each tool serves a distinct purpose: environments lists available databases, info retrieves database metadata, query executes read-only SQL. No overlap in functionality.

Naming Consistency4/5

All tool names are single lowercase words, which is consistent, but they don't follow a strong verb_noun pattern. Names are clear and unambiguous.

Tool Count5/5

Three tools is ideal for a focused MCP server that provides database environment listing, metadata retrieval, and query execution. No unnecessary tools.

Completeness4/5

The tool surface covers the core workflow of exploring and querying databases. Missing explicit schema or table listing tools, but info may partially address this.

Maintenance

ActivityMaintained
ResponsivenessSlow

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    A Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.
    15,085
    2,091
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    A 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.
    5
    342
    MIT

Appeared in Searches

Latest Blog Posts

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/devakone/mysql-query-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server