Skip to content

refactor(dtos): drop noise fields from MCP tool response records#132

Open
adityamparikh wants to merge 1 commit into
apache:mainfrom
adityamparikh:dto-cleanup
Open

refactor(dtos): drop noise fields from MCP tool response records#132
adityamparikh wants to merge 1 commit into
apache:mainfrom
adityamparikh:dto-cleanup

Conversation

@adityamparikh
Copy link
Copy Markdown
Contributor

Summary

Three MCP tool response records in `Dtos.java` carried fields that conveyed no real information to the LLM client. Removing them simplifies the JSON wire format and eliminates legacy `java.util.Date` usage entirely.

Fields removed

Record Field Why noise
`SolrMetrics` `timestamp` (Date) Always "now" — metrics collected synchronously per call. MCP host records call timing already.
`SolrHealthStatus` `lastChecked` (Date) Same: always "now".
`SolrHealthStatus` `solrVersion` (String) Always null in every code path. `@JsonInclude(NON_NULL)` was hiding it on the wire anyway.
`SolrHealthStatus` `status` (String) Same: always null.
`CollectionCreationResult` `success` (boolean) Always `true` on return — failures throw before reaching the result.
`CollectionCreationResult` `message` (String) Always the literal "Collection created successfully".
`CollectionCreationResult` `createdAt` (Date) Always "now".

After this change:

  • `SolrMetrics` → `(indexStats, queryStats, cacheStats, handlerStats)`
  • `SolrHealthStatus` → `(isHealthy, errorMessage, responseTime, totalDocuments, collection)`
  • `CollectionCreationResult` → `(name)`

Date → Instant migration: not needed

The original motivation was "why are we using `java.util.Date` instead of `java.time.Instant`?" — once every `Date` field turned out to be cargo-culted noise rather than load-bearing state, the migration is moot. Both `java.util.Date` and `com.fasterxml.jackson.annotation.JsonFormat` imports drop from `Dtos.java` entirely.

Wire format impact

For LLM clients consuming the existing JSON, the change is purely subtractive — three keys disappear from each affected response. Any code that depended on those values (none in this repo) would break, but since `@JsonInclude(NON_NULL)` was already dropping `solrVersion` and `status` from the wire, only `timestamp` / `lastChecked` / `success` / `message` / `createdAt` are visible behavioral changes.

Test plan

  • `./gradlew clean build` — BUILD SUCCESSFUL, all tests pass
  • `./gradlew nativeTest -Pnative` — 157/157 tests pass, 0 failures
  • Test assertions updated where they referenced removed fields (`CollectionServiceIntegrationTest`, `CollectionServiceTest`, `ConferenceEndToEndIntegrationTest`, `McpClientIntegrationTestBase`)
  • CI native + docker matrix on the PR

Related

This addresses a sub-thread of review on #131 (schema modification PR), where the new `SchemaUpdateResult` followed the same convention and the reviewer asked why we used `Date`. After this PR merges, #131 will pick up the same treatment for `SchemaUpdateResult` via rebase.

🤖 Generated with Claude Code

Three MCP tool response records carried fields that conveyed no real
information to the LLM client:

- SolrMetrics.timestamp (Date) — always "now" since metrics are
  collected synchronously per call. The MCP host already records
  call timing.
- SolrHealthStatus.lastChecked (Date) — same: always "now".
- SolrHealthStatus.solrVersion (String) — always null in every code
  path. @JsonInclude(NON_NULL) was hiding it from the wire anyway.
- SolrHealthStatus.status (String) — same: always null.
- CollectionCreationResult.success (boolean) — always true on return;
  failures throw before reaching the result.
- CollectionCreationResult.message (String) — always the same literal
  "Collection created successfully".
- CollectionCreationResult.createdAt (Date) — always "now".

After this change, CollectionCreationResult is just (name), which is
the only useful piece of information (echoes back what the LLM sent so
it can confirm the operation applied to the expected collection). The
choice to keep it as a record vs returning a bare String preserves
symmetry with other tool result types and gives the LLM a parseable
JSON object `{"name":"shows"}` instead of a bare string.

This drops the java.util.Date and com.fasterxml.jackson.annotation
.JsonFormat imports from Dtos.java entirely — no remaining DTO needs
either. There was no need to migrate Date → Instant: every Date field
turned out to be cargo-culted noise rather than load-bearing state.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
adityamparikh added a commit to adityamparikh/solr-mcp that referenced this pull request May 18, 2026
Apply the same drop-noise treatment to SchemaUpdateResult that PR apache#132
applies to Dtos.java records:

- success (boolean) — always true on return; failures throw before
  reaching the result.
- timestamp (Date) — always "now"; sub-second operation, MCP host
  records call timing already.

After this change, SchemaUpdateResult is just (collection, addedNames):
both fields carry real information. addedNames echoes the field names
back so the LLM can confirm what landed. java.util.Date and
com.fasterxml.jackson.annotation.JsonFormat imports drop from the
record entirely.

Test assertions referencing the dropped fields are removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant