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

   ## Summary
   
   This PR implements group 1 of the `typed-mcp-contracts` OpenSpec change 
(#306, spec `mcp-contracts`). It's stacked on #294: the first commit is #294's, 
and this PR's own change is the second commit, `7b036944`. It merges after #294 
and the schema group. Until the schema group lands, `get-schema` fails the new 
output-schema check (see Evidence).
   
   **Prompts, resources and completions return MCP's typed results**, built 
through `util/McpResults`:
   
   ```diff
    prompts (6)
   -  String        → Spring AI wraps it as one ASSISTANT message, no 
description
   +  GetPromptResult(description, [PromptMessage(Role.USER, text)])
    resources: solr://collections, solr://{collection}/schema, 
solr://{collection}/fields
   -  String
   +  ReadResourceResult([TextResourceContents(uri, "application/json", json)])
    completions (6)
   -  List<String>  → silently capped at 100
   +  CompleteResult(values ≤ 100, total, hasMore)
   ```
   
   - **Role.** MCP's `role` names the speaker. Every prompt is an instruction 
to the model, so each one passes `Role.USER` explicitly. `Role.ASSISTANT` would 
make the model read its instructions as its own earlier reply.
   - **Descriptions.** Each prompt's description is a 
`PromptNames.*_DESCRIPTION` constant, shared by the annotation and the result.
   
   **Every tool that returns a non-`String` publishes an output schema:**
   
   ```text
   @McpTool(..., generateOutputSchema = true)       # 12 tools; the 4 indexing 
tools still return String
     tools/list  → "outputSchema": { "type": "object", ... }
     tools/call  → "structuredContent": {...} + the same JSON as text
   ```
   
   - 
`McpToolRegistrationTest.everyToolReturningANonStringPublishesAnOutputSchema` 
fails the build if a tool that returns a non-`String` leaves the flag off.
   - `McpContractConformanceIntegrationTest` (legacy protocol) and 
`McpModernContractConformanceIntegrationTest` (modern protocol) call every tool 
that has an output schema. Each one asserts:
     - the schema describes an object;
     - the call succeeds, which means the SDK's own check of 
`structuredContent` against the schema passed;
     - the text block holds the same JSON.
   - The schemas stay open to additional properties, as Spring AI publishes 
them for MCP.
   - `AGENTS.md` gains an "MCP contracts" section with the rules.
   
   ## Evidence
   
   - **Prompts:** every `prompts/get` case in `McpClientIntegrationTestBase` 
(HTTP and STDIO) asserts a description, exactly one message, `Role.USER`, and 
text content.
   - **Resources:** a new client test shows `solr://collections` returns the 
same JSON as `list-collections`. Every resource test asserts the `uri` and 
`application/json`.
   - **Completions:** a parameterised test over 0, 99, 100 and 150 matches 
checks the values, `total` and `hasMore`.
   - **Conformance on this branch** (both protocols): 13 of 14 pass.
     - **Before:** with the flag on and the old records, `list-collections`, 
`delete-alias` and `get-schema` failed.
     - **After #294:** only `get-schema` fails: `required property 'other' not 
found`. The `@JsonAnyGetter` catch-all is advertised as a required property, 
which the schema group removes.
   - Without the #294 stack, this commit built 530/0 and passed `nativeTest 
-Pnative` (349 passed, 0 failed).
   
   ## Merge Danger
   
   **Door:** two-way
   
   **Blast Radius:** tool-consumers
   
   Clients now get an `outputSchema` and `structuredContent` for 12 tools, and 
the SDK rejects any result that doesn't match its schema. Prompt messages 
change role from `assistant` to `user`.
   
   🤖 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]

Reply via email to