adityamparikh opened a new pull request, #202:
URL: https://github.com/apache/solr-mcp/pull/202

   ### Summary
   `index-json-documents` took its documents as a JSON **string**, so the model 
had to escape every quote and newline of the payload inside a JSON string 
argument. On the 61-show sample that escaping is about 12% of the output tokens 
the model generates for the call, and one mis-escaped quote fails the whole 
call after the payload has been produced.
   
   The parameter is now `List<Map<String, Object>> documents`, advertised in 
the tool schema as an array of objects. The model emits native JSON, the MCP 
client parses it once, and on the SDK 2.0 line (#23) the shape is validated 
before dispatch.
   
   ```
   before:  
{"collection":"shows","json":"[{\"id\":\"netflix-001\",\"title\":\"Stranger 
Things\",...}]"}
   after:   
{"collection":"shows","documents":[{"id":"netflix-001","title":"Stranger 
Things",...}]}
   ```
   
   ### What changed
   - `JsonDocumentCreator.create(List<Map<String,Object>>)`: same flattening as 
the string path (nested objects to `a_b`, arrays to multi-valued fields, nulls 
skipped). `JsonDocumentCreatorTest` pins that both entry points produce 
identical documents.
   - `IndexingService.indexJsonDocuments` takes the typed list; description 
tells the model to pass the array itself, not a string. The `index-data` prompt 
says the same for the JSON path and its opening line names the format rather 
than the parameter.
   - Tests keep their JSON text blocks and parse them through a new 
`TestDocuments.json(...)` helper; the MCP-level tests send the array.
   - README tool table.
   
   ### Not changed
   CSV, XML and Markdown stay strings: those formats have few quotes and no 
repeated keys, so a string is already their cheapest wire form. Part of a set 
with `feat/markdown-multi-document` and `fix/xml-record-fields`; the three are 
independent and merge in any order.
   
   ### Verification
   - `./gradlew build` on Java 25: green.
   - `./gradlew nativeTest -Pnative` on GraalVM CE 25.0.2: 259 successful, 0 
failed (the generic `List<Map>` parameter deserialises natively without extra 
hints).
   - Measured against a running server: 61 documents index in 0.1 s server-side 
either way; the saving is entirely in what the model has to emit.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
   


-- 
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]

Reply via email to