From 7e3ea73815501f19bcc1fa20589ef386a4a760e3 Mon Sep 17 00:00:00 2001 From: Christian Tzolov <1351573+tzolov@users.noreply.github.com> Date: Sun, 14 Sep 2025 12:07:54 +0200 Subject: [PATCH] fix: Add JsonInclude annotation to notification records for proper serialization (#552) Add @JsonInclude(JsonInclude.Include.NON_ABSENT) to ResourcesUpdatedNotification and to LoggingMessageNotification This ensures that absent (null/Optional.empty()) fields are excluded from JSON serialization, preventing potential serialization issues with these MCP notification types. Signed-off-by: Christian Tzolov --- mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java b/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java index 3f81502..4e8b0fa 100644 --- a/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java +++ b/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java @@ -2203,6 +2203,7 @@ public final class McpSchema { * @param uri The updated resource uri. * @param meta See specification for notes on _meta usage */ + @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonIgnoreProperties(ignoreUnknown = true) public record ResourcesUpdatedNotification(// @formatter:off @JsonProperty("uri") String uri, @@ -2224,6 +2225,7 @@ public final class McpSchema { * @param data JSON-serializable logging data. * @param meta See specification for notes on _meta usage */ + @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonIgnoreProperties(ignoreUnknown = true) public record LoggingMessageNotification( // @formatter:off @JsonProperty("level") LoggingLevel level,