You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3fd1642
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/client.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -496,6 +496,27 @@ var client = McpClient.sync(transport)
496
496
.build();
497
497
```
498
498
499
+
### Required Tool Result Content
500
+
501
+
By default, the SDK accepts a `tools/call` result with missing or null `content` and
502
+
replaces it with an empty list. To reject these responses before that substitution,
503
+
enable content validation on either the synchronous or asynchronous client builder:
504
+
505
+
```java
506
+
var client =McpClient.async(transport)
507
+
.validateCallToolResultContent(true)
508
+
.build();
509
+
```
510
+
511
+
With this option enabled, `callTool` fails with `IllegalArgumentException` when
512
+
`content` is missing, null, or not an array, including when `isError` is true.
513
+
An explicit `content: []` remains valid. This validates the required content field;
514
+
it is separate from validating `structuredContent` against a tool's `outputSchema`.
515
+
It does not enable strict validation for other MCP messages.
516
+
517
+
A rejected response does not imply that the server rolled back the tool's effects.
518
+
The SDK does not retry the tool call because content validation failed.
519
+
499
520
### Pagination
500
521
501
522
`listTools`, `listResources`, `listResourceTemplates`, and `listPrompts` all accept an optional opaque `cursor` string, and their results carry a `nextCursor` that is non-null while more pages remain. Loop until `nextCursor` is `null` to collect every page:
0 commit comments