adityamparikh opened a new pull request, #164: URL: https://github.com/apache/solr-mcp/pull/164
## Motivation The `search` tool's `sortClauses` parameter is `List<Map<String, String>>` with magic `"item"`/`"order"` keys. A JSON schema cannot express required keys of a map, so the tool schema MCP clients receive says nothing about what to send — LLM clients guess (`field`/`direction` is a common wrong guess) and sorting silently doesn't apply (`map.get(...)` returns null). A typed record turns the keys into named schema properties: the contract becomes machine-checkable instead of guessable. ## Changes - New `SortClause(field, order)` record in the `search` package; `sortClauses` is now `List<SortClause>`. - LLM-friendly normalization at conversion time: `order` is case-insensitive (`DESC` works) and defaults to `asc` when omitted; an unrecognized order or missing field throws `IllegalArgumentException` naming the offending value, so the client can self-correct on the next call. - Removed the now-unused `SORT_ITEM`/`SORT_ORDER` constants. - Registered the record in `SolrNativeHints` (tool parameter records are deserialized reflectively by Jackson, same as response records; list renamed `MCP_RESPONSE_RECORDS` → `MCP_TOOL_RECORDS`). - Tests: new `SortClauseTest` covering conversion, case normalization, default order, and both rejection paths; existing unit + integration tests updated to the record. Note: this changes the tool's parameter schema. Map-shaped calls from existing clients would stop matching — but they only "worked" if the client guessed both magic keys correctly, which the schema never told them. `./gradlew build` passes (unit + Testcontainers integration tests). 🤖 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]
