Sponsored by Deepsite.site

MCP Lucene Server

Created By
VivekKumarNeu8 months ago
MCP Lucene Server
Content

MCP Lucene Server

Description

The MCP Lucene Server is a Java-based implementation of the Model Context Protocol (MCP) designed to provide efficient search and retrieval capabilities using Apache Lucene. This server allows you to manage and query documents, leveraging Lucene's powerful indexing and search features. It is built using Spring Boot for easy setup and deployment.

Features

  • MCP Compliance: Implements the core Model Context Protocol.

  • Lucene-Powered: Utilizes Apache Lucene for full-text search and indexing.

  • RESTful API: Provides a RESTful API for interacting with the server.

  • Document Management:

    • Upsert: Add or update documents in the Lucene index.

    • Delete: Delete documents from the Lucene index.

    • List: Retrieve a list of documents from the index.

  • Querying:

    • Supports complex queries using the Lucene query syntax.

    • Filtering: Filter queries based on document metadata.

  • Status: Check the server status.

  • Spring Boot: Built with Spring Boot for easy setup and deployment.

  • Dockerization: Includes instructions for containerizing the application using Docker.

Table of Contents

Getting Started

Prerequisites

  • Java: Java 11 or higher.

  • Maven: Maven 3.6.0 or higher.

  • Docker: Install Docker if you plan to use the Docker image.

Installation

  1. Clone the repository:

    git clone [https://github.com/your-username/mcp-lucene-server.git](https://github.com/your-username/mcp-lucene-server.git)
    cd mcp-lucene-server
    

    (Replace your-username with your GitHub username)

  2. Build the project using Maven:

    mvn clean install
    

Running the Server

Without Docker

  1. Run the Spring Boot application:

    java -jar target/mcp-lucene-server-0.0.1-SNAPSHOT.jar
    

    (The exact name of the .jar file might vary slightly depending on your project version.)

  2. The server will start on port 8080 by default.

With Docker

  1. Ensure you have Docker installed: Follow the instructions on the official Docker website: https://docs.docker.com/get-docker/

  2. Build the Docker image: Navigate to the root directory of your project in your terminal and run:

    docker build -t mcp-lucene-server .
    
  3. Run the Docker container:

    docker run -p 8080:8080 mcp-lucene-server
    

    This will map port 8080 on your host machine to port 8080 inside the container.

Usage

API Endpoints

The server provides the following API endpoints:

  • GET /mcp/v1/status

    • Returns the status of the server.
  • POST /mcp/v1/upsert

    • Upserts (inserts or updates) one or more documents.

    • Request body:

      {
        "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

    • Queries the Lucene index.

    • Request body:

      {
        "queries": [
          {
            "query": "document",
            "top_k": 10,
            "filter": {
              "language": "english"
            }
          },
           {
            "query": "text search",
            "filter": {
               "category": "example"
             }
           }
        ]
      }
      
    • query: The Lucene query string.

    • top_k: (Optional) The maximum number of results to return (default: 10).

    • filter: (Optional) A map of metadata fields and values to filter by.

  • POST /mcp/v1/delete

    • Deletes documents from the Lucene index.

    • Request body:

      {
          "ids": ["doc1", "doc2"]
      }
      
  • GET /mcp/v1/list

    • Lists documents from the Lucene index.

    • Request body:

      {
          "ids": ["doc1", "doc2"]
      }
      

Examples

Get server status:

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

Upsert documents:

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"
}
}
]
}'

Query documents:

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"
}
}
]
}'

Delete documents:

curl -X POST 

http://localhost:8080/mcp/v1/delete 

-H 'Content-Type: application/json' 

-d '{
"ids": ["doc1"]
}'

List documents:

curl -X POST 

http://localhost:8080/mcp/v1/list 

-H 'Content-Type: application/json' 

-d '{
"ids": ["doc1", "doc2"]
}'

Configuration

The server can be configured using Spring Boot's application properties. Here are some of the key properties:

  • server.port: The port the server listens on (default: 8080).

  • lucene.index.path: The path to the Lucene index directory. This is where the indexed data is stored. If not set, a default location is used. It is highly recommended to configure this to a persistent storage location.

You can set these properties in an application.properties or application.yml file in your src/main/resources directory, or by using environment variables.

Example application.properties:

server.port=8080 lucene.index.path=/path/to/lucene/index

License

This project is licensed under the Apache 2.0 License.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
ChatWiseThe second fastest AI chatbot™
Tavily Mcp
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
CursorThe AI Code Editor
Serper MCP ServerA Serper MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"