Elasticsearch MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Provides Elasticsearch interaction allowing users to search documents, analyze indices, and manage clusters through natural language queries

  • Mentions that Kibana is accessible as part of the Elasticsearch cluster setup, though interaction is primarily through the Elasticsearch API

Elasticsearch/OpenSearch MCP サーバー

概要

ElasticsearchとOpenSearchの連携を可能にするModel Context Protocol(MCP)サーバー実装。このサーバーは、ドキュメントの検索、インデックスの分析、そして一連のツールによるクラスター管理を可能にします。

デモ

https://github.com/user-attachments/assets/f7409e31-fac4-4321-9c94-b0ff2ea7ff15

特徴

インデックス操作

  • list_indices : すべてのインデックスを一覧表示します。
  • get_index : 1 つ以上のインデックスに関する情報 (マッピング、設定、エイリアス) を返します。
  • create_index : 新しいインデックスを作成します。
  • delete_index : インデックスを削除します。

ドキュメント操作

  • search_documents : ドキュメントを検索します。
  • index_document : インデックス内のドキュメントを作成または更新します。
  • get_document : ID でドキュメントを取得します。
  • delete_document : ID でドキュメントを削除します。
  • delete_by_query : 指定されたクエリに一致するドキュメントを削除します。

クラスター操作

  • get_cluster_health : クラスターの健全性に関する基本情報を返します。
  • get_cluster_stats : クラスター統計の概要を返します。

エイリアス操作

  • list_aliases : すべてのエイリアスを一覧表示します。
  • get_alias : 特定のインデックスのエイリアス情報を取得します。
  • put_alias : 特定のインデックスのエイリアスを作成または更新します。
  • delete_alias : 特定のインデックスのエイリアスを削除します。

環境変数を設定する

.env.exampleファイルを.envにコピーし、それに応じて値を更新します。

Elasticsearch/OpenSearch クラスターを起動する

Docker Compose を使用して Elasticsearch/OpenSearch クラスターを起動します。

# For Elasticsearch docker-compose -f docker-compose-elasticsearch.yml up -d # For OpenSearch docker-compose -f docker-compose-opensearch.yml up -d

Elasticsearchのデフォルトのユーザー名はelastic 、パスワードはtest123です。OpenSearchのデフォルトのユーザー名はadmin 、パスワードはadminです。

Kibana/OpenSearch ダッシュボードには http://localhost:5601からアクセスできます。

Claude Desktopでの使用

オプション1: Smithery経由でインストールする

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

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

オプション2: uvxを使用する

uvxを使用すると、PyPIからパッケージが自動的にインストールされるため、リポジトリをローカルにクローンする必要はありません。Claude Desktopの設定ファイルclaude_desktop_config.jsonに以下の設定を追加してください。

// For Elasticsearch { "mcpServers": { "elasticsearch-mcp-server": { "command": "uvx", "args": [ "elasticsearch-mcp-server" ], "env": { "ELASTICSEARCH_HOST": "https://localhost:9200", "ELASTICSEARCH_USERNAME": "elastic", "ELASTICSEARCH_PASSWORD": "test123" } } } } // For OpenSearch { "mcpServers": { "opensearch-mcp-server": { "command": "uvx", "args": [ "opensearch-mcp-server" ], "env": { "OPENSEARCH_HOST": "https://localhost:9200", "OPENSEARCH_USERNAME": "admin", "OPENSEARCH_PASSWORD": "admin" } } } }

オプション3: ローカル開発でUVを使用する

uvを使用するには、リポジトリをローカルにクローンし、ソースコードへのパスを指定する必要があります。Claude Desktop の設定ファイルclaude_desktop_config.jsonに以下の設定を追加してください。

// For Elasticsearch { "mcpServers": { "elasticsearch-mcp-server": { "command": "uv", "args": [ "--directory", "path/to/src/elasticsearch_mcp_server", "run", "elasticsearch-mcp-server" ], "env": { "ELASTICSEARCH_HOST": "https://localhost:9200", "ELASTICSEARCH_USERNAME": "elastic", "ELASTICSEARCH_PASSWORD": "test123" } } } } // For OpenSearch { "mcpServers": { "opensearch-mcp-server": { "command": "uv", "args": [ "--directory", "path/to/src/elasticsearch_mcp_server", "run", "opensearch-mcp-server" ], "env": { "OPENSEARCH_HOST": "https://localhost:9200", "OPENSEARCH_USERNAME": "admin", "OPENSEARCH_PASSWORD": "admin" } } } }
  • macOSの場合: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows の場合: %APPDATA%/Claude/claude_desktop_config.json

新しい MCP サーバーをロードするには、Claude Desktop を再起動します。

次のような自然言語コマンドを使用して、Claude を通じて Elasticsearch/OpenSearch クラスターと対話できるようになりました。

  • 「クラスター内のすべてのインデックスを一覧表示する」
  • 「ボブという生徒は何歳ですか?」
  • 「クラスターのヘルスステータスを表示」

Anthropic MCPクライアントでの使用

uv run mcp_client/client.py src/server.py

ライセンス

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

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

モデルコンテキストプロトコル サーバーと自然言語コマンドを介してユーザーがインデックス操作、ドキュメント検索、クラスター管理を実行できるようにすることで、Elasticsearch クラスターとのやり取りを容易にします。

  1. Overview
    1. Demo
      1. Features
        1. Index Operations
        2. Document Operations
        3. Cluster Operations
        4. Alias Operations
      2. Configure Environment Variables
        1. Start Elasticsearch/OpenSearch Cluster
          1. Usage with Claude Desktop
            1. Option 1: Installing via Smithery
            2. Option 2: Using uvx
            3. Option 3: Using uv with local development
          2. Usage with Anthropic MCP Client
            1. License
              ID: b3po3delex