Skip to content

Commit 7e3ea73

Browse files
authored
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 <[email protected]>
1 parent bc3a925 commit 7e3ea73

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,6 +2203,7 @@ public ProgressNotification(String progressToken, double progress, Double total,
22032203
* @param uri The updated resource uri.
22042204
* @param meta See specification for notes on _meta usage
22052205
*/
2206+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
22062207
@JsonIgnoreProperties(ignoreUnknown = true)
22072208
public record ResourcesUpdatedNotification(// @formatter:off
22082209
@JsonProperty("uri") String uri,
@@ -2224,6 +2225,7 @@ public ResourcesUpdatedNotification(String uri) {
22242225
* @param data JSON-serializable logging data.
22252226
* @param meta See specification for notes on _meta usage
22262227
*/
2228+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
22272229
@JsonIgnoreProperties(ignoreUnknown = true)
22282230
public record LoggingMessageNotification( // @formatter:off
22292231
@JsonProperty("level") LoggingLevel level,

0 commit comments

Comments
 (0)