Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
# ============================================================================
# Tests the server against multiple Solr versions using Testcontainers.
# Runs in parallel so each Solr version is an independent job.
# Tested versions: 9.4, 9.9, 9.10, 10
# Tested versions: 9.4, 9.9, 9.10, 9.11, 10
# ============================================================================
solr-compatibility:
name: Solr ${{ matrix.solr-version }} Compatibility
Expand All @@ -190,6 +190,7 @@ jobs:
- "9.4-slim"
- "9.9-slim"
- "9.10-slim"
- "9.11-slim"
- "10-slim"

steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ jobs:
solr-version:
- "9.4-slim"
- "9.10-slim"
- "9.11-slim"
- "10-slim"

steps:
Expand Down
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ buildpacks (`bootBuildImage -Pnative`). Key configuration:
generic `Object` dispatch): `AliasResult`, `CollectionCreationResult`,
`SolrHealthStatus`, `SolrMetrics`, `IndexStats`, `QueryStats`, `CacheStats`,
`CacheInfo`, `HandlerStats`, `HandlerInfo`, `SearchResponse`, `SortClause`,
`SchemaUpdateResult`
`SchemaUpdateResult`, `CollectionSchema` and `FieldListing` and their nested records
- **Spring AI**: `org.springframework.ai.mcp.annotation.context.DefaultMetaProvider`,
which `MetaUtils` instantiates reflectively
- **Resources**: `logback-spring.xml` (see Logging Architecture above), and SolrJ's
Expand Down Expand Up @@ -465,10 +465,11 @@ The Solr Docker image used in tests is pinned as `test-image-solr` in `gradle/li
./gradlew test -Dsolr.test.image=solr:9.4-slim # Solr 9.4
./gradlew test -Dsolr.test.image=solr:9.9.0-slim # Solr 9.9 (the pinned default)
./gradlew test -Dsolr.test.image=solr:9.10-slim # Solr 9.10
./gradlew test -Dsolr.test.image=solr:9.11-slim # Solr 9.11
./gradlew test -Dsolr.test.image=solr:10-slim # Solr 10
```

**Tested compatible versions:** 9.4, 9.9, 9.10, 10
**Tested compatible versions:** 9.4, 9.9, 9.10, 9.11, 10

