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

Elasticsearch

MCP Server

一个提供Elasticsearch和OpenSearch交互的模型上下文协议(MCP)服务器,支持文档搜索、索引分析和集群管理。

工具数

19

提示词数

0

GitHub Stars

276

资源数

0
集群管理搜索引擎PythonClaude数据管理Claude DesktopClaude

安装说明

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

作者 / 组织

cr7258

提供方

cr7258

最后核验

2026/5/17 20:59

运行时

Python

快速接入

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

命令预览

uvx elasticsearch-mcp-server --transport sse

详细介绍

Elasticsearch/OpenSearch MCP服务器

](https://mseep.ai/app/cr7258-elasticsearch-mcp-server)

![Trust Score](https://archestra.ai/mcp-catalog/cr7258__elasticsearch-mcp-server)

概述

提供Elasticsearch和OpenSearch交互的模型上下文协议(MCP)服务器实现。此服务器允许通过一组工具搜索文档、分析索引和管理集群。

演示

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

特性

一般操作

  • general_api_request:执行常规HTTP API请求。对于任何没有专用工具的Elasticsearch/OOpenSearch API,请使用此工具。

索引操作

  • list_indices:列出所有索引。
  • get_index:返回有关一个或多个索引的信息(映射、设置、别名)。
  • create_index:创建新索引。
  • delete_index:删除索引。
  • create_data_stream:创建新的数据流(需要匹配的索引模板)。
  • get_data_stream:获取有关一个或多个数据流的信息。
  • delete_data_stream:删除一个或多个数据流及其支持索引。

文档操作

  • 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:删除特定索引的别名。

分析仪操作

  • analyze_text:使用指定的分析器或自定义分析链分析文本。有助于调试搜索查询和理解文本是如何标记的。

配置环境变量

MCP服务器支持以下环境变量:

基本身份验证(用户名/密码)

  • ELASTICSEARCH_USERNAME:基本身份验证的用户名
  • ELASTICSEARCH_PASSWORD:基本身份验证密码
  • OPENSEARCH_USERNAME:OpenSearch基本身份验证的用户名
  • OPENSEARCH_PASSWORD:OpenSearch基本身份验证密码

API密钥验证(仅限Elasticsearch)-推荐

连接设置

  • ELASTICSEARCH_HOSTS / OPENSEARCH_HOSTS:以逗号分隔的主机列表(默认值: https://localhost:9200)
  • VERIFY_CERTS:是否验证SSL证书(默认值: false)
  • REQUEST_TIMEOUT:请求超时(秒)(可选,如果未设置,则使用客户端默认值)

MCP服务器身份验证(仅限HTTP传输)

当使用基于HTTP的传输(SSE或Streamable HTTP)运行MCP服务器时,您可以启用承载令牌身份验证,以保护服务器免受未经授权的访问。

  • MCP_API_KEY:用于MCP服务器身份验证的API密钥。客户必须包括 Authorization: Bearer 头球

重要安全注意事项:

  • 身份验证是 仅适用 用于HTTP传输(sse, streamable-http).这 stdio 传输使用本地进程通信,不需要身份验证。
  • 如果 MCP_API_KEY未设置,MCP服务器将可访问 无身份验证当通过网络暴露服务器时,这是一个安全风险。
  • 对于使用HTTP传输的生产部署, 始终设置 MCP_API_KEY.
# Generate a secure API key (example using openssl)
export MCP_API_KEY=$(openssl rand -base64 32)

# Or set a custom API key
export MCP_API_KEY="your-secure-api-key-here"

禁用高风险操作

  • DISABLE_HIGH_RISK_OPERATIONS:设置为 true 禁用所有写入操作(默认值: false)
  • DISABLE_OPERATIONS:逗号分隔的要禁用的特定操作列表(可选,如果未设置,则使用默认写入操作列表)

DISABLE_HIGH_RISK_OPERATIONS 如果设置为true,则执行写入操作的所有MCP工具都对MCP客户端完全隐藏。在此模式下,默认情况下禁用以下MCP工具。

  • 索引操作:

- create_index - delete_index

  • 文档操作:

- index_document - delete_document - delete_by_query

  • 数据流操作:

- create_data_stream - delete_data_stream

  • 别名操作:

- put_alias - delete_alias

  • API一般操作:

- general_api_request

(可选)您可以在 DISABLE_OPERATIONS 环境变量。

# Disable High-Risk Operations
export DISABLE_HIGH_RISK_OPERATIONS=true
# Disable specific operations only
export DISABLE_OPERATIONS="delete_index,delete_document,delete_by_query"

启动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.

工作室

选项1:使用uvx

使用 uvx 将自动从PyPI安装软件包,无需在本地克隆存储库。将以下配置添加到的配置文件中 claude_desktop_config.json.

// For Elasticsearch with username/password
{
  "mcpServers": {
    "elasticsearch-mcp-server": {
      "command": "uvx",
      "args": [
        "elasticsearch-mcp-server"
      ],
      "env": {
        "ELASTICSEARCH_HOSTS": "https://localhost:9200",
        "ELASTICSEARCH_USERNAME": "elastic",
        "ELASTICSEARCH_PASSWORD": "test123"
      }
    }
  }
}

// For Elasticsearch with API key
{
  "mcpServers": {
    "elasticsearch-mcp-server": {
      "command": "uvx",
      "args": [
        "elasticsearch-mcp-server"
      ],
      "env": {
        "ELASTICSEARCH_HOSTS": "https://localhost:9200",
        "ELASTICSEARCH_API_KEY": ""
      }
    }
  }
}

// For OpenSearch
{
  "mcpServers": {
    "opensearch-mcp-server": {
      "command": "uvx",
      "args": [
        "opensearch-mcp-server"
      ],
      "env": {
        "OPENSEARCH_HOSTS": "https://localhost:9200",
        "OPENSEARCH_USERNAME": "admin",
        "OPENSEARCH_PASSWORD": "admin"
      }
    }
  }
}

方案2:在当地发展中使用紫外线

使用 uv 需要在本地克隆存储库并指定源代码的路径。将以下配置添加到Claude Desktop的配置文件中 claude_desktop_config.json.

// For Elasticsearch with username/password
{
  "mcpServers": {
    "elasticsearch-mcp-server": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/elasticsearch-mcp-server",
        "run",
        "elasticsearch-mcp-server"
      ],
      "env": {
        "ELASTICSEARCH_HOSTS": "https://localhost:9200",
        "ELASTICSEARCH_USERNAME": "elastic",
        "ELASTICSEARCH_PASSWORD": "test123"
      }
    }
  }
}

// For Elasticsearch with API key
{
  "mcpServers": {
    "elasticsearch-mcp-server": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/elasticsearch-mcp-server",
        "run",
        "elasticsearch-mcp-server"
      ],
      "env": {
        "ELASTICSEARCH_HOSTS": "https://localhost:9200",
        "ELASTICSEARCH_API_KEY": ""
      }
    }
  }
}

