Conversation
|
One abstraction/coverage concern with the strict path: it now depends on the concrete shape returned by
That is true for the Jackson configurations covered here, but Could we pin the intended contract with a mapper-neutral/custom-transport regression (and ideally normalize through an SDK JSON-object abstraction rather than concrete Java container classes)? At minimum, documenting that strict content validation requires This is opt-in, so it is not a default-path regression, but it is a new requirement on an otherwise transport-neutral client feature. AI-assisted review; checked the current head and |
CallToolResult.fromJsonreplaces missing or nullcontentwith an empty list. Applications then cannot distinguish these responses from a validcontent: []result.This adds
validateCallToolResultContent(true)to the synchronous and asynchronous client builders. When enabled,callToolchecks the raw result before converting it toCallToolResult, rejecting missing, null, or non-array content withIllegalArgumentException. An explicit empty array remains valid.The option follows the existing
McpClientFeatures.Sync/Asyncwiring. Validation accepts bothListandObject[]representations of JSON arrays, including Jackson'sUSE_JAVA_ARRAY_FOR_JSON_ARRAYsetting.The option defaults to false, preserving the compatibility behavior introduced in #928. It is independent of tool output-schema validation and does not enable strict validation of other MCP messages. Validation failures do not retry the tool call or undo server-side effects.
Validation on Java 17, with both Jackson 2 and Jackson 3:
This is a proposed public API. Please confirm the scope and naming in the related enhancement issue before requesting review.
AI-assisted implementation, submitted for human review.
Fixes #1148