elasticsearch-mcp
elasticsearch-mcp
Elasticsearch 用 MCP サーバー。REST API に直接構築されており(elasticsearch-py 非依存)、OpenSearch や HTTP のみを公開するマネージドクラスタでも動作します。
検索・診断・マッピング・クラスタ運用をカバーする 21 個のツールを提供します。デフォルトでは読み取り専用で、書き込み経路はすべて制御されています。
インストール
git clone <your-repo> elasticsearch-mcp && cd elasticsearch-mcp
uv sync # or: pip install -e ".[dev]"
cp .env.example .env
pytest -qRelated MCP server: OpenSearch MCP Server
Claude Code / Claude Desktop に登録する
{
"mcpServers": {
"elasticsearch": {
"command": "uv",
"args": ["--directory", "/abs/path/elasticsearch-mcp", "run", "elasticsearch-mcp"],
"env": {
"ES_MCP_HOSTS": "https://es.internal:9200",
"ES_MCP_API_KEY": "base64-encoded-api-key",
"ES_MCP_INDEX_ALLOW": "logs-*,metrics-*",
"ES_MCP_READ_ONLY": "true"
}
}
}
}stdio の代わりにリモート / 共有デプロイする場合:
elasticsearch-mcp --transport streamable-httpツール
検索
ツール | 機能 |
| Query DSL を実行。サイズ上限付き、タイムアウト挿入、深いページング拒否、 |
| 構造化された仕様を有効な DSL にして、インデックスに対して検証。フィールドカタログを返す |
|
|
| ヒットを取得せずに一致数をカウント |
診断
ツール | 機能 |
| ステータス、シャード数、保留タスク、ノードごとのヒープ / ディスク / CPU / 拒否(任意) |
| インデックスごとのドキュメント数、ストア、セグメント、平均クエリ / インデックスレイテンシ、マージ |
|
|
| 平均クエリレイテンシでランクされたインデックス、実行中の検索タスク、スレッドプール拒否、スローログしきい値 |
マッピング
ツール | 機能 |
| ドキュメント数とサイズを含むインデックスとエイリアス一覧 |
| マルチフィールドを含む |
| ヒット 0 件の match クエリをデバックするための分析器のトークン出力 |
| 後付けのマッピング変更(書き込みゲート付き) |
運用
ツール | 機能 |
| スナップショットの一覧と進捗 |
| 選択したインデックスをスナップショット化(既定は非同期) |
| リストア。既存のオープン インデックスに対する事前チェックとリネーム対応 |
| クエリ、パイプライン、スクリプト、コーリングスライシング、スロットリングに対応する非同期リインデックス。タスク ID を返す |
| 長時間実行タスクのポーリングまたは停止 |
| バージョン、ディストリビューション、アクティブなセーフティポリシー |
設定
すべての変数は ES_MCP_ プレフィックスを使用し、環境変数または .env から読み取ります。
変数 | 既定値 | 用途 |
|
| カンマ区切り。それらへのアクセス断たれ対策のフェイルオーバー |
| – | 認証方式を 1 つ選択 |
|
| TLS |
|
| 429/502/503/504 と接続エラーを対象にするリトライ。乱数バックオフと |
|
| すべての書き込みツールの制御スイッチ |
|
| restore、reindex、 |
|
| グロブ許可リスト |
|
| グロブ拒否リスト。拒否が優先 |
|
| ヒット数の上限 |
|
| バケット爆発を拒否 |
|
| クエリごとのガード |
|
| トークン量の制御 |
| 未設定 | すべてのツール呼び出しと結果の JSONL 記録 |
|
| ログは stderr へ出力し、stdout には出力しない(stdio に渡す運用) |
セーフティモデル
独立した 4 つの階層がすべてフェイルクローズします。
インデックスポリシー — 呼び出しごとに許可リストと拒否リストをチェックし、拒否は優先。クラスタ全体へのワイルドカード書き込みは拒否。
読み取り専用 — 変更系ツールは
READ_ONLY=falseでない限り拒否させる。破壊的操作ゲート — restore、reindex、
put\_mappingでは、さらにALLOW_DESTRUCTIVE=trueと呼び出し内の明示的なconfirm=trueが必要。クエリ制限 — サイズ上限、バケット上限、集計ネスト深さ上限、深いページング拒否、タイムアウト強制注入。
ツールは実行構無しに読み取り可能なテキスト(ERROR (run_query): ...)でエラーを返すため、モデルは停止せずに自己修正できます。
推奨本番構成:許可済みインデックスに対して read を持つ専用 ES API キーと READ_ONLY=true を設定し、アシスタントから reindex / restore をどうしても呼び出す場合にのみ、書き込み可能な別インスタンスを用意してください。
拡張
src/es_mcp/tools/ 配下にモジュールを追加し、register(server, ctx) を公開して server.build_server に配線します。ポリシーチェックには ctx.guard を、出力には ctx.render を使うと、制限が自動的に適用されます。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityCmaintenanceAn MCP server that enables interaction with Elasticsearch and OpenSearch clusters for searching documents and managing indices. It provides tools for cluster health monitoring, index configuration, and general API requests.16Apache 2.0
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to interact with OpenSearch clusters to monitor cluster health, manage indices, and perform data searches. It provides a standardized interface for real-time OpenSearch operations within MCP-compatible environments like Open WebUI.
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to interact with OpenSearch clusters for searching indices, retrieving mappings, and managing shards through the MCP protocol.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceRead-only MCP server for exploring and searching OpenSearch clusters, enabling log analysis, index exploration, and query execution.MIT
Related MCP Connectors
Search, document and execute authenticated API calls across 700+ apps via one MCP server
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Read-only Remote MCP for externally grounded AI agent trust receipts.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/baburajr/elasticsearch_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server