Skip to main content
Glama
Elasticsearch MCP Server

Elasticsearch MCP Server

Official
by elastic

Elasticsearch MCP サーバー

このリポジトリには、研究と評価を目的とした実験的な機能が含まれており、実稼働には対応していません。

モデル コンテキスト プロトコル (MCP) を使用して、任意の MCP クライアント (Claude Desktop など) から Elasticsearch データに直接接続します。

このサーバーは、モデルコンテキストプロトコルを使用してエージェントをElasticsearchデータに接続します。これにより、自然言語による会話を通じてElasticsearchインデックスと対話できるようになります。

利用可能なツール

  • list_indices : 利用可能なすべてのElasticsearchインデックスを一覧表示する

  • get_mappings : 特定のElasticsearchインデックスのフィールドマッピングを取得する

  • search : 提供されたクエリDSLを使用してElasticsearch検索を実行する

  • get_shards : すべてまたは特定のインデックスのシャード情報を取得する

Related MCP server: Elasticsearch MCP Server

前提条件

  • Elasticsearchインスタンス

  • Elasticsearch 認証資格情報 (API キーまたはユーザー名/パスワード)

  • MCP クライアント (例: Claude Desktop)

デモ

https://github.com/user-attachments/assets/5dd292e1-a728-4ca7-8f01-1380d1bebe0c

インストールとセットアップ

公開されたNPMパッケージの使用

[!TIP] Elasticsearch MCP Server を使用する最も簡単な方法は、公開されている npm パッケージを使用することです。

  1. MCPクライアントの設定

    • MCPクライアントを開きます。MCPクライアントのリストを確認し、ここでClaude Desktopを設定します。

    • 設定 > 開発者 > MCP サーバーに移動します

    • Edit Configをクリックし、次の設定で新しい MCP サーバーを追加します。

    {
      "mcpServers": {
        "elasticsearch-mcp-server": {
          "command": "npx",
          "args": [
            "-y",
            "@elastic/mcp-server-elasticsearch"
          ],
          "env": {
            "ES_URL": "your-elasticsearch-url",
            "ES_API_KEY": "your-api-key"
          }
        }
      }
    }
  2. 会話を始める

    • MCPクライアントで新しい会話を開きます

    • MCPサーバーは自動的に接続されます

    • Elasticsearchデータについて質問できるようになりました

設定オプション

Elasticsearch MCP サーバーは、Elasticsearch に接続するための構成オプションをサポートしています。

[!NOTE] 認証には、API キーまたはユーザー名とパスワードの両方を指定する必要があります。

環境変数

説明

必須

ES_URL

ElasticsearchインスタンスのURL

はい

ES_API_KEY

認証用のElasticsearch APIキー

いいえ

ES_USERNAME

基本認証用のElasticsearchユーザー名

いいえ

ES_PASSWORD

基本認証用のElasticsearchパスワード

いいえ

ES_CA_CERT

Elasticsearch SSL/TLS のカスタム CA 証明書へのパス

いいえ

地域開発

[!NOTE] MCP サーバーを変更または拡張する場合は、次のローカル開発手順に従ってください。

  1. 正しいNode.jsバージョンを使用する

    nvm use
  2. 依存関係をインストールする

    npm install
  3. プロジェクトを構築する

    npm run build
  4. Claudeデスクトップアプリでローカルに実行

    • Claudeデスクトップアプリを開く

    • 設定 > 開発者 > MCP サーバーに移動します

    • Edit Configをクリックし、次の設定で新しい MCP サーバーを追加します。

    {
      "mcpServers": {
        "elasticsearch-mcp-server-local": {
          "command": "node",
          "args": [
            "/path/to/your/project/dist/index.js"
          ],
          "env": {
            "ES_URL": "your-elasticsearch-url",
            "ES_API_KEY": "your-api-key"
          }
        }
      }
    }
  5. MCP Inspectorによるデバッグ

    ES_URL=your-elasticsearch-url ES_API_KEY=your-api-key npm run inspector

    MCP Inspectorが起動し、リクエストのデバッグと分析が可能になります。以下の画面が表示されます。

    Starting MCP inspector...
    Proxy server listening on port 3000
    
    🔍 MCP Inspector is up and running at http://localhost:5173 🚀

