Apache Solr MCP server

Integrates with Apache Solr to provide search, indexing, and collection management capabilities including advanced filtering, faceting, pagination, schema-less document indexing, health monitoring, and performance metrics collection.
Back to servers
Setup instructions
Provider
Aditya Parikh
Release date
Jul 06, 2025
Language
Python
Stats
6 stars

The Solr MCP Server implements the Spring AI Model Context Protocol, enabling AI assistants to interact with Apache Solr search platforms. This server allows capabilities such as searching collections, indexing documents, and managing Solr collections through various tools accessible via the MCP protocol.

Prerequisites

  • Java 21 or higher
  • Docker and Docker Compose (for running Solr)
  • Gradle (for building the project)

Installation and Setup

Clone the repository

git clone https://github.com/yourusername/solr-mcp-server.git
cd solr-mcp-server

Start Solr using Docker Compose

docker-compose up -d

This command starts a Solr instance in SolrCloud mode with ZooKeeper and creates two sample collections: books and films.

Build and run the MCP server

./gradlew bootRun

Available Tools

Search

Search a Solr collection with advanced query options.

Tool: Search
Description: Search specified Solr collection with query, optional filters, facets, sorting, and pagination.
Parameters:
  - collection: Solr collection to query
  - query: Solr q parameter (defaults to "*:*" if not specified)
  - filterQueries: Solr fq parameter (optional)
  - facetFields: Solr facet fields (optional)
  - sortClauses: Solr sort parameter (optional)
  - start: Starting offset for pagination (optional)
  - rows: Number of rows to return (optional)

Index Documents

Index JSON documents into a Solr collection.

Tool: index_documents
Description: Index documents from JSON string into Solr collection
Parameters:
  - collection: Solr collection to index into
  - json: JSON string containing documents to index

List Collections

List all available Solr collections.

Tool: listCollections
Description: List solr collections
Parameters: None

Get Collection Stats

Get detailed statistics and metrics for a Solr collection.

Tool: getCollectionStats
Description: Get stats/metrics on a Solr collection
Parameters:
  - collection: Name of the collection

Check Collection Health

Check the health status of a Solr collection.

Tool: checkHealth
Description: Check health of a Solr collection
Parameters:
  - collection: Name of the collection

Get Schema

Retrieve the schema for a Solr collection.

Tool: getSchema
Description: Get schema for a Solr collection
Parameters:
  - collection: Name of the collection

Adding to Claude Desktop

To add this MCP server to Claude Desktop:

  1. Build the project as a standalone JAR:
./gradlew bootJar
  1. In Claude Desktop, go to Settings > Tools > Add Tool

  2. Select "MCP Server" as the tool type

  3. Configure the tool:

    • Name: Solr MCP Server
    • Description: Tools for interacting with Apache Solr
    • Command: java -jar /path/to/solr-mcp-server-0.0.1-SNAPSHOT.jar
    • Working Directory: /path/to/solr-mcp-server
  4. Click "Add Tool"

Alternatively, you can add the following configuration to your MCP client configuration file:

"solr-search-mcp": {
  "command": "~/.sdkman/candidates/java/current/bin/java",
  "args": [
    "-jar",
    "~/solr-mcp-server/build/libs/solr-mcp-server-0.0.1-SNAPSHOT.jar"
  ],
  "env": {
    "SOLR_URL": "http://localhost:8983/solr/"
  }
}

Usage Examples

Searching for Books

When you ask:

I need to search for fantasy books in the Solr collection. Can you help me?

The assistant can use the Search tool:

I'll search for fantasy books in the Solr collection.

Using the Search tool with:
- collection: books
- query: genre_s:fantasy
- rows: 5

Here are the fantasy books I found:
1. "A Game of Thrones" by George R.R. Martin
2. "A Clash of Kings" by George R.R. Martin
...

Indexing New Documents

When you ask:

I have some new book data I'd like to add to Solr. Can you help me index it?

The assistant can use the index_documents tool:

I'll help you index that book data into Solr.

Using the index_documents tool with:
- collection: books
- json: [{"id":"123456789","name":["The New Book"],"author":["Jane Author"],"genre_s":"mystery","price":[12.99]}]

The document has been successfully indexed into the books collection.

Listing Collections

When you ask:

What Solr collections are available in the system?

The assistant can use the listCollections tool:

I'll check what Solr collections are available.

Using the listCollections tool.

The following collections are available:
1. books
2. films

Troubleshooting

If you encounter issues:

  1. Ensure Solr is running and accessible. By default, the server connects to http://localhost:8983/solr/, but you can set the SOLR_URL environment variable to point to a different Solr instance.
  2. Check the logs for any error messages
  3. Verify that the collections exist using the Solr Admin UI

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "solr-search-mcp" '{"command":"~/.sdkman/candidates/java/current/bin/java","args":["-jar","~/solr-mcp-server/build/libs/solr-mcp-server-0.0.1-SNAPSHOT.jar"],"env":{"SOLR_URL":"http://localhost:8983/solr/"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "solr-search-mcp": {
            "command": "~/.sdkman/candidates/java/current/bin/java",
            "args": [
                "-jar",
                "~/solr-mcp-server/build/libs/solr-mcp-server-0.0.1-SNAPSHOT.jar"
            ],
            "env": {
                "SOLR_URL": "http://localhost:8983/solr/"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "solr-search-mcp": {
            "command": "~/.sdkman/candidates/java/current/bin/java",
            "args": [
                "-jar",
                "~/solr-mcp-server/build/libs/solr-mcp-server-0.0.1-SNAPSHOT.jar"
            ],
            "env": {
                "SOLR_URL": "http://localhost:8983/solr/"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later