MySQL Queryのロゴ

MySQL Query

コミュニティ
devakone

MySQL Query MCP server for AI assistants - execute read-only MySQL queries

公開者devakone
リポジトリmysql-query-mcp-server
言語TypeScript
フォーク
2
スター
13
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    MySQL Queryは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには13件のスターと2件のフォークがあります。

MySQL Query MCP Server

npm version License: MIT

A Model Context Protocol (MCP) server that provides read-only MySQL database queries for AI assistants. Execute queries, explore database structures, and investigate your data directly from your AI-powered tools.

Supported AI Tools

This MCP server works with any tool that supports the Model Context Protocol, including:

  • Cursor IDE: Set up in .cursor/mcp.json
  • Anthropic Claude: Use with a compatible MCP client
  • Other MCP-compatible AI assistants: Follow the tool's MCP configuration instructions

Features & Limitations

What It Does

  • ✅ Execute read-only MySQL queries (SELECT, SHOW, DESCRIBE only)
  • ✅ Work with predefined environments (local, development, staging, production)
  • ✅ Provide database information and metadata
  • ✅ List available database environments
  • ✅ Support SSL connections for secure database access
  • ✅ Implement query timeouts to prevent long-running operations

What It Doesn't Do

  • ❌ Execute write operations (INSERT, UPDATE, DELETE, CREATE, ALTER, etc.)
  • ❌ Support custom environment names (limited to local, development, staging, production)
  • ❌ Provide database design or schema generation capabilities
  • ❌ Function as a full database management tool

This tool is designed specifically for data investigation and exploration through read-only queries. It is not intended for database administration, schema management, or data modification.

MySQL Query MCP Demo

Quick Install

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

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

Setup Instructions

Configure Your AI Tool to Use the MCP Server

Create or edit your MCP configuration file (e.g., .cursor/mcp.json for Cursor IDE):

Basic Configuration:

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

Comprehensive Configuration with Database Credentials:

json
{
  "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_TIMEZONE": "Z"
    }
  }
}

Choosing the Right Configuration Approach

There are two ways to configure the MySQL MCP server:

  1. Binary Configuration (type: "bin", bin: "mysql-query-mcp")

    • When to use: When you've installed the package globally (npm install -g mysql-query-mcp-server)
    • Pros: Simpler configuration
    • Cons: Requires global installation
  2. Command Configuration (command: "npx", args: ["mysql-query-mcp-server@latest"])

    • When to use: When you want to use the latest version without installing it globally
    • Pros: No global installation required, all configuration in one file
    • Cons: More complex configuration

Choose the approach that best fits your workflow. Both methods will work correctly with any AI assistant that supports MCP.

Important Configuration Notes

  • You must use the full environment names: LOCAL_, DEVELOPMENT_, STAGING_, PRODUCTION_
  • Abbreviations like DEV_ or PROD_ will not work
  • Global settings like DEBUG, MCP_MYSQL_SSL apply to all environments
  • At least one environment (typically "local") must be configured
  • You only need to configure the environments you plan to use
  • For security reasons, consider using environment variables or secure credential storage for production credentials
  • DATETIME, DATE, and TIMESTAMP columns are returned as strings to preserve the exact value stored in MySQL without host timezone shifting

Configuration Options

Environment VariableDescriptionDefault
DEBUGEnable debug loggingfalse
[ENV]_DB_HOSTDatabase host for environment-
[ENV]_DB_USERDatabase username-
[ENV]_DB_PASSDatabase password-
[ENV]_DB_NAMEDatabase name-
[ENV]_DB_PORTDatabase port3306
[ENV]_DB_SSLEnable SSL connectionfalse
MCP_MYSQL_SSLEnable SSL for all connectionsfalse
MCP_MYSQL_REJECT_UNAUTHORIZEDVerify SSL certificatestrue
MYSQL_TIMEZONETimezone mysql2 uses when sending JavaScript Date values in queriesZ

Date and Time Values

MySQL DATETIME, DATE, and TIMESTAMP columns are returned as raw strings, for example 2026-05-13 16:12:08. This preserves the exact stored value and prevents the Node host timezone from shifting results during JSON serialization.

MYSQL_TIMEZONE defaults to Z (UTC). Override it only if your application intentionally sends JavaScript Date objects to MySQL using a different connection timezone.

Callers that already handle date/time values as strings do not need to change. Callers that previously expected JavaScript Date objects from this MCP server should parse the returned string explicitly.

Integration with AI Assistants

Your AI assistant can interact with MySQL databases through the MCP server. Here are some examples:

Example queries:

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?

