Token导航 LogoToken导航TokenDH.com
Elasticsearch AI logo
运维云端stdio官方级别未说明来源级核验

Elasticsearch AI

MCP Server

将Elasticsearch集群转化为AI驱动的APM分析平台,提供日志、APM追踪和系统指标的自然语言交互分析,实现深度性能监控和故障排查。

工具数

25

提示词数

0

GitHub Stars

5

资源数

0
PythonClaude日志分析Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

byviz

提供方

byviz

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

🔍 Elasticsearch MCP服务器AI

一个模型上下文协议(MCP)服务器,将Elasticsearch集群转换为AI驱动的可观察性引擎。\ 支持自然语言交互,用于分析日志、APM跟踪(使用瀑布图和RCA)和系统指标 --以最小的努力提供深入的性能和故障排除见解。

💡 Elasticsearch MCP服务器AI演示示例

  • APM瀑布跟踪性能分析演示,如何使用瀑布可视化来分析应用程序跟踪,以获得深入的性能见解。快速识别真实APM数据中的瓶颈、延迟问题和服务依赖关系。

Demo APM RCA

  • 演示RCA APM(根本原因分析),演示如何自动识别APM跟踪中错误和性能问题的根本原因,为快速排除故障提供可操作的见解。

Demo APM RCA

  • 演示通过APM服务执行性能分析,分析和比较每个APM服务的性能指标,确定整个体系结构的延迟、吞吐量和资源瓶颈。

Demo APM RCA

🎯 核心价值:先进的APM分析

此MCP服务器将您的Elasticsearch集群转换为强大的AI驱动的APM分析平台。 关键差异化因素 是我们的 专用APM分析工具 提供基本Elasticsearch查询无法实现的自动化洞察:

🔬 APM瀑布分析 - analyzeTracePerformance

  • 完整的瀑布分析 APM轨迹的可视化时间线重建
  • 自动关联 系统错误和基础设施指标
  • 性能优化建议 基于检测到的模式
  • 深度瓶颈检测 跨微服务和依赖关系
  • 非常适合:延迟调试、性能优化、依赖性分析

🎯 APM根本原因分析(RCA) - findErrorPatterns

  • 时间误差分析 具有自动聚合和模式检测功能
  • 智能根本原因分析 提出具体可行的建议
  • 异常检测 错误频率、类型和服务影响
  • 自动关联 在错误尖峰和系统事件之间
  • 非常适合:主动故障排除、稳定性分析、事故预防

🔗 业务事件关联 - correlateBusinessEvents

  • 完成用户旅程重建 跨越所有系统接触点
  • 交叉指数相关性 (APM+日志+指标+业务事件)
  • 时间线分析 与业务影响评估相关的事件
  • 端到端交易跟踪 从用户操作到系统响应
  • 非常适合:业务影响分析、关键流程调试、客户体验优化
💡 这些工具实现了基本Elasticsearch查询无法实现的专用逻辑,为SRE和DevOps团队提供深入的见解和自动化分析。它们代表了此MCP服务器的核心价值主张。

🎯 这是什么MCP服务器?

此MCP服务器将您的Elasticsearch集群转换为AI助手的强大工具,实现:

  • 🔍 智能搜索 在日志、指标和文档中
  • 📊 APM分析 检测错误和性能问题
  • 🖥️ 系统监控 CPU、内存和磁盘指标
  • 🔧 自动诊断 应用问题

🛠️ 可用工具(25个工具)

🔧 优化的APM工具核心价值

工具说明主要参数
analyzeTracePerformance使用瀑布图和相关性进行完整的性能分析trace_id (必填), include_errors, include_metrics
findErrorPatterns基于时间分析和RCA的错误模式检测time_range, service_name, error_type, min_frequency
correlateBusinessEvents业务事件关联以重建用户旅程correlation_id (必填), time_window, include_user_journey

🔍 搜索和查询

工具说明主要参数
searchAllIndices使用查询字符串在所有索引中搜索文档q (查询), size (极限), from (偏移), sort (订购)
searchDocuments在特定索引中搜索文档index (指数), q (查询), size, from, sort
countDocuments使用可选筛选器全局统计文档q (查询), index (具体指标)
countDocumentsInIndex统计特定索引中的文档index (必填), q (可选查询)
getDocument通过ID获取特定文档index (必填), id (必填), _source (字段)

📊 集群信息

工具说明主要参数
getClusterInfo基本群集信息(名称、版本、UUID)
getClusterHealth具有详细指标的群集运行状况level (集群/索引/分片), wait_for_status, timeout
getClusterStats用于监视的完整群集统计信息
getNodeStats所有节点的统计数据(CPU、内存、磁盘)metric (索引/os/进程/jvm/等)
getHotThreads用于故障排除的活动线程和JVM统计信息metric (JVM度量类型)

🗂️ 索引管理