// For OpenSearch
{
  "mcpServers": {
    "opensearch-mcp-server": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/elasticsearch-mcp-server",
        "run",
        "opensearch-mcp-server"
      ],
      "env": {
        "OPENSEARCH_HOSTS": "https://localhost:9200",
        "OPENSEARCH_USERNAME": "admin",
        "OPENSEARCH_PASSWORD": "admin"
      }
    }
  }
}

上海证券交易所

选项1:使用uvx

# export environment variables (with username/password)
export ELASTICSEARCH_HOSTS="https://localhost:9200"
export ELASTICSEARCH_USERNAME="elastic"
export ELASTICSEARCH_PASSWORD="test123"

# OR export environment variables (with API key)
export ELASTICSEARCH_HOSTS="https://localhost:9200"
export ELASTICSEARCH_API_KEY=""

# By default, the SSE MCP server will serve on http://127.0.0.1:8000/sse
uvx elasticsearch-mcp-server --transport sse

# The host, port, and path can be specified using the --host, --port, and --path options
uvx elasticsearch-mcp-server --transport sse --host 0.0.0.0 --port 8000 --path /sse

选项2:使用紫外线

# By default, the SSE MCP server will serve on http://127.0.0.1:8000/sse
uv run src/server.py elasticsearch-mcp-server --transport sse

# The host, port, and path can be specified using the --host, --port, and --path options
uv run src/server.py elasticsearch-mcp-server --transport sse --host 0.0.0.0 --port 8000 --path /sse

可流式传输的HTTP

选项1:使用uvx

# export environment variables (with username/password)
export ELASTICSEARCH_HOSTS="https://localhost:9200"
export ELASTICSEARCH_USERNAME="elastic"
export ELASTICSEARCH_PASSWORD="test123"

# OR export environment variables (with API key)
export ELASTICSEARCH_HOSTS="https://localhost:9200"
export ELASTICSEARCH_API_KEY=""

# By default, the Streamable HTTP MCP server will serve on http://127.0.0.1:8000/mcp
uvx elasticsearch-mcp-server --transport streamable-http

# The host, port, and path can be specified using the --host, --port, and --path options
uvx elasticsearch-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000 --path /mcp

选项2:使用紫外线

# By default, the Streamable HTTP MCP server will serve on http://127.0.0.1:8000/mcp
uv run src/server.py elasticsearch-mcp-server --transport streamable-http

# The host, port, and path can be specified using the --host, --port, and --path options
uv run src/server.py elasticsearch-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000 --path /mcp

兼容性

MCP服务器与Elasticsearch7.x、8.x和9.x兼容。默认情况下,它使用Elasticsearch8.x客户端(没有后缀)。

MCP服务器Elasticsearch
elasticsearch-mcp-server-es7elasticsearch 7.x
elasticsearch mcp服务器Elasticsearch8.x
elasticsearch-mcp-server-es9elasticsearch 9.x
opensearch mcp服务器opensearch 1.x、2.x、3.x

要使用Elasticsearch 7.x客户端,请运行 elasticsearch-mcp-server-es7 变体。对于Elasticsearch 9.x,请使用 elasticsearch-mcp-server-es9例如:

uvx elasticsearch-mcp-server-es7

如果你想在本地运行不同的Elasticsearch变体(例如7.x或9.x),只需更新 elasticsearch 依赖关系版本 pyproject.toml,然后使用以下命令启动服务器:

uv run src/server.py elasticsearch-mcp-server

Kubernetes部署

Docker镜像发布到 ghcr.io/cr7258/elasticsearch-mcp-server Helm图表可作为OCI工件在 oci://ghcr.io/cr7258/charts/elasticsearch-mcp-server 存储库。

有关完整的安装说明、配置参考和使用示例,请参阅 Helm chart自述.

许可证

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

目录标签

目录标签

集群管理搜索引擎PythonClaude数据管理混合部署索引操作文档操作

支持客户端

Claude DesktopClaude

接入字段

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

stdio

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

api-key

运行时(runtime,运行环境)

Python

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

19

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdioapi-keyremote-capable

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

安装前确认

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

来源信息

继续浏览同类 MCP