
Elasticsearch
io.github.TocharianOU由 GitHub 帳號 TocharianOU 發布v0.9.1更新於 Oct 24, 2026
Elasticsearch MCP Server for ES 5.x-9.x with a query harness, field validation and full API access
概覽
一個本機 MCP 伺服器,讓助理連線 Elasticsearch 叢集,進行搜尋、欄位查詢、索引檢查以及以安全為重點的日誌分析。
- 可以做什麼
- 列出索引與資料流,檢視欄位對應與分片健康狀態,支援 5.x 至 9.x 版本。執行完整的 Query DSL 搜尋與 ES|QL 管道查詢,並自動驗證與修正欄位。將 ECS 詞彙與索引實際對應交叉比對,找出真實欄位名稱。直接呼叫任意 Elasticsearch REST 端點,包括寫入與刪除方法。結果依 token 上限回傳,附上醒目提示與摘要,方便長時間排查。
- 適用情境
- 適合讓助理以自然語言查詢 Elasticsearch 叢集,尤其是安全分析、威脅獵捕、事件調查或日誌探索,也適合希望在查詢執行前依真實欄位名稱驗證的情境。
- 執行需求
- 透過 npm 套件 @tocharianou/elasticsearch-mcp 在本機執行,需要 Node 18 以上版本,也可使用發行壓縮檔。需要 Elasticsearch 執行個體網址(ES_URL)與憑證:ES_API_KEY 中的 API 金鑰,或 ES_USERNAME 與 ES_PASSWORD 的使用者名稱密碼。可選 ES_CA_CERT 用於自訂 TLS,以及 MCP_TRANSPORT、MCP_HTTP_HOST、MCP_HTTP_PORT 用於 HTTP 模式。需要能連線該叢集的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Elasticsearch,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Elasticsearch MCP Server
[npm version] [Downloads] [Ask DeepWiki]
Enhanced Elasticsearch MCP Server Solution - Security & Threat Analysis Focused
This is a professional security-focused solution maintained by TocharianOU. It enables comprehensive interaction with all Elasticsearch APIs, specifically optimized for security analysis, threat detection, and incident investigation. Features include advanced security monitoring, anomaly detection, threat hunting, root cause analysis, and comprehensive audit capabilities.
Key Security Features:
- Real-time threat detection and security monitoring
- Advanced machine learning for anomaly detection
- Root cause analysis and attack chain tracking
- Security incident investigation and forensics
- Compliance monitoring and audit reporting
Note: This solution is designed for security professionals, SOC teams, and threat analysts.
Connect to your Elasticsearch data directly from any MCP Client (such as Claude Desktop) using the Model Context Protocol (MCP). Interact with your Elasticsearch security data through natural language queries for advanced threat analysis and incident response.
Prerequisites
- An Elasticsearch instance
- Elasticsearch authentication credentials (API key or username/password)
- MCP Client (e.g. Claude Desktop) or HTTP client for remote access
Multi-Version Elasticsearch Support
Automatically supports Elasticsearch 5.x - 9.x with intelligent version detection:
Key Features:
- Automatic version detection - No manual configuration needed
- Smart client selection - Loads the right client for your ES version
- Adaptive features - Disables unsupported tools (e.g., Data Streams on ES < 7.9, ES|QL on ES < 8.11)
- Version-specific optimizations - Handles API differences transparently
What happens:
The Query Harness (v0.9.0)
Since v0.9.0 the server ships a query harness: a deterministic layer between the AI model and your cluster. The design philosophy is simple:
The model steers; the harness knows. Intent ("find failed logins by user") belongs to the model. Correctness (real field names, aggregatability, version quirks) belongs to the harness.
What this means in practice — at the level of principles, not internals:
- Live truth beats bundled knowledge beats model memory. Every query is checked against the cluster's actual field capabilities before it runs. A bundled ECS (Elastic Common Schema) vocabulary provides meaning; the live cluster provides existence. The model's own recollection is never trusted.
- Unambiguous mistakes are fixed silently; ambiguous ones become guidance.
The classic example: a spurious
.keywordsuffix on modern ECS mappings is auto-corrected (and the correction is reported); an unknown field blocks the doomed query and returns the nearest real fields instead of a provider error. - Field knowledge stays out of the context window. The full ECS dictionary
(thousands of fields) lives in process memory. The model retrieves only the
handful it needs, on demand, via
lookup_fields. - Every failure must be actionable. Raw Elasticsearch errors are rewritten with live suggestions and index-naming advice (data stream vs. legacy Beats naming, internal indices that should be accessed via Kibana APIs, and so on).
- The model needs zero version knowledge. Naming eras, API differences and
mapping-style differences (legacy
text+.keywordsubfield vs. modern barekeyword) are absorbed entirely by the harness. The same model behaves identically against ES 5.6 and ES 9.x — verified by a version test matrix covering nine watershed releases (5.6 → 9.0). - An escape hatch always exists. Validation can be bypassed per call
(
skip_lint) when the model knows better — e.g. runtime fields defined outside the query. The harness assists; it never imprisons.
SSL/TLS Connection
To connect to Elasticsearch with a self-signed certificate or in a test environment, you can set the following environment variable:
⚠️ This disables Node.js SSL certificate validation. Use only in development or testing environments. For production, always use a trusted CA certificate.
Installation & Setup
Install (or run) the server, point it at your cluster via environment variables, register it in your MCP client, then just start a conversation — the server connects and registers the tools your ES version supports.
Configuration Options
The Elasticsearch MCP Server supports the following configuration options:
Elasticsearch Configuration
Transport Mode Configuration (NEW in v0.3.0)
Transport Mode Details:
- Stdio mode (default): For Claude Desktop and local MCP clients
- HTTP Streamable mode: Runs as a standalone HTTP server for remote access, API integration, and web applications
Quick Start
Option 1: NPM Installation (Recommended)
-
Install globally via NPM
-
Run directly
Option 2: GitHub Release (Standalone Package)
-
Download release package
- Go to GitHub Releases
- Download the latest
.tar.gzfile and its checksum files (.sha256and.sha512)
-
Verify package integrity
-
Extract and use
Option 3: Source Installation
-
Clone the repository
-
Install Dependencies
-
Build the Project
-
Configure Claude Desktop App
- Open Claude Desktop App
- Go to Settings > Developer > MCP Servers
- Click
Edit Configand add a new MCP Server with the following configuration:
For NPM Installation:
For Source Installation:
-
Debugging with MCP Inspector (optional)
Installation & Integration Notes
If npm install -g misbehaves:
- Permission errors (
EACCES) on global install — don'tsudo. Either skip the global install entirely and let your MCP client runnpx @tocharianou/elasticsearch-mcp(npx fetches on demand), or set a user-level prefix:npm config set prefix ~/.npm-globaland add it to yourPATH. - Slow or blocked registry — use a mirror for the install only:
npm install -g @tocharianou/elasticsearch-mcp --registry=https://registry.npmmirror.com. - Node version — requires Node 18+ (
node --version). Older Node fails at startup with ESM/fetch errors, not at install time. npxcold start — the firstnpxrun downloads the package; if your MCP client times out on first connect, runnpx @tocharianou/elasticsearch-mcponce in a terminal to warm the cache, then reconnect.- Fully offline hosts — use the GitHub Release tarball (Option 2) and point
your client at
node /path/to/dist/index.js; nothing is fetched at runtime.
Claude Desktop — Settings → Developer → MCP Servers → Edit Config, then add the JSON block shown above. Restart the app after editing; the server appears in the tools list of a new conversation.
Claude Code (CLI) — register the server per-project or globally:
Any other MCP client / platform integration — run in HTTP mode
(MCP_TRANSPORT=http, see below) and point the client at http://host:port/mcp;
this is the recommended shape for containerized platforms, one server instance
per cluster connection.
Credentials hygiene — the env vars end up in your client's config file in plain text. Prefer a scoped, read-only API key (see Elasticsearch Access Control below) over superuser credentials.
Method 3: HTTP Streamable Mode (NEW in v0.3.0)
Run the server as a standalone HTTP service for remote access and API integration:
HTTP Streamable Mode Features:
- Exposes MCP server at
http://host:port/mcpendpoint - Health check available at
http://host:port/health - Session-based connection management
- Supports both POST (JSON-RPC requests) and GET (SSE streams)
- Compatible with any HTTP client or MCP SDK
Any MCP-capable client (or plain JSON-RPC over HTTP) can talk to the /mcp
endpoint: initialize once, keep the returned mcp-session-id header on
subsequent tools/list / tools/call requests. Use /health for liveness
checks.
Available Tools
Tools not supported by your cluster version are automatically skipped at startup.
es_searchandesql_queryacceptskip_lint: trueto bypass the harness validation for edge cases (e.g. runtime fields defined outside the query).
ES|QL Query Tool (esql_query)
ES|QL is Elasticsearch's modern pipe-based query language, ideal for analytics and data exploration without complex JSON DSL.
Example queries:
Parameters:
query— the ES|QL string (required)params— positional parameters replacing?placeholders (optional)include_types— include column type info in output (optional, defaultfalse)break_token_rule— bypass token limit for large results (optional, defaultfalse)skip_lint— bypass harness field validation (optional, defaultfalse)
Automatically registered only on ES 8.11+ clusters.
Contributing
We welcome contributions from the community! For details on how to contribute, please see Contributing Guidelines.
How It Works
- The MCP client (the AI model) decides what to look for and calls a tool.
- The harness validates the request against the live cluster — fixing what is unambiguous, blocking what would fail, and translating errors into guidance.
- Results come back token-bounded and pre-digested (highlights, tables, aggregation summaries), so long investigations stay within context limits.
Security Analysis Examples
[!TIP] Here are security-focused queries you can try with your MCP Client.
Threat Detection:
- "Analyze brute force attack attempts in the past 24 hours"
- "Detect abnormal login behavior and suspicious IP addresses in the system"
- "Identify potential SQL injection attack patterns and malicious requests"
- "Discover DDoS attack signatures and traffic anomalies in network flows"
Root Cause Analysis:
- "Trace the complete attack chain and impact scope for specific security incidents"
- "Analyze root causes and propagation paths of system failures"
- "Identify data breach sources and involved sensitive information"
- "Investigate user privilege abuse incidents with timeline and operation records"
Threat Intelligence:
- "Create machine learning models to detect zero-day attacks and unknown threats"
- "Establish behavioral baselines and identify activities deviating from normal patterns"
- "Analyze threat levels and attack history of malicious domains and IP addresses"
- "Detect behavioral characteristics and attack patterns of Advanced Persistent Threats (APT)"
Real-time Monitoring:
- "Monitor active threats and ongoing attacks in the current system"
- "Detect abnormal data access patterns and privilege escalation behaviors"
- "Discover suspicious network communications and data exfiltration activities"
- "Identify security causes of abnormal system resource consumption and performance degradation"
Security Best Practices
[!WARNING] Avoid using cluster-admin privileges. Create dedicated API keys with limited scope and apply fine-grained access control at the index level to prevent unauthorized data access.
Package Integrity Verification
When downloading release packages, always verify checksums to ensure integrity:
This protects against:
- Corrupted downloads
- Tampered packages
- Man-in-the-middle attacks
Elasticsearch Access Control
You can create a dedicated Elasticsearch API key with minimal permissions to control access to your data:
License
This project is licensed under the Apache License 2.0.
Troubleshooting
- Ensure your MCP configuration is correct.
- Verify that your Elasticsearch URL is accessible from your machine.
- Check that your authentication credentials (API key or username/password) have the necessary permissions.
- If using SSL/TLS with a custom CA, verify that the certificate path is correct and the file is readable.
- Look at the terminal output for error messages.
If you encounter issues, feel free to open an issue on the GitHub repository.
來源:README.md,提交 1809fb9
工具
0版本歷史
2- v0.9.1最新Oct 11, 2026
- v0.7.2Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分