### Solr 10 Compatibility

Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Apache Solr MCP 1.0.0 is the project's first release: a Model Context Protocol (
- **Search**: the `search` tool runs full-text queries with filter queries, faceting, sorting and pagination.
- **Indexing in four formats**: `index-json-documents`, `index-csv-documents`, `index-xml-documents` (Solr update XML; only `<add>` is accepted, so the tool cannot delete documents or issue commits) and `index-markdown-documents`, which extracts front matter, title, headings and body text from each document.
- **Collection management**: `list-collections`, `create-collection`, `check-health` and `get-collection-stats`, plus alias management with `list-aliases`, `create-alias` and `delete-alias`.
- **Schema inspection and additive changes**: `get-schema`, `add-fields` and `add-field-types`. The schema tools only add; they never change or remove existing fields or field types.
- **Prompts, resources and completions**: guided prompts (`explore-collections`, `setup-collection`, `search-collection`, `index-data`, `view-schema`, `design-schema`), the `solr://collections` and `solr://{collection}/schema` resources, and collection-name completion for their arguments.
- **Schema inspection and additive changes**: `get-schema`, `list-fields` (the fields that hold data, from Solr's Luke handler), `add-fields` and `add-field-types`. The schema tools only add; they never change or remove existing fields or field types.
- **Prompts, resources and completions**: guided prompts (`explore-collections`, `setup-collection`, `search-collection`, `index-data`, `view-schema`, `design-schema`), the `solr://collections`, `solr://{collection}/schema` and `solr://{collection}/fields` resources, and collection-name completion for their arguments.
- **STDIO and HTTP transports**: STDIO is the default; `PROFILES=http` serves stateless streamable HTTP.
- **OAuth2 security for HTTP, on by default**: JWT bearer tokens from the issuer in `OAUTH2_ISSUER_URI`, with audience validation and configurable CORS origins (`MCP_CORS_ALLOWED_ORIGINS`). Setup guides cover Auth0 and Keycloak.
- **Docker images**: `apache/solr-mcp`, a JVM image (amd64 and arm64) that serves both transports, and GraalVM native images for each transport (`<version>-native-stdio`, `<version>-native-http`) on GHCR.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ Using a different client, or want STDIO/HTTP/Docker options? See the per-client
| `check-health` | Check the health status of a collection |
| `add-fields` | Add fields to a collection schema (additive only; existing fields cannot be modified) |
| `add-field-types` | Add field types — custom analyzers, `DenseVectorField` for semantic search, etc. |
| `get-schema` | Retrieve schema information for a collection |
| `get-schema` | Retrieve the full schema: field types, analyzers, dynamic-field patterns, copy fields |
| `list-fields` | List the fields that hold data in a collection, with types, flags and document counts |
| `list-aliases` | List all Solr aliases and the collections they point to |
| `create-alias` | Create or update a Solr alias pointing to one or more collections |
| `delete-alias` | Delete a Solr alias (underlying collections are not affected) |
Expand All @@ -131,6 +132,7 @@ Every tool advertises MCP behavior hints (`readOnlyHint`, `destructiveHint`, `id
|--------------|-------------|
| `solr://collections` | List of all Solr collections in the cluster |
| `solr://{collection}/schema` | Schema definition for a collection (supports autocompletion) |
| `solr://{collection}/fields` | Fields that hold data in a collection, as `list-fields` returns them (supports autocompletion) |

### Prompts

Expand All @@ -149,7 +151,7 @@ Slash-command-style workflow templates that walk the assistant through a canonic

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

- **Resource argument** — the `{collection}` segment of `solr://{collection}/schema` completes to live collection names.
- **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.
Expand Down
9 changes: 5 additions & 4 deletions THREAT_MODEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ it speaks MCP (JSON-RPC) to an AI client over one of two transports — **STDIO*
(streamable-HTTP; a network listener). On the other side it speaks SolrJ HTTP to
**one** backend Solr instance whose location and credentials the operator fixes
at startup via environment (`SOLR_URL`, optional `SOLR_USERNAME`/`SOLR_PASSWORD`).
It exposes eleven tools (search, three indexing formats, collection create/list/
stats/health, schema get/add-fields/add-field-types), two resources
(`solr://collections`, `solr://{collection}/schema`), and prompt/completion
It exposes sixteen tools (search, four indexing formats, collection create/list/
stats/health, alias list/create/delete, schema get/list-fields/add-fields/
add-field-types), three resources (`solr://collections`,
`solr://{collection}/schema`, `solr://{collection}/fields`), and prompt/completion
helpers. It translates natural-language requests — as structured by the calling
LLM into tool arguments — into Solr API calls, and returns Solr results back to
the model. *(documented — README; AGENTS.md; `src/main/java/.../server/`.)*
Expand Down Expand Up @@ -108,7 +109,7 @@ deferred to a later version (see §12). This is a deliberate scoping choice for
| --- | --- | --- | --- |
| STDIO transport | stdin/stdout JSON-RPC | child process of the client only | **Yes** |
| HTTP transport | servlet on `:8080/mcp` + OAuth2 filter chain | **network listener** | **Yes (highest network exposure)** |
| Read tools | `search`, `list-collections`, `get-collection-stats`, `check-health`, `get-schema` | reads backend Solr | **Yes** |
| Read tools | `search`, `list-collections`, `get-collection-stats`, `check-health`, `get-schema`, `list-fields` | reads backend Solr | **Yes** |
| Write/index tools | `index-json/csv/xml-documents` | writes backend Solr index | **Yes** |
| Admin/schema tools | `create-collection`, `add-fields`, `add-field-types` | mutates backend Solr collections/schema | **Yes (privileged)** |
| Backend SolrJ client | `SolrConfig` → `HttpJdkSolrClient` | outbound HTTP to `SOLR_URL` | **Yes (auth passthrough)** |
Expand Down
2 changes: 1 addition & 1 deletion dev-docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Tests run against the Solr image pinned as `test-image-solr` in `gradle/libs.ver
./gradlew test -Dsolr.test.image=solr:10-slim # Solr 10
```

**Tested compatible versions:** 9.4, 9.9, 9.10, 10.
**Tested compatible versions:** 9.4, 9.9, 9.10, 9.11, 10.

**Solr 10 notes.** Solr 10 is fully supported with the JSON wire format. The `/admin/mbeans`
endpoint was removed in Solr 10, so `getCacheMetrics()`/`getHandlerMetrics()` catch
Expand Down
2 changes: 1 addition & 1 deletion docs/clients/chatgpt.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Use the `https://…` address it prints, with `/mcp` appended.
1. **Settings → Security and login**: turn on **Developer mode**.
2. Open **ChatGPT Plugins**, select the **+** button and create a developer-mode app.
3. Enter a name and description, and under **Connection** give the public endpoint, ending in `/mcp`, for example `https://<your-tunnel>/mcp`. For a private server, choose **Tunnel** instead and select an available Secure MCP Tunnel.
4. Choose **No authentication**, create the connection and review the discovered tools. There should be twelve.
4. Choose **No authentication**, create the connection and review the discovered tools. There should be sixteen.
5. Start a chat, enable the app, and ask *"What Solr collections are available?"*.

ChatGPT asks for confirmation before tool calls it treats as writes. Tools without a `readOnlyHint` annotation are treated as writes, so expect prompts for most Solr MCP tools. After restarting the server, use **Refresh** on the app so ChatGPT re-reads its tools.
Expand Down
2 changes: 1 addition & 1 deletion docs/clients/mcp-inspector.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ See the [HTTP security model](../security/http.md) for server-side OAuth2 setup

## Resources, prompts and completions ##

The **Resources** tab lists `solr://collections` and the `solr://{collection}/schema` template:
The **Resources** tab lists `solr://collections` and the `solr://{collection}/schema` and `solr://{collection}/fields` templates:

![MCP Inspector reading the solr://collections resource](../../images/mcp-inspector-list-resources.png)

Expand Down
4 changes: 2 additions & 2 deletions docs/site/content/pages/mcp/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ template: mcp/quick-start

* Java 25+ ([Eclipse Temurin](https://adoptium.net/) recommended)
* [Docker](https://docs.docker.com/get-docker/) and Docker Compose
* Apache Solr **9.4–10** (the bundled sample stack runs Solr 9; the server is tested against 9.4, 9.9, 9.10, and 10)
* Apache Solr **9.4–10** (the bundled sample stack runs Solr 9; the server is tested against 9.4, 9.9, 9.10, 9.11, and 10)
* An MCP client &mdash; this guide uses [Claude Desktop](https://claude.ai/download), but any MCP-compatible client works. See [Adding to AI Clients](/mcp/clients/claude-desktop.html) for other options.

## Start Solr with Sample Data ##
Expand Down Expand Up @@ -120,7 +120,7 @@ Open Claude Desktop and try these prompts:
* *"Find all sci-fi movies released after 2000 and show the genre breakdown"*
* *"Index this JSON into the books collection: [{"id": "1", "title": "The Great Gatsby", "author": "F. Scott Fitzgerald"}]"*

**Tip:** clients that support MCP completions autocomplete collection names — for the `{collection}` in the `solr://{collection}/schema` resource and for the `collection` argument of the `search-collection`, `index-data`, `view-schema`, and `design-schema` prompts.
**Tip:** clients that support MCP completions autocomplete collection names — for the `{collection}` in the `solr://{collection}/schema` and `solr://{collection}/fields` resources and for the `collection` argument of the `search-collection`, `index-data`, `view-schema`, and `design-schema` prompts.

***

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,19 @@ public List<String> completeCollection(CompleteRequest.CompleteArgument argument
}
}

/**
* Completion for the {@code {collection}} segment of the {@code solr://{collection}/fields}
* resource template (defined in {@code SchemaService}).
*
* @param argument the partial value the client is completing
* @return matching collection names, capped at {@link #MAX_COMPLETION_RESULTS}
*/
@PreAuthorize("isAuthenticated()")
@McpComplete(uri = "solr://{collection}/fields")
public List<String> completeFieldsResourceCollection(CompleteRequest.CompleteArgument argument) {
return completeCollection(argument);
}

/**
* Completion for the {@code collection} argument of the {@code search-collection} prompt (defined
* in {@code SearchService}).
Expand Down Expand Up @@ -498,7 +511,9 @@ public List<String> listCollections() throws SolrServerException, IOException {
name = "get-collection-stats",
annotations = @McpTool.McpAnnotations(readOnlyHint = true),
description =
"Get stats/metrics on a Solr collection. cacheStats and handlerStats may be"
"Get index size and performance metrics for a Solr collection: document and segment "
+ "counts, and query, cache and handler stats. It does not describe fields; use "
+ "list-fields for the fields that hold data. cacheStats and handlerStats may be"
+ " null when Solr's /admin/metrics API does not provide them for the collection;"
+ " this is expected and not an error.")
public SolrMetrics getCollectionStats(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import org.apache.solr.common.luke.FieldFlag;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -66,7 +67,16 @@ class SolrNativeHints implements RuntimeHintsRegistrar {
"org.apache.solr.mcp.server.collection.HandlerInfo",
"org.apache.solr.mcp.server.search.SearchResponse",
"org.apache.solr.mcp.server.search.SortClause",
"org.apache.solr.mcp.server.schema.SchemaUpdateResult");
"org.apache.solr.mcp.server.schema.SchemaUpdateResult",
"org.apache.solr.mcp.server.schema.CollectionSchema",
"org.apache.solr.mcp.server.schema.CollectionSchema$Field",
"org.apache.solr.mcp.server.schema.CollectionSchema$FieldType",
"org.apache.solr.mcp.server.schema.CollectionSchema$Analyzer",
"org.apache.solr.mcp.server.schema.CollectionSchema$CopyField",
// Jackson instantiates this @JsonSerialize(contentUsing = ...) serializer reflectively
"org.apache.solr.mcp.server.schema.FieldFlags$NameSerializer",
"org.apache.solr.mcp.server.schema.FieldListing",
"org.apache.solr.mcp.server.schema.FieldListing$IndexedField");

@Override
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
Expand All @@ -92,6 +102,9 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
hints.reflection().registerType(FacetField.class, categories);
hints.reflection().registerType(FacetField.Count.class, categories);

// SolrJ's Luke flag enum, serialized in get-schema and list-fields responses
hints.reflection().registerType(FieldFlag.class, categories);

// SolrJ / Solr API model types used by CoreAdminResponse.getCoreStatus()
// which deserializes via Jackson reflection.
for (String solrApiType :
Expand Down Expand Up @@ -126,16 +139,6 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
.registerType(
org.apache.solr.client.solrj.request.schema.FieldTypeDefinition.class, categories);

// SolrJ schema response type — returned by the get-schema MCP tool and
// serialized to JSON by Spring AI for MCP clients. Without reflection
// hints the JSON Spring AI produces in native image is missing the
// fields/fieldTypes/dynamicFields/copyFields arrays, which silently
// breaks any consumer that introspects the schema.
hints
.reflection()
.registerType(
org.apache.solr.client.solrj.response.schema.SchemaRepresentation.class, categories);

// MCP tool request/response records (some package-private, registered by
// name); request records are deserialized reflectively by Jackson when
// tool arguments are bound
Expand Down
Loading