From b41b2d931885f92972914c156d37efc65c67c8ac Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Sun, 14 Sep 2025 11:33:45 +0200 Subject: [PATCH] fix: Add JsonInclude annotation to notification records for proper serialization 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 3f8150271..4e8b0fa06 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 ProgressNotification(String progressToken, double progress, Double total, * @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 ResourcesUpdatedNotification(String uri) { * @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,