Skip to main content
Glama

Elasticsearch Semantic Search MCP Server

MCP 服务器:Elasticsearch 语义搜索工具

演示 repo: https://j.blaszyk.me/tech-blog/mcp-server-elasticsearch-semantic-search/

目录


概述

该存储库提供了一个 MCP 服务器的 Python 实现,用于通过Elasticsearch中索引的Search Labs 博客文章进行语义搜索

它假设您已经使用Elastic Open Crawler抓取了博客文章并将其存储在search-labs-posts索引中。


运行 MCP 服务器

ES_URLES_AP_KEY添加到.env文件中,(查看此处了解如何生成具有最低权限的 api 密钥)

MCP Inspector中启动服务器:

make dev

运行后,访问 MCP Inspector: http://localhost:5173


与 Claude Desktop 集成

要将 MCP 服务器添加到Claude Desktop

make install-claude-config

这会更新你主目录中的claude_desktop_config.json 。下次重启后,Claude 应用将检测服务器并加载声明的工具。


抓取搜索实验室博客文章

1. 验证爬虫设置

要检查Elastic Open Crawler是否工作,请运行:

docker run --rm \ --entrypoint /bin/bash \ -v "$(pwd)/crawler-config:/app/config" \ --network host \ docker.elastic.co/integrations/crawler:latest \ -c "bin/crawler crawl config/test-crawler.yml"

这应该从单个页面打印抓取的内容。


2.配置Elasticsearch

设置Elasticsearch URL 和 API Key

生成具有最低爬虫权限的 API 密钥:

POST /_security/api_key { "name": "crawler-search-labs", "role_descriptors": { "crawler-search-labs-role": { "cluster": ["monitor"], "indices": [ { "names": ["search-labs-posts"], "privileges": ["all"] } ] } }, "metadata": { "application": "crawler" } }

从响应中复制encoded值并将其设置为API_KEY


3. 更新语义搜索的索引映射

确保search-labs-posts索引存在。如果不存在,请创建它:

PUT search-labs-posts

更新映射以启用语义搜索

PUT search-labs-posts/_mappings { "properties": { "body": { "type": "text", "copy_to": "semantic_body" }, "semantic_body": { "type": "semantic_text", "inference_id": ".elser-2-elasticsearch" } } }

使用Elasticsearch 的 ELSER 模型body字段索引为语义文本


4.开始爬行

运行爬虫来填充索引:

docker run --rm \ --entrypoint /bin/bash \ -v "$(pwd)/crawler-config:/app/config" \ --network host \ docker.elastic.co/integrations/crawler:latest \ -c "bin/crawler crawl config/elastic-search-labs-crawler.yml"

[!TIP]如果使用新的 Elasticsearch 集群,请等待ELSER 模型启动后再进行索引。


5.验证索引文档

检查文档是否已被索引:

GET search-labs-posts/_count

这将返回索引中的文档总数。您也可以在Kibana中验证。


完成!您现在可以对Search Labs 博客文章进行语义搜索了

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

一个 Python MCP 服务器,可以通过 Elasticsearch 中索引的 Search Labs 博客文章进行语义搜索,从而允许 Claude 从博客内容中智能地检索相关信息。

  1. 目录
    1. 概述
      1. 运行 MCP 服务器
        1. 与 Claude Desktop 集成
          1. 抓取搜索实验室博客文章
            1. 验证爬虫设置
            2. 2.配置Elasticsearch
            3. 更新语义搜索的索引映射
            4. 4.开始爬行
            5. 5.验证索引文档

          Related MCP Servers

          • A
            security
            A
            license
            A
            quality
            An MCP server that enables users to fetch Python documentation using the Brave Search API through natural language queries.
            Last updated -
            1
            JavaScript
            Apache 2.0
            • Apple
          • A
            security
            A
            license
            A
            quality
            An MCP server that enables Claude to perform web searches using Perplexity's API with intelligent model selection based on query intent and support for domain and recency filtering.
            Last updated -
            6
            JavaScript
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            Provides an MCP protocol interface for interacting with Elasticsearch 7.x databases, supporting comprehensive search functionality including aggregations, highlighting, and sorting.
            Last updated -
            3
            1
            Python
            Apache 2.0
          • -
            security
            F
            license
            -
            quality
            An MCP server that integrates with Claude to provide smart documentation search capabilities across multiple AI/ML libraries, allowing users to retrieve and process technical information through natural language queries.
            Last updated -
            Python

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/jedrazb/elastic-semantic-search-mcp-server'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server