返回市场
MCP服务器-Elasticsearch

MCP服务器-Elasticsearch

作者:da1y2 星标更新:2024-12-02

项目介绍

Elasticsearch

用于Elasticsearch集群的Model Context Protocol服务器。使LLMs能够管理索引并执行查询。

重要提示:此文档主要通过向Claude提供来自Postgres MCP服务器的例子来构建。

组件

工具

  • search

    • 对索引执行搜索查询
    • 输入参数:
      • index (字符串):目标索引名称
      • query (对象):Elasticsearch查询DSL
    • 返回搜索结果
  • create_index

    • 创建新的Elasticsearch索引
    • 输入参数:
      • index (字符串):索引名称
      • mappings (对象,可选):索引映射配置
      • settings (对象,可选):索引设置配置
  • list_indices

    • 列出所有可用的索引
    • 不需要输入参数
    • 返回索引信息数组
  • index_document

    • 索引一个文档
    • 输入参数:
      • index (字符串):目标索引名称
      • id (字符串,可选):文档ID
      • document (对象):文档内容
    • 返回索引操作结果

资源

该服务器为每个索引提供了映射信息:

  • 索引映射 (elasticsearch://<host>/<index>/schema)
    • JSON映射信息
    • 字段名称、类型和配置
    • 自动从元数据中发现

使用Claude Desktop

在您的claude_desktop_config.json文件中的“mcpServers”部分添加以下内容:

{
  "mcpServers": {
    "elasticsearch": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-elasticsearch",
        "http://localhost:9200"
      ]
    }
  }
}

Docker单行命令运行容器:

docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:8.11.3

用您的Elasticsearch端点替换URL。

许可证

根据MIT许可证授权。免费使用、修改和分发。详情见LICENSE文件。 </中文翻译>