Commit 7aa3465
Fix JsonSchema null collection fields causing serialization failures
When an MCP server (e.g. Python/fastmcp) omits optional schema fields
like required, $defs, and definitions, Jackson deserializes them as
null. This causes failures when callers re-serialize the JsonSchema
with a standard ObjectMapper or iterate over these collections.
Add a compact constructor that defaults null collection fields to
empty immutable collections (List.of(), Map.of()). Also add
@JsonInclude(NON_EMPTY) on collection fields so that empty defaults
are omitted during serialization, preserving wire format compatibility.
Fixes #664
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 26304a7 commit 7aa3465
File tree
2 files changed
+63
-4
lines changed- mcp-core/src/main/java/io/modelcontextprotocol/spec
- mcp-test/src/test/java/io/modelcontextprotocol/spec
2 files changed
+63
-4
lines changedLines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1312 | 1312 | | |
1313 | 1313 | | |
1314 | 1314 | | |
1315 | | - | |
1316 | | - | |
| 1315 | + | |
| 1316 | + | |
1317 | 1317 | | |
1318 | | - | |
1319 | | - | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
1320 | 1332 | | |
1321 | 1333 | | |
1322 | 1334 | | |
| |||
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
774 | 821 | | |
775 | 822 | | |
776 | 823 | | |
| |||
0 commit comments