SO

Solr MCP Server Basic Search Service

Search Solr servers with the MCP server basic search service to quickly retrieve relevant results.

Quick Install
npx -y @mjochum64/mcp-solr-search

Overview

The Solr MCP Server Basic Search Service is a lightweight adapter that exposes an Apache Solr index as an MCP (Model Context Protocol) tool. It makes it easy for model-driven agents or other MCP-aware clients to perform relevance searches against a Solr collection and retrieve structured results suitable for context augmentation, QA, or retrieval-augmented generation.

This service translates MCP tool calls into Solr queries, applies basic filtering and pagination, and returns a compact, consistent JSON result set. That lets LLMs and other orchestrators request the “most relevant” documents without needing to know Solr query syntax or connectivity details.

Features

  • MCP-compatible search tool exposing Solr as a retrieval backend
  • Query string search with configurable top_k (number of results)
  • Optional field selection and simple filter support
  • Score and snippet (highlight) return where supported by Solr
  • Simple environment-driven configuration (Solr URL, core/collection, defaults)
  • Lightweight HTTP API suitable for local deployment, containers, or integration into orchestration systems

Installation / Configuration

Clone the repository and run the service. The project supports environment configuration for Solr connectivity and service behavior.

Clone and run (example using npm; adapt if project uses another runtime):

git clone https://github.com/mjochum64/mcp-solr-search.git
cd mcp-solr-search
# install dependencies (if Node.js)
npm install

# start the server (example)
npm start

Environment variables (example .env):

# Solr connection
SOLR_URL=http://localhost:8983
SOLR_CORE=my_core_or_collection

# Service options
PORT=8080
DEFAULT_TOP_K=5
DEFAULT_FIELDS=id,title,content
REQUEST_TIMEOUT_MS=5000

Docker run example (sets environment variables at runtime):

docker run -p 8080:8080 \
  -e SOLR_URL="http://solr:8983" \
  -e SOLR_CORE="my_collection" \
  -e DEFAULT_TOP_K=5 \
  mcp-solr-search:latest

Configuration table (common environment variables)

VariablePurposeExample
SOLR_URLBase URL of your Solr serverhttp://localhost:8983
SOLR_CORECore or collection name to querymy_core
PORTHTTP port for MCP server8080
DEFAULT_TOP_KDefault number of results when not provided5
DEFAULT_FIELDSComma-separated fields to return by defaultid,title,summary
REQUEST_TIMEOUT_MSSolr request timeout in milliseconds5000

Note: Adjust the service start command to match the repository’s runtime (node, python, etc.). See the repo README for exact start commands if different.

Available Resources

  • GitHub repository: https://github.com/mjochum64/mcp-solr-search
  • Apache Solr docs (querying, highlighting): https://lucene.apache.org/solr/
  • MCP (Model Context Protocol) overview/spec (for tool invocation patterns): consult your MCP client docs or server spec

Usage / Example Requests

The server exposes an MCP-style tool for basic searching. Example payloads below show typical calls — adapt the exact endpoint if your instance exposes a different path (e.g., /call, /tools/basic_search, or an MCP endpoint).

Example: simple search (curl)

curl -X POST http://localhost:8080/call \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "basic_search",
    "input": {
      "query": "solar panel efficiency",
      "top_k": 3
    }
  }'

Example: search with field selection and filters

curl -X POST http://localhost:8080/call \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "basic_search",
    "input": {
      "query": "wind turbine maintenance",
      "top_k": 5,
      "fields": ["id","title","summary","url"],
      "filters": {
        "status": "published",
        "year": { "gte": 2019 }
      }
    }
  }'

Example response (typical structure)

{
  "tool": "basic_search",
  "results": [
    {
      "id": "doc-123",
      "score": 12.34,
      "fields": {
        "title": "Solar Panel Efficiency Improvements",
        "summary": "Research into new coatings...",
        "url": "https://example.com/doc/123"
      },
      "highlight": "solar panel <em>efficiency</em>"
    }
  ],
  "meta": {
    "query_time_ms": 45,
    "total_found": 124
  }
}

Fields returned include document id, relevancy score, requested fields, optional highlight snippets (if Solr highlighting is enabled), and meta information about the query.

Use Cases

  • Retrieval Augmented Generation (RAG): Use the MCP tool to fetch top-k relevant documents to include as context for an LLM prompt, improving factual grounding.
Tags:search