Solr MCP Server

Clone this repo:

Branches

  1. 0b50f37 test: assert JSON with JsonPath and Spring's JsonMapper; rename objectMapper to jsonMapper (#321) by Aditya Parikh · 3 days ago main
  2. 6d92d51 docs(agents): move SBOM, logging and LICENSE/NOTICE detail to dev-docs (#317) by Aditya Parikh · 3 days ago
  3. 544fbf7 docs: say which requests the XML writer serializes, and why JSON and XML (#303) by Aditya Parikh · 3 days ago
  4. 623725c docs(openspec): propose typed-mcp-contracts (#306) by Aditya Parikh · 3 days ago
  5. 8f9b16c chore: initialize OpenSpec for spec-driven changes (#298) by Aditya Parikh · 3 days ago

Project Status: Incubating Quality Gate Status Security Rating Reliability Rating Maintainability Rating Bugs Vulnerabilities Code Smells Lines of Code Duplicated Lines (%)

Solr MCP Server

Search, index, and manage Apache Solr collections using natural language — no need to hand-craft Solr queries, build filter expressions, or memorize the admin API.

Instead of writing:

q=title:"star wars" AND genre_s:"sci-fi"&fq=year_i:[2000 TO *]&facet=true&facet.field=genre_s&sort=score desc&rows=10

Just ask your AI assistant:

“Find sci-fi movies with ‘star wars’ in the title released after 2000, show me the genre breakdown, and sort by relevance.”

This Spring AI Model Context Protocol (MCP) server exposes Solr operations as tools that any MCP-compatible AI client (Claude Desktop, Claude Code, Codex, ChatGPT, VS Code/Copilot, Cursor, JetBrains, Zed) can invoke.

Quick start

Prerequisites: Java 25+, Docker and Docker Compose, Git.

Compatibility: works with Apache Solr 9.4–10 (the test suite runs against 9.9 by default — see Solr version compatibility).

1. Start Solr with sample data

git clone https://github.com/apache/solr-mcp.git
cd solr-mcp
docker compose up -d

This starts Solr in SolrCloud mode with two sample collections: films (1,100+ movies) and books (empty, ready for indexing). Wait ~30 seconds, then verify at http://localhost:8983/solr/.

2. Build the server

./gradlew build

This produces build/libs/solr-mcp-1.0.0-SNAPSHOT.jar.

3. Connect your AI client

Add the server to your MCP client. For Claude Desktop, edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows), then restart Claude:

{
  "mcpServers": {
    "solr-mcp": {
      "command": "java",
      "args": ["-jar", "/absolute/path/to/solr-mcp/build/libs/solr-mcp-1.0.0-SNAPSHOT.jar"],
      "env": { "SOLR_URL": "http://localhost:8983/solr/" }
    }
  }
}

Using a different client, or want STDIO/HTTP/Docker options? See the per-client guides: Claude Desktop · Claude Code · Codex · ChatGPT (HTTP only) · VS Code / Copilot · Cursor · JetBrains · Zed · MCP Inspector.

4. Try it out

  • “What collections are available in Solr?”
  • “Search the films collection for movies directed by Steven Spielberg”
  • “Show me the schema for the films collection”
  • “Index this JSON into the books collection: [{“id”: “1”, “title”: “The Great Gatsby”, “author”: “F. Scott Fitzgerald”}]”

Example prompts

Searching

  • “Find sci-fi movies released after 2000 and show the genre breakdown”
  • “Search films for movies with ‘war’ in the title, sorted by year”
  • “Show me the top 5 most recent films”

Indexing

  • “Index this JSON into the books collection: [{“id”: “1”, “title”: “1984”, “author”: “George Orwell”}]”
  • “Create a new collection called products”

Managing

  • “Is the films collection healthy?”
  • “How many documents are in the films collection?”
  • “Show me the schema for the films collection”

What you can do

Tools

ToolDescription
searchFull-text search with filtering, faceting, sorting, and pagination
index-json-documentsIndex documents passed as a JSON array of objects into a collection
index-csv-documentsIndex documents from a CSV string via Solr's CSV handler; repeat a column name for multi-valued fields
index-xml-documentsIndex documents from Solr update XML (<add><doc><field name="...">); only <add> blocks are accepted
index-markdown-documentsIndex markdown documents into a collection (one array element per document), extracting front matter, title, headings, and body text
create-collectionCreate a collection (configSet, numShards, replicationFactor optional — default: a private copy of _default, 1, 1)
list-collectionsList all available Solr collections
get-collection-statsGet statistics and metrics for a collection
check-healthCheck the health status of a collection
add-fieldsAdd fields to a collection schema (additive only; existing fields cannot be modified)
add-field-typesAdd field types — custom analyzers, DenseVectorField for semantic search, etc.
get-schemaRetrieve the full schema: field types, analyzers, dynamic-field patterns, copy fields
list-fieldsList the fields that hold data in a collection, with types, flags and document counts
list-aliasesList all Solr aliases and the collections they point to
create-aliasCreate or update a Solr alias pointing to one or more collections
delete-aliasDelete a Solr alias (underlying collections are not affected)

Every tool advertises MCP behavior hints (readOnlyHint, destructiveHint, idempotentHint) so clients can build sensible approval UX — search and the metadata tools are read-only, indexing is destructive but idempotent, schema modification is additive.

Resources

Resource URIDescription
solr://collectionsList of all Solr collections in the cluster
solr://{collection}/schemaSchema definition for a collection (supports autocompletion)
solr://{collection}/fieldsFields that hold data in a collection, as list-fields returns them (supports autocompletion)

Prompts

Slash-command-style workflow templates that walk the assistant through a canonical Solr workflow.

PromptArgumentsPurpose
explore-collections—List collections and characterise each by stats and health
setup-collectionname, purpose (optional)Pick configset / shards / replication factor, create the collection, verify it
view-schemacollectionRead-only schema walkthrough
design-schemacollection, datasetDescription, sampleDocument (optional)Choose field types and apply additive schema changes
index-datacollection, format (json / csv / xml), sample (optional)Pick the right indexing tool and confirm the result
search-collectioncollection, questionTranslate a natural-language question into a Solr query

Completions

The server implements MCP argument autocompletion, so clients can suggest valid values as you type:

  • Resource arguments — the {collection} segment of solr://{collection}/schema and solr://{collection}/fields completes to live collection names.
  • Prompt arguments — the collection argument of the search-collection, index-data, view-schema, and design-schema prompts completes to live collection names.

Suggestions are matched case-insensitively by prefix and capped per request.

Screenshots

Claude Desktop (STDIO) — answering a question about the films collection with the server's tools:

Claude Desktop calling Solr MCP tools over STDIO

STDIO — the Inspector launches the server with java -jar; the protocol log shows the tool, prompt and resource lists coming back:

MCP Inspector connected to the server over STDIO

HTTP — connected over Streamable HTTP at http://localhost:8080/mcp. Without a token the client connects and lists tools; calling them needs a bearer token:

MCP Inspector connected to the server over Streamable HTTP

HTTP with OAuth2 — the bearer token goes in the server's Settings → Custom Headers:

MCP Inspector custom Authorization header

With a valid token, tool calls succeed — here check-health on films:

MCP Inspector check-health succeeding with a bearer token

Without one, every tool call returns Access Denied:

MCP Inspector search denied without a bearer token

Resources — reading solr://collections:

MCP Inspector reading the solr://collections resource

Completions — the {collection} argument of solr://{collection}/schema completes to live collection names:

MCP Inspector completing the collection argument

Prompts — the collection argument of search-collection completes the same way:

MCP Inspector completing a prompt's collection argument

Configuration

The server reads configuration from environment variables. The essentials:

VariableDescriptionDefault
SOLR_URLSolr base URLhttp://localhost:8983/solr/
PROFILESTransport mode: stdio (default, for Claude Desktop) or http (remote / multi-client)stdio
MCP_PROTOCOLMCP spec revision: the 2025 revisions today's clients speak (default), or modern for the 2026-07-28 revisionstateless (HTTP), streamable (STDIO)

Running in HTTP mode — OAuth2, CORS, and the HTTP_SECURITY_ENABLED toggle (secured by default) — is covered in the security docs. Tracing, metrics and log-export env vars (OTEL_SAMPLING_PROBABILITY, OTEL_TRACES_URL, OTEL_METRICS_URL, OTEL_LOGS_URL) are covered in Observability.

Documentation

Using it

Developing it

Container images: published images are not yet available on a public registry. The Docker examples in the client guides use a locally built image — build it with ./gradlew jibDockerBuild (produces solr-mcp:latest). See Building Docker images.

Community

License

Apache License 2.0 — see LICENSE.

Acknowledgments

Built with Spring AI MCP, Apache Solr, Jib, Paketo Buildpacks, Testcontainers, and Spring AI MCP Security.