02 / IT · Analysis
MCP C# SDK v2.4.1 fixes three serialisation bugs
Changes to JSON null handling affect the order in which task extension clients and servers are updated.
The developers of the C# SDK for the Model Context Protocol (MCP) said on 4 Dec 2026 that v2.4.1 fixes three serialisation bugs. The GitHub release notes detail changes to JSON handling for tool results, user-defined objects and image and audio data.
Compatibility. The ModelContextProtocol.Extensions.Tasks extension now always includes ttlMs, the property that specifies a task's lifetime. Clients running v2.4.0 cannot read this property when its value is null. The developers recommend updating clients before servers or configuring a finite task lifetime on the server.
The list converter SingleItemOrListConverter<T> now follows the serialisation rules of the generic type T rather than each item's runtime type. Including properties specific to derived types requires JsonDerivedType metadata or a converter for T.
Null values in required properties
The default serialisation settings in McpJsonUtilities.DefaultOptions no longer omit null properties from user-defined objects. Previously, properties with null values were omitted even when outputSchema, which defines the structure of a tool's output, marked them as required. Clients that validated results against the schema rejected them.
The release notes illustrate the change with an order object's note property, which accepts a string or null but must be present in the JSON. In v2.4.1, the property is included even when its value is null, making the result conform to the output schema.
The change applies to tool return values and properties within objects that clients pass as tool arguments. Handling of top-level null arguments remains unchanged. MCP protocol types such as Tool also continue to omit optional properties with null values.
Servers and clients that distinguish between an absent property and an explicit null require code changes. Developers can retain the previous behaviour by specifying omission conditions for individual properties or in the serialisation settings, provided the output schema does not require those properties.
Restored handling of annotated tool results
The release also fixes serialisation and deserialisation failures involving content with Annotations and resource links with Icons. In v2.4.0, processing these properties triggered an InvalidOperationException. Servers returned a generic error instead of the tool result, and clients could not read annotated results.
Version v2.4.1 restores the behaviour of v2.3.1, allowing text content with audience annotations to be written to and read from JSON again. The release notes say developers can remove workarounds that stripped annotations or icons, or retried operations after the exception.
Corrected image and audio encoding
Sampling messages, which request content generation from a model, now handle media encoding differently. SamplingMessage.Content and CreateMessageResult.Content previously applied Base64 encoding twice to image and audio data. Both now encode the data once, matching standalone content blocks.
Decoding a message from the previous version once produced Base64 text rather than the original image bytes. The developers said model providers could reject such images. Receiving code that retains the double-decoding workaround will corrupt correctly encoded media.
Sending code that pre-decoded media to compensate for the duplicate encoding also requires modification. With v2.4.1, senders can return to passing the original media bytes.