工具说明主要参数
getCatIndices包含状态信息的紧凑索引列表format (json/yaml/text), v (冗长), h (列), s (排序)
getIndex特定指标的详细信息index (必填)
getMapping索引的字段映射和数据类型index (必填)
getSettings索引的配置和设置index (必填)

🚨 APM和监控

工具说明主要参数
searchAPMData在APM数据中搜索跟踪、交易和跨度q (查询), size, from, sort, _source, timeout
countAPMDocuments统计APM索引中的文档(错误、跟踪、指标)q (筛选查询)
searchAPMErrorsAPM中的搜索错误和异常q (时间查询), size, from, sort, _source, timeout
searchAPMPerformance分析性能指标和慢速事务q (查询), size, from, sort, _source, timeout
searchSystemMetricsMetricbeat的系统指标(CPU、内存、磁盘)q (时间查询), size, from, sort, _source, timeout
searchLogData从Filebeat和其他来源搜索应用程序日志q (查询), size, from, sort, _source, timeout
searchFilebeatLogs专门从Filebeat索引中搜索日志q (高级查询), size, from, sort, _source, timeout
searchWatcherAlertsElasticsearch监视器警报历史记录q (时间查询), size, from, sort, _source, timeout

📝 公共参数

🔍 搜索参数

  • q (query):Elasticsearch查询字符串(例如。, "error AND @timestamp:>now-1h")
  • size:结果数(默认值:10,建议最大值:100)
  • from:分页偏移量(默认值:0)
  • sort:排序(例如。, "@timestamp:desc", "_score:desc")
  • _source:要包括的具体字段(例如。, "@timestamp,message,service.name")
  • timeout:搜索超时(默认值:“30s”)

📊 时间参数

  • time_range:时间范围(例如。, "now-1h", "now-24h", "now-7d")
  • time_window:时间窗口(例如。, "30m", "1h", "5m")
  • @timestamp:查询中的时间过滤器(例如。, "@timestamp:>now-2h")

🏷️ 过滤参数

  • index:特定指数或模式(例如。, "logs-2024", "logs-apm.error-*")
  • service_name:APM服务名称(例如。, "api-users", "servicio-local")
  • error_type:错误类型(例如。, "ConnectionError", "TimeoutError")
  • level:细节级别(例如。, "cluster", "indices", "shards")

🔧 格式参数

  • format:输出格式(例如。, "json", "yaml", "text")
  • v:带标头的详细输出(true/false)
  • h:要显示的特定列(例如。, "index,health,status")
  • s:要排序的列(例如。, "index:desc")

🚀 安装

📦 源代码 (推荐)

选项1:简单安装(建议用户使用)

# Clone repository
git clone https://github.com/byviz/mcp-server-elasticsearch-ai.git
cd elasticsearch-mcp

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install ALL dependencies (production + development)
pip install -r requirements-all.txt

# Install package in development mode
pip install -e .

选项2:最小安装(仅运行)

# If you only want to run the server (no development)
pip install -r requirements.txt
pip install -e .

选项3:使用pyproject.toml(高级)

# Clone repository
git clone https://github.com/byviz/elasticsearch-mcp-ai.git
cd elasticsearch-mcp

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install directly from pyproject.toml
pip install -e .

📋 依赖关系文件摘要

文件描述何时使用
requirements-all.txt所有依赖关系 (生产+开发)推荐 对于大多数用户
requirements.txt只需运行最小的依赖项仅当您想要非常轻量级的安装时
requirements-dev.txt只有开发依赖关系适用于已经具备基础知识的贡献者
pyproject.toml现代Python配置适用于使用现代工具的高级用户

📋 验证安装

# Verify package was installed correctly
python -c "import elasticsearch_mcp; print('✅ Installation successful')"

# Check version
python -m elasticsearch_mcp --version

⚙️ 配置

📋 所需的环境变量

弹性搜索

# Cluster connection
ELASTICSEARCH_URL="https://your-cluster.es.io:9243"

# Authentication (choose one option)
ELASTICSEARCH_USERNAME="your-username"
ELASTICSEARCH_PASSWORD="your-password"
# Or alternatively:
# ELASTICSEARCH_API_KEY="your-api-key"

🔧 可选变量

高级Elasticsearch

ELASTICSEARCH_TIMEOUT=30                     # Timeout in seconds
ELASTICSEARCH_VERIFY_CERTS=true              # Verify SSL certificates
ELASTICSEARCH_CA_CERTS="/path/to/ca.crt"     # CA certificates
ELASTICSEARCH_CLIENT_CERT="/path/to/client.crt"  # Client certificate
ELASTICSEARCH_CLIENT_KEY="/path/to/client.key"   # Private key

MCP服务器

MCP_TRANSPORT=stdio                          # Transport (stdio/http/sse)
MCP_PORT=8000                               # Port for HTTP/SSE
MCP_LOG_LEVEL=INFO                          # Logging level
MCP_ENABLE_SECURITY_FILTERING=true          # Security filtering