貢献

コミュニティからの貢献を歓迎します。貢献方法の詳細については、貢献ガイドラインをご覧ください。

例題

[!TIP] MCP クライアントで試すことができる自然言語クエリをいくつか示します。

  • 「Elasticsearch クラスターにはどのようなインデックスがありますか?」

  • 「「製品」インデックスのフィールド マッピングを表示します。」

  • 「先月の 500 ドルを超えるすべての注文を検索します。」

  • 「5 つ星のレビューを最も多く獲得した製品はどれですか?」

仕組み

  1. MCP クライアントはリクエストを分析し、必要な Elasticsearch 操作を決定します。

  2. MCP サーバーはこれらの操作 (インデックスの一覧表示、マッピングの取得、検索の実行) を実行します。

  3. MCP クライアントは結果を処理し、ユーザーフレンドリーな形式で表示します。

セキュリティのベストプラクティス

[!WARNING] クラスター管理者権限の使用は避けてください。スコープを制限した専用のAPIキーを作成し、インデックスレベルできめ細かなアクセス制御を適用して、不正なデータアクセスを防止してください。

データへのアクセスを制御するために、最小限の権限を持つ専用の Elasticsearch API キーを作成できます。

POST /_security/api_key
{
  "name": "es-mcp-server-access",
  "role_descriptors": {
    "mcp_server_role": {
      "cluster": [
        "monitor"
      ],
      "indices": [
        {
          "names": [
            "index-1",
            "index-2",
            "index-pattern-*"
          ],
          "privileges": [
            "read",
            "view_index_metadata"
          ]
        }
      ]
    }
  }
}

ライセンス

このプロジェクトは、Apache License 2.0 に基づいてライセンスされています。

トラブルシューティング

  • MCP 構成が正しいことを確認してください。

  • Elasticsearch URL がマシンからアクセスできることを確認します。

  • 認証資格情報 (API キーまたはユーザー名/パスワード) に必要な権限があることを確認します。

  • カスタム CA で SSL/TLS を使用する場合は、証明書パスが正しいことと、ファイルが読み取り可能であることを確認します。

  • エラー メッセージのターミナル出力を確認します。

問題が発生した場合は、お気軽に GitHub リポジトリで問題を報告してください。

Available Tools

3 tools
get_mappingsB

Get field mappings for a specific Elasticsearch index

Inputs: index (required).

list_indicesB

List all available Elasticsearch indices

Inputs: no named parameters.

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 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: get_mappings retrieves field mappings for a specific index, list_indices enumerates all indices, and search performs query-based searches. There is no overlap in functionality, making tool selection unambiguous.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern (get_mappings, list_indices, search), with clear and descriptive verbs that align with their actions. No deviations or mixed conventions are present.

    Tool Count3/5

    With only 3 tools, the set feels thin for an Elasticsearch server, as it lacks essential operations like creating/deleting indices, updating mappings, or performing CRUD operations on documents. While the tools are well-defined, the count is borderline for the domain's scope.

    Completeness2/5

    There are significant gaps in the tool surface for Elasticsearch functionality. Missing operations include index creation/deletion, document indexing/updating/deleting, and cluster management. This incompleteness will likely cause agent failures when attempting full workflows.

    Maintenance

    ActivityInactive
    ResponsivenessMostly unanswered

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      A
      maintenance
      Facilitates interaction with Elasticsearch clusters by allowing users to perform index operations, document searches, and cluster management via a Model Context Protocol server and natural language commands.
      20
      320
      Apache 2.0
    • A
      license
      B
      quality
      C
      maintenance
      Connects agents to Elasticsearch data using the Model Context Protocol, allowing natural language interaction with Elasticsearch indices through MCP Clients like Claude Desktop and Cursor.
      11
      61 npm
      24
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Connects to Elasticsearch databases using the Model Context Protocol, allowing users to query and interact with their Elasticsearch indices through natural language conversations.
      4
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects agents to Elasticsearch data using the Model Context Protocol, allowing natural language interaction with Elasticsearch indices through tools for listing indices, getting field mappings, performing searches, and viewing shard information.
      Apache 2.0