adityamparikh opened a new pull request, #305:
URL: https://github.com/apache/solr-mcp/pull/305
## Summary
The `index-data` prompt named the four indexing tools with string literals
that were separate copies of the `@McpTool(name = ...)` values. Renaming a tool
would still compile, and the prompt would then tell the model to call a tool
that no longer exists. Both places now use the same constant, and the format
keywords are an enum instead of a string switch.
```diff
+private static final String INDEX_JSON_TOOL = "index-json-documents"; //
+ CSV, XML, MARKDOWN
@McpTool(
- name = "index-json-documents",
+ name = INDEX_JSON_TOOL,
-private record IndexTool(String format, String name, String paramName,
String payload) {}
-private static IndexTool resolveIndexTool(String format) {
- switch (format.trim().toLowerCase()) { case "json" -> new
IndexTool("json", "index-json-documents", ...) ... }
+private enum IndexFormat {
+ JSON(INDEX_JSON_TOOL, "documents", "..."), CSV(...), XML(...),
MARKDOWN(...);
+ String keyword() { return name().toLowerCase(Locale.ROOT); }
+ static IndexFormat parse(String format) // trims, Locale.ROOT, "md" ->
MARKDOWN
```
- The tool names are `String` constants, not enum values, because an
annotation attribute has to be a compile-time constant.
- Lowercasing now uses `Locale.ROOT`. With `toLowerCase()`, a Turkish
default locale lowercases `I` to a dotless `ı`.
- The unknown-format error builds its keyword list from
`IndexFormat.values()`, so it is no longer a third hand-written copy. The
message text is unchanged: `format must be one of json/csv/xml/markdown, got:
...`.
- `paramName` stays a literal. It has to match the Java parameter name the
MCP input schema is generated from, and `@McpToolParam` has no `name` attribute
a constant could feed.
## Evidence
Tests are unchanged on purpose. The string literals in `IndexingServiceTest`
and `McpClientIntegrationTestBase` pin the public tool names clients call, so a
constant changing should still fail them.
- `IndexingServiceTest` prompt cases (json, csv, xml, markdown, `md` alias,
unknown format): pass.
- `McpClientIntegrationTest` / `McpClientStdioIntegrationTest` (tool
listing, `index-data` prompt body): pass.
- `./gradlew build`: 518 tests, 0 failures, 0 skipped.
## Merge Danger
**Door:** two-way
Private refactor inside `IndexingService`. Tool names, parameter names and
prompt text are byte-identical.
**Blast Radius:** none
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]