Skip to content

Commit 61a417f

Browse files
committed
docs: clarify structured output validation timing
1 parent b33c811 commit 61a417f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,23 @@ Structured results are automatically validated against the output schema
394394
generated from the annotation. This ensures the tool returns well-typed,
395395
validated data that clients can easily process.
396396

397+
##### Validation Timing and Side Effects
398+
399+
Output-schema validation happens after the tool function returns. If a tool
400+
performs side effects before returning, those side effects are not rolled back
401+
when structured-output validation fails.
402+
403+
A validation failure means the tool implementation and its declared schema are
404+
out of sync. Treat it as a server bug, not as a signal that the operation was
405+
safe to retry.
406+
407+
For tools with important side effects, prefer patterns that make the state
408+
explicit, for example:
409+
410+
- return an operation or job identifier and expose completion state separately
411+
- separate "start work" from "fetch result" into different tools or resources
412+
- keep the structured result shape stable and version schema changes carefully
413+
397414
**Note:** For backward compatibility, unstructured results are also
398415
returned. Unstructured results are provided for backward compatibility
399416
with previous versions of the MCP specification, and are quirks-compatible

0 commit comments

Comments
 (0)