Back to MCP directory
publicPublicdnsLocal runtime

elastic-semantic-search-mcp-server

该项目是一个基于Elasticsearch的语义搜索工具,用于对Search Labs博客文章进行语义检索,包含爬虫配置、索引映射更新和MCP服务器集成功能。

article

README

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

此项目提供了一个基于 Python 实现的 MCP 服务器,能够借助 Search Labs 博客文章在 Elasticsearch 中开展语义搜索,助力用户更高效地获取相关信息。

🚀 快速开始

运行 MCP 服务器

ES_URLES_AP_KEY 添加到 .env 文件中(可参考 这里 生成具有最小权限的 API 键)。 在 MCP 监控器 中启动服务器:

make dev

运行后,访问 MCP 监控器:http://localhost:5173

与 Claude 桌面集成

要将 MCP 服务器添加到 Claude Desktop,执行以下命令:

make install-claude-config

这会更新位于主目录中的 claude_desktop_config.json 文件。下次重新启动时,Claude 应用程序会自动检测并连接到该配置。

爬取 Search Labs 博客文章

1. 验证爬虫设置

确保已安装所有必要的依赖项,并且环境变量正确配置。运行以下命令以验证爬虫是否正常工作:

python crawler.py --test

2. 配置 Elasticsearch

elasticsearch.yml 文件中,更新以下配置以优化性能和索引管理:

# Elasticsearch 配置
cluster.name: "search-labs-cluster"
node.name: "crawler-node"
path.data: /var/lib/elasticsearch

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

创建一个新文件 index-mapping.json,并添加以下内容以定义字段和分析器:

{
  "mappings": {
    "properties": {
      "title": {"type": "text", "analyzer": "standard"},
      "content": {"type": "text", "analyzer": "standard"},
      "date": {"type": "date", "format": "yyyy-MM-dd"}
    }
  }
}

4. 开始爬取

运行以下命令以启动爬虫:

make start-crawler

要停止爬虫,按下 Ctrl+C

5. 验证已索引文档

使用 Elasticsearch 查询工具验证索引中的数据:

curl -X GET "http://localhost:9200/search-labs-posts/_search?pretty"

✨ 主要特性

  • 语义搜索:借助 Search Labs 博客文章在 Elasticsearch 中实现语义搜索,提升搜索的准确性和相关性。
  • 与 Claude 集成:可与 Claude Desktop 集成,方便在 Claude 中使用 MCP 服务器的搜索功能。
  • 可扩展性:提供了爬取博客文章的功能,并且可以根据需要更新爬虫规则以适应页面结构变化。

📚 详细文档

概述

此仓库提供了一个 Python 实现的 MCP 服务器,用于通过 Search Labs 博客文章Elasticsearch 中进行 语义搜索。它假设您已经爬取了博客文章并将它们存储在使用 Elastic Open Crawler 创建的 search-labs-posts 索引中。

⚠️ 注意事项

⚠️ 重要提示

  • 确保 Elasticsearch 服务正在运行。
  • 定期更新爬虫规则以适应 Search Labs 的页面结构变化。
  • 在生产环境中,建议配置日志记录和错误处理机制。

如有任何问题,请参考项目文档或联系维护人员。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client