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.
git clone https://github.com/yourusername/solr-mcp-server.git
cd solr-mcp-server
docker-compose up -d
This command starts a Solr instance in SolrCloud mode with ZooKeeper and creates two sample collections: books
and films
.
./gradlew bootRun
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 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 all available Solr collections.
Tool: listCollections
Description: List solr collections
Parameters: None
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 the health status of a Solr collection.
Tool: checkHealth
Description: Check health of a Solr collection
Parameters:
- collection: Name of the collection
Retrieve the schema for a Solr collection.
Tool: getSchema
Description: Get schema for a Solr collection
Parameters:
- collection: Name of the collection
To add this MCP server to Claude Desktop:
./gradlew bootJar
In Claude Desktop, go to Settings > Tools > Add Tool
Select "MCP Server" as the tool type
Configure the tool:
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/"
}
}
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
...
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.
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
If you encounter issues:
SOLR_URL
environment variable to point to a different Solr instance.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.
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.
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/"
}
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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