Using MySQL MCP Tools

The MySQL Query MCP server provides three main tools that your AI assistant can use:

1. query

Execute read-only SQL queries against a specific environment:

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

2. info

Get detailed information about your database:

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

3. environments

List all configured environments from your configuration:

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

Available Tools

The MySQL Query MCP server provides three main tools:

1. query

Execute read-only SQL queries:

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

Supported query types (strictly limited to):

  • SELECT statements
  • SHOW commands
  • DESCRIBE/DESC tables

2. info

Get detailed information about your database:

  • Server version
  • Connection status and uptime
  • Selected server variables (character set, timezone, timeouts, connection limits)
  • Connection counters (threads connected, threads running, query counts)
  • Available databases

The full SHOW VARIABLES output and the server process list are deliberately not reported. See SECURITY.md.

3. environments

List all configured environments from your configuration:

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

Security Considerations

  • ✅ Only read-only queries are allowed (SELECT, SHOW, DESCRIBE)
  • ✅ Each environment has its own isolated connection pool
  • ✅ SSL connections are supported for production environments
  • ✅ Query timeouts prevent runaway operations
  • ✅ Tool responses never include configuration values, and are checked for secrets before being returned
  • ⚠️ Credentials are still configured as plaintext environment variables in your MCP client config. Keep that file out of version control

If you used a version before 1.3.0

Versions up to and including 1.2.2 returned database credentials in the environments tool response, which means they could have been written into an AI chat transcript. Rotate any credential you configured through this server. Details are in SECURITY.md.

Troubleshooting

Connection Issues

If you're having trouble connecting:

  1. Verify your database credentials in your MCP configuration
  2. Ensure the MySQL server is running and accessible
  3. Check for firewall rules blocking connections
  4. Enable debug mode by setting DEBUG=true in your configuration

Common Errors

Error: No connection pool available for environment

  • Make sure you've defined all required environment variables for that environment
  • Check that you're using one of the supported environment names (local, development, staging, production)

Error: Query execution failed

  • Verify your SQL syntax
  • Check that you're only using supported query types (SELECT, SHOW, DESCRIBE)
  • Ensure your query is truly read-only

For more comprehensive troubleshooting, see the Troubleshooting Guide.

For examples of how to integrate with AI assistants, see the Integration Examples.

For implementation details about the MCP protocol, see the MCP README.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

CI/CD and Release Process

This project uses GitHub Actions for continuous integration and automated releases.

CI/CD Workflow

The CI/CD pipeline consists of:

  1. Build and Test: Runs on every push to main and develop branches, and on pull requests to these branches

    • Tests the codebase with Node.js 16.x and 18.x
    • Ensures the package builds correctly
    • Validates all tests pass
  2. Release: Runs when changes are pushed to the main branch and the build/test job succeeds

    • Uses release-please to manage version bumps and changelog updates
    • Creates a release PR with version changes based on conventional commits
    • Automatically publishes to npm when a release PR is merged

Release Process

The project follows Semantic Versioning:

  • Major version: Breaking changes (non-backward compatible)
  • Minor version: New features (backward compatible)
  • Patch version: Bug fixes and minor improvements

Commits should follow the Conventional Commits format:

  • feat: add new feature - Minor version bump
  • fix: resolve bug - Patch version bump
  • docs: update documentation - No version bump
  • chore: update dependencies - No version bump
  • BREAKING CHANGE: change API - Major version bump

When you push to main, release-please will analyze commits and automatically create or update a release PR with appropriate version bumps and changelog entries.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Abou Koné - Engineering Leader and CTO


For more information or support, please open an issue on the GitHub repository.

インストール

TypingMind
前提条件:

Node.js 18+

$30

MySQL QueryのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度MySQL Queryに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

MySQL Queryをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. MySQL QueryのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "mysql-query": {
      "command": "npx",
      "args": [
        "-y",
        "mysql-query-mcp-server"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてMySQL QueryのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. MySQL QueryのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
MySQL Queryを使ってこのタスクを手伝ってもらえますか?
MySQL Query
はい、読みました。
MySQL Queryで調べた結果をお伝えします。

よくある質問

MySQL Query MCPサーバーは何に使いますか?

MySQL Queryは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでMySQL Query MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでMySQL Queryを利用できます。

TypingMindでMySQL Query MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。MySQL Queryを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

MySQL Query MCPをTypingMindに接続するにはどうすればよいですか?

MySQL QueryはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでMySQL Query MCPのどのようなツールを利用できますか?

MySQL QueryはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

MySQL Query MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。MySQL Queryで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