mcp-lucene-server

Apache 2.0
  • Linux
  • Apple

Integrations

  • Utilizes Apache Lucene for full-text search and indexing capabilities, enabling efficient document management, complex querying with Lucene query syntax, and document filtering based on metadata.

  • Supports containerization of the application using Docker, with instructions for building and running the server as a Docker container.

  • Built with Spring Boot for application setup and deployment, providing RESTful API endpoints for document management operations including upsert, delete, list, and query functionalities.

MCP Lucene 服务器

描述

MCP Lucene 服务器是基于模型上下文协议 (MCP) 的 Java 实现,旨在使用 Apache Lucene 提供高效的搜索和检索功能。此服务器允许您利用 Lucene 强大的索引和搜索功能来管理和查询文档。它使用 Spring Boot 构建,易于设置和部署。

特征

  • **MCP 合规性:**实现核心模型上下文协议。
  • **Lucene-Powered:**利用 Apache Lucene 进行全文搜索和索引。
  • **RESTful API:**提供与服务器交互的 RESTful API。
  • 文档管理:
    • **Upsert:**在 Lucene 索引中添加或更新文档。
    • **删除:**从 Lucene 索引中删除文档。
    • **列表:**从索引中检索文档列表。
  • 查询:
    • 支持使用 Lucene 查询语法的复杂查询。
    • 过滤:根据文档元数据过滤查询。
  • **状态:**检查服务器状态。
  • **Spring Boot:**使用 Spring Boot 构建,可轻松设置和部署。
  • **Dockerization:**包括使用 Docker 对应用程序进行容器化的说明。

目录

入门

先决条件

  • Java: Java 11 或更高版本。
  • Maven: Maven 3.6.0 或更高版本。
  • **Docker:**如果您计划使用 Docker 镜像,请安装 Docker

安装

  1. 克隆存储库:
    git clone [https://github.com/your-username/mcp-lucene-server.git](https://github.com/your-username/mcp-lucene-server.git) cd mcp-lucene-server
    (将your-username替换为您的 GitHub 用户名)
  2. 使用 Maven 构建项目:
    mvn clean install

运行服务器

没有 Docker
  1. 运行 Spring Boot 应用程序:
    java -jar target/mcp-lucene-server-0.0.1-SNAPSHOT.jar
    .jar文件的确切名称可能会根据项目版本的不同而略有不同。)
  2. 服务器将默认在端口8080上启动。
使用 Docker
  1. **确保已安装 Docker:**按照 Docker 官方网站上的说明进行操作: https://docs.docker.com/get-docker/
  2. **构建 Docker 镜像:**在终端中导航到项目的根目录并运行:
    docker build -t mcp-lucene-server .
  3. 运行 Docker 容器:
    docker run -p 8080:8080 mcp-lucene-server
    这会将主机上的端口8080映射到容器内的端口8080

用法

API 端点

服务器提供以下 API 端点:

  • GET /mcp/v1/status
    • 返回服务器的状态。
  • POST /mcp/v1/upsert
    • 更新(插入或更新)一个或多个文档。
    • 请求正文:
      { "documents": [ { "id": "doc1", "text": "This is the text of document 1.", "metadata": { "category": "example", "language": "english" } }, { "id": "doc2", "text": "This is document 2's text.", "metadata": { "category": "sample", "language": "spanish" } } ] }
  • POST /mcp/v1/query
    • 查询 Lucene 索引。
    • 请求正文:
      { "queries": [ { "query": "document", "top_k": 10, "filter": { "language": "english" } }, { "query": "text search", "filter": { "category": "example" } } ] }
    • query :Lucene 查询字符串。
    • top_k :(可选)要返回的最大结果数(默认值:10)。
    • filter :(可选)要过滤的元数据字段和值的映射。
  • POST /mcp/v1/delete
    • 从 Lucene 索引中删除文档。
    • 请求正文:
      { "ids": ["doc1", "doc2"] }
  • GET /mcp/v1/list
    • 列出 Lucene 索引中的文档。
    • 请求正文:
      { "ids": ["doc1", "doc2"] }

示例

获取服务器状态:

curl http://localhost:8080/mcp/v1/status

更新插入文档:

curl -X POST http://localhost:8080/mcp/v1/upsert -H 'Content-Type: application/json' -d '{ "documents": [ { "id": "doc1", "text": "This is the text of document 1.", "metadata": { "category": "example", "language": "english" } }, { "id": "doc2", "text": "This is document 2''s text.", "metadata": { "category": "sample", "language": "spanish" } } ] }'

查询文件:

curl -X POST http://localhost:8080/mcp/v1/query -H 'Content-Type: application/json' -d '{ "queries": [ { "query": "document text", "top_k": 5, "filter": { "language": "english" } } ] }'

删除文档:

curl -X POST http://localhost:8080/mcp/v1/delete -H 'Content-Type: application/json' -d '{ "ids": ["doc1"] }'

列出文件:

curl -X POST http://localhost:8080/mcp/v1/list -H 'Content-Type: application/json' -d '{ "ids": ["doc1", "doc2"] }'

配置

可以使用 Spring Boot 的应用程序属性来配置服务器。以下是一些关键属性:

  • server.port :服务器监听的端口(默认值:8080)。
  • lucene.index.path :Lucene 索引目录的路径。索引数据就存储在这里。如果未设置,则使用默认位置。强烈建议将其配置为持久存储位置。

您可以在src/main/resources目录中的application.propertiesapplication.yml文件中设置这些属性,或者使用环境变量来设置这些属性。

示例application.properties

服务器.端口=8080 lucene.index.path=/路径/到/lucene/索引

执照

该项目采用Apache 2.0 许可证进行授权。

-
security - not tested
A
license - permissive license
-
quality - not tested

mcp-lucene-服务器

  1. 描述
    1. 特征
      1. 目录
        1. 入门
          1. 先决条件
          2. 安装
          3. 运行服务器
        2. 用法
          1. API 端点
          2. 示例
        3. 配置
          1. 执照

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              A Model Context Protocol (MCP) server that provides search and crawl functionality using Search1API.
              Last updated -
              5
              206
              111
              TypeScript
              MIT License
              • Apple
            • A
              security
              A
              license
              A
              quality
              An MCP server implementation that integrates the Tavily Search API, providing optimized search capabilities for LLMs.
              Last updated -
              1
              TypeScript
              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 SerpApi to retrieve search results from multiple search engines including Google, Bing, Yahoo, and others, enabling fast access to both live and archived search data.
              Last updated -
              Python

            View all related MCP servers

            ID: 2dlbo0wmkw