Skip to content

Commit c1016b5

Browse files
fix: standardize MCP tool names to kebab-case (#43)
1 parent acdfb18 commit c1016b5

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

src/main/java/org/apache/solr/mcp/server/indexing/IndexingService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public IndexingService(SolrClient solrClient, IndexingDocumentCreator indexingDo
192192
* @see #indexDocuments(String, List)
193193
*/
194194
@PreAuthorize("isAuthenticated()")
195-
@McpTool(name = "index_json_documents", description = "Index documents from json String into Solr collection")
195+
@McpTool(name = "index-json-documents", description = "Index documents from json String into Solr collection")
196196
public void indexJsonDocuments(@McpToolParam(description = "Solr collection to index into") String collection,
197197
@McpToolParam(description = "JSON string containing documents to index") String json)
198198
throws IOException, SolrServerException {
@@ -258,7 +258,7 @@ public void indexJsonDocuments(@McpToolParam(description = "Solr collection to i
258258
* @see #indexDocuments(String, List)
259259
*/
260260
@PreAuthorize("isAuthenticated()")
261-
@McpTool(name = "index_csv_documents", description = "Index documents from CSV string into Solr collection")
261+
@McpTool(name = "index-csv-documents", description = "Index documents from CSV string into Solr collection")
262262
public void indexCsvDocuments(@McpToolParam(description = "Solr collection to index into") String collection,
263263
@McpToolParam(description = "CSV string containing documents to index") String csv)
264264
throws IOException, SolrServerException {
@@ -348,7 +348,7 @@ public void indexCsvDocuments(@McpToolParam(description = "Solr collection to in
348348
* @see #indexDocuments(String, List)
349349
*/
350350
@PreAuthorize("isAuthenticated()")
351-
@McpTool(name = "index_xml_documents", description = "Index documents from XML string into Solr collection")
351+
@McpTool(name = "index-xml-documents", description = "Index documents from XML string into Solr collection")
352352
public void indexXmlDocuments(@McpToolParam(description = "Solr collection to index into") String collection,
353353
@McpToolParam(description = "XML string containing documents to index") String xml)
354354
throws ParserConfigurationException, SAXException, IOException, SolrServerException {

src/main/java/org/apache/solr/mcp/server/metadata/CollectionService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public List<String> completeCollectionForSchema() {
342342
* @see CollectionAdminRequest.List
343343
* @see CoreAdminRequest
344344
*/
345-
@McpTool(description = "List solr collections")
345+
@McpTool(name = "list-collections", description = "List solr collections")
346346
public List<String> listCollections() {
347347
try {
348348
if (solrClient instanceof CloudSolrClient) {
@@ -431,7 +431,7 @@ public List<String> listCollections() {
431431
* @see LukeRequest
432432
* @see #extractCollectionName(String)
433433
*/
434-
@McpTool(description = "Get stats/metrics on a Solr collection")
434+
@McpTool(name = "get-collection-stats", description = "Get stats/metrics on a Solr collection")
435435
public SolrMetrics getCollectionStats(
436436
@McpToolParam(description = "Solr collection to get stats/metrics for") String collection)
437437
throws SolrServerException, IOException {
@@ -1022,7 +1022,7 @@ private boolean validateCollectionExists(String collection) {
10221022
* @see SolrHealthStatus
10231023
* @see SolrPingResponse
10241024
*/
1025-
@McpTool(description = "Check health of a Solr collection")
1025+
@McpTool(name = "check-health", description = "Check health of a Solr collection")
10261026
public SolrHealthStatus checkHealth(@McpToolParam(description = "Solr collection") String collection) {
10271027
try {
10281028
// Ping Solr

src/main/java/org/apache/solr/mcp/server/metadata/SchemaService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public String getSchemaResource(String collection) {
249249
* @see SchemaRequest
250250
* @see org.apache.solr.client.solrj.response.schema.SchemaResponse
251251
*/
252-
@McpTool(description = "Get schema for a Solr collection")
252+
@McpTool(name = "get-schema", description = "Get schema for a Solr collection")
253253
public SchemaRepresentation getSchema(String collection) throws Exception {
254254
SchemaRequest schemaRequest = new SchemaRequest();
255255
return schemaRequest.process(solrClient, collection).getSchemaRepresentation();

src/main/java/org/apache/solr/mcp/server/search/SearchService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private static Map<String, Map<String, Long>> getFacets(QueryResponse queryRespo
215215
* If there's an I/O error
216216
*/
217217
@PreAuthorize("isAuthenticated()")
218-
@McpTool(name = "Search", description = """
218+
@McpTool(name = "search", description = """
219219
Search specified Solr collection with query, optional filters, facets, sorting, and pagination.
220220
Note that solr has dynamic fields where name of field in schema may end with suffixes
221221
_s: Represents a string field, used for exact string matching.

src/test/java/org/apache/solr/mcp/server/McpToolRegistrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void testSearchServiceHasToolAnnotation() throws NoSuchMethodException {
4949

5050
// Verify the annotation properties
5151
McpTool toolAnnotation = searchMethod.getAnnotation(McpTool.class);
52-
assertEquals("Search", toolAnnotation.name(), "McpTool name should be 'Search'");
52+
assertEquals("search", toolAnnotation.name(), "McpTool name should be 'search' (kebab-case)");
5353
assertNotNull(toolAnnotation.description(), "McpTool description should not be null");
5454
assertFalse(toolAnnotation.description().isBlank(), "McpTool description should not be blank");
5555
}

src/test/java/org/apache/solr/mcp/server/SampleClient.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ public void run() {
158158
assertEquals(8, toolsList.tools().size(), "Expected 8 tools to be available");
159159

160160
// Define expected tools based on the log output
161-
Set<String> expectedToolNames = Set.of("index_json_documents", "index_csv_documents", "getCollectionStats",
162-
"Search", "listCollections", "checkHealth", "index_xml_documents", "getSchema");
161+
Set<String> expectedToolNames = Set.of("index-json-documents", "index-csv-documents",
162+
"get-collection-stats", "search", "list-collections", "check-health", "index-xml-documents",
163+
"get-schema");
163164

164165
// Validate each expected tool is present
165166
List<String> actualToolNames = toolsList.tools().stream().map(Tool::name).toList();
@@ -179,23 +180,23 @@ public void run() {
179180

180181
// Validate specific tools based on expected behavior
181182
switch (tool.name()) {
182-
case "index_json_documents" :
183+
case "index-json-documents" :
183184
assertTrue(tool.description().toLowerCase().contains("json"),
184185
"JSON indexing tool should mention JSON in" + " description");
185186
break;
186-
case "index_csv_documents" :
187+
case "index-csv-documents" :
187188
assertTrue(tool.description().toLowerCase().contains("csv"),
188189
"CSV indexing tool should mention CSV in" + " description");
189190
break;
190-
case "Search" :
191+
case "search" : // single word, no hyphen needed
191192
assertTrue(tool.description().toLowerCase().contains("search"),
192193
"Search tool should mention search in description");
193194
break;
194-
case "listCollections" :
195+
case "list-collections" :
195196
assertTrue(tool.description().toLowerCase().contains("collection"),
196197
"List collections tool should mention collections" + " in description");
197198
break;
198-
case "checkHealth" :
199+
case "check-health" :
199200
assertTrue(tool.description().toLowerCase().contains("health"),
200201
"Health check tool should mention health in" + " description");
201202
break;

0 commit comments

Comments
 (0)