Skip to main content
Glama
mcp-mysql-server

mcp-mysql-server

by f4ww4z

@f4ww4z/mcp-mysql-server

鍛冶屋のバッジ

MySQLデータベース操作を提供するモデルコンテキストプロトコルサーバー。このサーバーにより、AIモデルは標準化されたインターフェースを介してMySQLデータベースと対話できるようになります。

インストール

Smithery経由でインストール

Smithery経由で Claude Desktop 用の MySQL Server を自動的にインストールするには:

npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude

手動インストール

npx @f4ww4z/mcp-mysql-server

Related MCP server: MCP MySQL Server

構成

サーバーでは、MCP 設定構成ファイルに次の環境変数を設定する必要があります。

推奨用途

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@f4ww4z/mcp-mysql-server", "mysql://user:password@localhost:port/database"],
    }
  }
}
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@f4ww4z/mcp-mysql-server"],
      "env": {
        "MYSQL_HOST": "your_host",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

評価の実行

evalsパッケージはmcpクライアントをロードし、index.tsファイルを実行するため、テスト間でリビルドする必要はありません。npxコマンドの先頭に環境変数をロードすることもできます。完全なドキュメントはこちらでご覧いただけます。

OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts src/index.ts

利用可能なツール

1. connect_db

提供された資格情報を使用して MySQL データベースへの接続を確立します。

use_mcp_tool({
  server_name: "mysql",
  tool_name: "connect_db",
  arguments: {
    host: "localhost",
    user: "your_user",
    password: "your_password",
    database: "your_database"
  }
});

2. クエリ

オプションの準備されたステートメント パラメータを使用して SELECT クエリを実行します。

use_mcp_tool({
  server_name: "mysql",
  tool_name: "query",
  arguments: {
    sql: "SELECT * FROM users WHERE id = ?",
    params: [1]
  }
});

3. 実行する

オプションの準備されたステートメント パラメータを使用して、INSERT、UPDATE、または DELETE クエリを実行します。

use_mcp_tool({
  server_name: "mysql",
  tool_name: "execute",
  arguments: {
    sql: "INSERT INTO users (name, email) VALUES (?, ?)",
    params: ["John Doe", "john@example.com"]
  }
});

4. list_tables

接続されたデータベース内のすべてのテーブルを一覧表示します。

use_mcp_tool({
  server_name: "mysql",
  tool_name: "list_tables",
  arguments: {}
});

5. テーブルの説明

特定のテーブルの構造を取得します。

use_mcp_tool({
  server_name: "mysql",
  tool_name: "describe_table",
  arguments: {
    table: "users"
  }
});

特徴

  • 自動クリーンアップによる安全な接続処理

  • クエリパラメータの準備済みステートメントのサポート

  • 包括的なエラー処理と検証

  • TypeScriptサポート

  • 自動接続管理

安全

  • SQLインジェクションを防ぐために準備されたステートメントを使用する

  • 環境変数による安全なパスワード処理をサポート

  • 実行前にクエリを検証します

  • 完了すると自動的に接続が閉じられます

エラー処理

サーバーは、一般的な問題に関する詳細なエラー メッセージを提供します。

  • 接続失敗

  • 無効なクエリ

  • パラメータが不足しています

  • データベースエラー

貢献

貢献を歓迎します!お気軽にhttps://github.com/f4ww4z/mcp-mysql-serverにプルリクエストを送信してください。

ライセンス

マサチューセッツ工科大学

Available Tools

4 tools
describe_tableB

Get table structure

Inputs: table (required).

executeB

Execute an INSERT, UPDATE, or DELETE query

Inputs: sql (required), params.

list_tablesB

List all tables in the database

Inputs: no named parameters.

queryB

Execute a SELECT query

Inputs: sql (required), params.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool serves a distinct purpose: describe_table shows schema, execute handles writes, list_tables lists tables, and query handles reads. No overlap or ambiguity.

    Naming Consistency2/5

    Naming is inconsistent: 'describe_table' and 'list_tables' follow verb_noun, while 'execute' is a bare verb and 'query' is a noun. No uniform pattern.

    Tool Count4/5

    Four tools is reasonable for basic database operations, covering schema inspection, reads, and writes. Could be slightly expanded, but not under- or over-scoped.

    Completeness3/5

    Covers essential CRUD and schema listing, but misses DDL operations like create/alter/drop table, which are common needs. Notable gap for schema modification.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A server that enables AI models to interact with MySQL databases through a Model Control Protocol, providing tools for table creation, schema inspection, query execution, and data retrieval.
      28
      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
      290 npm
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A 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.
      7
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A 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
      -