🚀 用法

📝 快速配置

  1. 创建配置文件:
cp config.env.example .env
  1. 编辑变量:
# Elasticsearch
ELASTICSEARCH_URL=https://your-cluster.es.io:9243
ELASTICSEARCH_USERNAME=your-username
ELASTICSEARCH_PASSWORD=your-password
  1. 运行服务器:
source .env
python -m elasticsearch_mcp

🎯 与Claude Desktop集成

添加到您的Claude Desktop配置文件中:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

窗户: %APPDATA%\Claude\claude_desktop_config.json

Linux: ~/.config/claude/claude_desktop_config.json

{
  "mcpServers": {
    "elasticsearch": {
      "command": "python",
      "args": ["-m", "elasticsearch_mcp"],
      "env": {
        "ELASTICSEARCH_URL": "https://your-cluster.es.io:9243",
        "ELASTICSEARCH_USERNAME": "your-username",
        "ELASTICSEARCH_PASSWORD": "your-password"
      }
    }
  }
}

🔒 安全

默认情况下,服务器在启用安全筛选的情况下运行(MCP_ENABLE_SECURITY_FILTERING=true),这将操作限制为只读。

允许的操作

  • 搜索和查询(GET、POST搜索)
  • 读取映射、配置和统计信息
  • APM分析和指标
  • 集群和节点信息
  • 可视化

受阻操作

  • 创建、修改或删除索引
  • 索引、更新或删除文档
  • 修改群集配置
  • 任何破坏性操作

📊 使用示例

🔍 基本搜索

"Search for documents containing 'error' in the last 30 minutes"
→ Use searchAllIndices with q="error AND @timestamp:>now-30m"

"Count how many documents are in the 'logs-2024' index"
→ Use countDocumentsInIndex with index="logs-2024"

📊 集群监控

"Is the cluster working well?"
→ Use getClusterHealth to check status (green/yellow/red)

"How many nodes does the cluster have and how much memory do they use?"
→ Use getNodeStats with metric="os,jvm" for detailed metrics

"Show basic cluster information"
→ Use getClusterInfo for name, version, and UUID

🗂️ 索引管理

"List all indices with their health status"
→ Use getCatIndices with format="json" and v=true

"What fields does the 'products' index have?"
→ Use getMapping with index="products" to see structure

"What is the configuration of the 'logs-app' index?"
→ Use getSettings with index="logs-app"

🚨 APM和故障排除

"Search for errors in the 'api-users' service from the last 2 hours"
→ Use searchAPMErrors with q="service.name:api-users AND @timestamp:>now-2h"

"What are the slowest transactions?"
→ Use searchAPMPerformance with sort="transaction.duration.us:desc"

"Analyze trace ID '430dbab7a0e0322274f076569cdc0c3d'"
→ Use analyzeTracePerformance with trace_id="430dbab7a0e0322274f076569cdc0c3d"

"Find ConnectionError patterns"
→ Use findErrorPatterns with error_type="ConnectionError"

🖥️ 系统度量

"Show CPU usage from the last 5 minutes"
→ Use searchSystemMetrics with q="metricset.name:cpu AND @timestamp:>now-5m"

"Search for ERROR level logs"
→ Use searchLogData with q="log.level:ERROR"

"Check Watcher alerts from the last 24 hours"
→ Use searchWatcherAlerts with q="@timestamp:>now-24h"

🔧 高级分析


"Find error patterns in servicio-local"
→ Use findErrorPatterns with service_name="servicio-local" and time_range="now-1h"

🛡️ 故障排除

连接错误

ERROR - Connection failed

解决方案:验证 ELASTICSEARCH_URL 以及证书

认证错误

ERROR - Authentication failed

解决方案:验证 ELASTICSEARCH_USERNAME/PASSWORDELASTICSEARCH_API_KEY

证书错误

ERROR - SSL verification failed

解决方案:配置 ELASTICSEARCH_VERIFY_CERTS=false 或提供证书

📄 许可证

Apache 2.0-有关详细信息,请参阅LICENSE文件

🤝 贡献

欢迎投稿!拜托:

  1. 分叉项目
  2. 创建要素分支
  3. 提交您的更改
  4. 推到分支
  5. 打开拉取请求

📞 支持

需要帮助、有疑问或想建议新功能?\ 加入我们不断壮大的社区!打开一个问题或联系我们——我们在这里帮助您充分利用人工智能驱动的Elasticsearch。

伊万·弗里亚斯·莫利纳\ 弹性和Byviz

- 📧 ivan.frias@elastic.co\ - 📧 ivan.frias@byviz.com

目录标签

目录标签

PythonClaude日志分析APM分析本地部署性能监控故障排查AI驱动

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

25

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP