This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-mcp.git
The following commit(s) were added to refs/heads/main by this push:
new afbf38d fix(indexing): return indexing results to MCP clients instead
of void (#107)
afbf38d is described below
commit afbf38db4006bc0deeb1388c9730bad962b23f06
Author: Aditya Parikh <[email protected]>
AuthorDate: Fri May 8 17:01:55 2026 -0400
fix(indexing): return indexing results to MCP clients instead of void (#107)
Change indexJsonDocuments(), indexCsvDocuments(), and indexXmlDocuments()
from void to String return type, returning a message with the success
count so AI clients get feedback on how many documents were indexed.
Signed-off-by: adityamparikh <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
.../solr/mcp/server/indexing/IndexingService.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git
a/src/main/java/org/apache/solr/mcp/server/indexing/IndexingService.java
b/src/main/java/org/apache/solr/mcp/server/indexing/IndexingService.java
index e52ca7b..84349a1 100644
--- a/src/main/java/org/apache/solr/mcp/server/indexing/IndexingService.java
+++ b/src/main/java/org/apache/solr/mcp/server/indexing/IndexingService.java
@@ -193,11 +193,13 @@ public class IndexingService {
*/
@PreAuthorize("isAuthenticated()")
@McpTool(name = "index-json-documents", description = "Index documents
from json String into Solr collection")
- public void indexJsonDocuments(@McpToolParam(description = "Solr
collection to index into") String collection,
+ public String indexJsonDocuments(@McpToolParam(description = "Solr
collection to index into") String collection,
@McpToolParam(description = "JSON string containing
documents to index") String json)
throws IOException, SolrServerException {
List<SolrInputDocument> schemalessDoc =
indexingDocumentCreator.createSchemalessDocumentsFromJson(json);
- indexDocuments(collection, schemalessDoc);
+ int successCount = indexDocuments(collection, schemalessDoc);
+ return "Successfully indexed " + successCount + " of " +
schemalessDoc.size() + " documents into collection '"
+ + collection + "'";
}
/**
@@ -259,11 +261,13 @@ public class IndexingService {
*/
@PreAuthorize("isAuthenticated()")
@McpTool(name = "index-csv-documents", description = "Index documents
from CSV string into Solr collection")
- public void indexCsvDocuments(@McpToolParam(description = "Solr
collection to index into") String collection,
+ public String indexCsvDocuments(@McpToolParam(description = "Solr
collection to index into") String collection,
@McpToolParam(description = "CSV string containing
documents to index") String csv)
throws IOException, SolrServerException {
List<SolrInputDocument> schemalessDoc =
indexingDocumentCreator.createSchemalessDocumentsFromCsv(csv);
- indexDocuments(collection, schemalessDoc);
+ int successCount = indexDocuments(collection, schemalessDoc);
+ return "Successfully indexed " + successCount + " of " +
schemalessDoc.size() + " documents into collection '"
+ + collection + "'";
}
/**
@@ -349,11 +353,13 @@ public class IndexingService {
*/
@PreAuthorize("isAuthenticated()")
@McpTool(name = "index-xml-documents", description = "Index documents
from XML string into Solr collection")
- public void indexXmlDocuments(@McpToolParam(description = "Solr
collection to index into") String collection,
+ public String indexXmlDocuments(@McpToolParam(description = "Solr
collection to index into") String collection,
@McpToolParam(description = "XML string containing
documents to index") String xml)
throws ParserConfigurationException, SAXException,
IOException, SolrServerException {
List<SolrInputDocument> schemalessDoc =
indexingDocumentCreator.createSchemalessDocumentsFromXml(xml);
- indexDocuments(collection, schemalessDoc);
+ int successCount = indexDocuments(collection, schemalessDoc);
+ return "Successfully indexed " + successCount + " of " +
schemalessDoc.size() + " documents into collection '"
+ + collection + "'";
}
/**