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 <christian.tzolov@broadcom.com>
This commit is contained in:
Christian Tzolov 2025-09-14 12:07:54 +02:00 • committed by GitHub
commit 7e3ea73815
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,