Token导航 LogoToken导航TokenDH.com
es MCP server logo
搜索检索stdio官方级别未说明来源级核验

es MCP server

MCP Server

Elasticsearch MCP服务器是一个为Elasticsearch集群提供交互工具和资源的服务,支持索引列表、映射获取、搜索等功能。

工具数

5

提示词数

0

GitHub Stars

2

资源数

0
PythonClaude数据分析ClaudeVS Code

安装说明

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

作者 / 组织

sajitsasi

提供方

sajitsasi

最后核验

2026/5/17 20:28

运行时

Python

快速接入

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

命令预览

pip install -r requirements.txt

详细介绍

Elasticsearch MCP服务器

该项目为Elasticsearch实现了一个MCP(模型上下文协议)服务器,提供了与Elasticsearchs集群交互的工具和资源。

![License: MIT](https://opensource.org/licenses/MIT)

特性

工具

  • list_indices:列出Elasticsearch集群中的所有索引
  • get_mappings:获取特定索引的映射
  • search:使用提供的查询DSL执行Elasticsearch搜索
  • search_with_query_string:使用简单的查询字符串执行搜索
  • get_index_stats:获取特定索引的统计信息

资源

  • elasticsearch://indices:列出所有Elasticsearch索引
  • elasticsearch://index/{index_name}:获取特定索引的详细信息
  • elasticsearch://mapping/{index_name}:获取特定索引的映射信息

先决条件

  • Python 3.7+
  • Elasticsearch Python客户端
  • MCP-SDK
  • Elasticsearch集群凭据(云ID和API密钥)

设置

  1. 克隆存储库:
   git clone https://github.com/yourusername/elasticsearch-mcp-server.git
   cd elasticsearch-mcp-server
  1. 安装所需的依赖项:
   pip install -r requirements.txt
  1. 设置环境变量:

- 复制示例环境文件: cp .env.example .env - 编辑 .env 文件并添加您的Elasticsearch凭据

或者直接在shell中设置它们:

   export ES_CLOUD_ID=your_elasticsearch_cloud_id
   export ES_API_KEY=your_elasticsearch_api_key

为Claude配置MCP服务器

configure_mcp_server.py 该脚本帮助您在Claude的MCP设置文件中设置Elasticsearch MCP服务器。这允许Claude通过MCP服务器连接到您的Elasticsearch集群。

python configure_mcp_server.py your_cloud_id your_api_key

此脚本:

  1. 将您的Elasticsearch云ID和API密钥作为命令行参数
  2. 查找或创建Claude MCP设置文件
  3. 添加或更新Elasticsearch MCP服务器配置
  4. 设置服务器连接到Elasticsearch集群所需的环境变量

运行此脚本后,重新启动VS Code以应用更改。然后,Claude将能够使用Elasticsearch MCP服务器与您的Elasticsearchs集群进行交互。

测试MCP资源

选项1:使用测试脚本

我们提供了一个测试脚本,用于启动MCP服务器并提供测试说明:

# Make the script executable if needed
chmod +x test_es_mcp.sh

# Run the test script
ES_CLOUD_ID=your_cloud_id ES_API_KEY=your_api_key ./test_es_mcp.sh

脚本将:

  1. 在后台启动MCP服务器
  2. 提供测试资源的说明
  3. 保持服务器运行,直到按Ctrl+C

选项2:手动测试

  1. 启动MCP服务器:
   ES_CLOUD_ID=your_cloud_id ES_API_KEY=your_api_key python es_mcp_server.py
  1. 在克劳德,使用 access_mcp_resource 访问资源的工具:

a.列出所有指标:

   
   elasticsearch-mcp-server
   elasticsearch://indices
   

b.获取特定索引的信息:

   
   elasticsearch-mcp-server
   elasticsearch://index/your_index_name
   

c.获取特定索引的映射:

   
   elasticsearch-mcp-server
   elasticsearch://mapping/your_index_name
   

选项3:使用Python测试脚本

我们还提供了一个Python测试脚本,演示了如何访问资源:

ES_CLOUD_ID=your_cloud_id ES_API_KEY=your_api_key python test_es_resources.py

资源详细信息

elasticsearch://indices

返回Elasticsearch集群中所有索引的JSON数组,包括:

  • 索引名称
  • 健康状况
  • 状态
  • 文档计数
  • 尺寸

elasticsearch://index/{index_name}

返回特定索引的详细信息,包括:

  • 索引名称
  • 设置
  • 统计数据(文档计数、字节大小和MB)

elasticsearch://mapping/{index_name}

返回特定索引的映射信息,包括:

  • 完整的映射定义
  • 字段计数
  • 字段类型分布

错误处理

所有资源都包括正确的错误处理和验证:

  • 如果索引不存在,资源将返回相应的错误消息
  • 如果连接到Elasticsearch时出现问题,资源将返回错误消息
  • 所有异常都会被捕获并作为可读的错误消息返回

贡献

欢迎投稿!以下是您如何做出贡献:

  1. 分叉存储库
  2. 创建要素分支: git checkout -b feature/your-feature-name
  3. 提交您的更改: git commit -am 'Add some feature'
  4. 推到分支: git push origin feature/your-feature-name
  5. 提交拉取请求

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

目录标签

目录标签

PythonClaude数据分析Elasticsearch工具本地部署MCP协议数据查询索引管理搜索服务

支持客户端

ClaudeVS Code

接入字段

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

stdio

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

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdionone部署方式未说明

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

安装前确认

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

来源信息

继续浏览同类 MCP