Skip to content

Releases: modelcontextprotocol/csharp-sdk

v0.4.1-preview.1

25 Nov 23:44
7f25ae9

Choose a tag to compare

v0.4.1-preview.1 Pre-release
Pre-release

This release brings protocol type standardization, several MCP specification implementations, and new features including an incremental source generator for automatic Description attributes from XML comments and client session resumption support. This release includes breaking changes to protocol types and elicitation enum schemas; refer to the Breaking Changes section below for details.

We are working toward the first stable version of the C# SDK as version 1.0.0, which will have compliance with Version 2025-11-25 of the MCP specification. We will publish at least one more pre-release version of the SDK before declaring the stable version, and breaking changes to remove obsolete interfaces and extension methods (#774) are expected as part of stabilizing the API.

Breaking Changes

Refer to the C# SDK Versioning documentation for details on versioning and breaking change policies.

  1. Audit and standardize MCP protocol types for consistency #892
    • Property mutability changes
    • Required properties changes
    • Collection types used for properties
  2. Implement SEP-1330: Standards-compliant enum schemas for elicitation #969
    • EnumSchema is marked [Obsolete] using the default CS0618 diagnostic, and it becomes an alias for LegacyTitledEnumSchema, which is also marked as [Obsolete] using the default CS0618 diagnostic

What's Changed

  • Add default value support for all primitive types in elicitation schemas (SEP-1034) #924 by @eiriktsarpalis (co-authored by @Copilot)
  • Audit protocol types #892 by @MackinnonBuck
  • Implement SEP-986: Specify Format for Tool Names #945 by @stephentoub
  • Add public constructors to McpClient types for reusing cached definitions #938 by @stephentoub (co-authored by @Copilot)
  • Tweak how McpClientTool.InvokeAsync exposes some content #941 by @stephentoub
  • Ignore unexpected properties when deserializing a ContentBlock #956 by @jeffhandley
  • Add Description property to Implementation type per MCP spec #966 by @stephentoub (co-authored by @Copilot)
  • Remove TODOs related to AllowOutOfOrderMetadataProperty workarounds #977 by @eiriktsarpalis
  • Make JsonRpcMessageWithId.RequestId non-required #984 by @MackinnonBuck
  • Implement SEP-1330: Standards-compliant enum schemas for elicitation #969 by @stephentoub (co-authored by @Copilot)
  • Add production-ready incremental source generator for automatic Description attributes from XML comments #899 by @stephentoub (co-authored by @Copilot)
  • Add tools support to sampling #976 by @stephentoub
  • Use JsonElement.Parse for string-to-JsonElement deserialization #1002 by @stephentoub (co-authored by @Copilot)
  • Fix race condition in StdioClientTransport on .NET Framework #996 by @stephentoub (co-authored by @Copilot)
  • Tokens can be cached beyond the lifetime of the (http) transport #834 by @halllo
  • Add ability for client to resume session #1029 by @halter73

Documentation Updates

Test Improvements

  • Fix tests in Dev Container #965 by @halter73
  • Skip flaky test on Mono where stderr callbacks are unsupported #980 by @stephentoub (co-authored by @Copilot)

Repository Infrastructure Updates

  • Update Microsoft.Extensions.AI packages to version 9.10.1 #916 by @stephentoub (co-authored by @Copilot)
  • Update to .NET SDK to 10.rc2 #883 by @eiriktsarpalis
  • Bump danielpalme/ReportGenerator-GitHub-Action from 5.4.17 to 5.4.18 #920
  • Bump actions/upload-artifact from 4.6.2 to 5.0.0 #918
  • Bump actions/download-artifact from 5.0.0 to 6.0.0 #919
  • Fixed dotnet version from 10.0.100-rc.1.25451.107 to 10.0.100-rc.2 #927 by @eduardomb-aw (co-authored by @eiriktsarpalis)
  • Update to .NET 10.x packages #957 by @stephentoub
  • Remove prerelease requirement from global.json #961 by @eiriktsarpalis
  • Update to MTP #958 by @Youssef1313
  • Bump actions/checkout from 5.0.0 to 5.0.1 #973
  • Bump danielpalme/ReportGenerator-GitHub-Action from 5.4.18 to 5.5.0 #972
  • Bump the opentelemetry-testing group with 6 updates #974
  • Revert "Update to MTP" #989 by @eiriktsarpalis
  • Bump the serilog-testing group with 2 updates #992
  • Bump the testing-frameworks group with 3 updates #991
  • Revert "Revert "Update to MTP"" #990 by @Youssef1313
  • Add Microsoft.CodeAnalysis.* to dependabot ignore list #1009 by @eiriktsarpalis (co-authored by @Copilot)
  • Revert "Update to MTP (#958)" #1011 by @halter73
  • Bump the testing-frameworks group with 3 updates #1013
  • Bump the serilog-testing group with 1 update #1014
  • Bump version to 0.4.1-preview.1 #1031 by @jeffhandley

Acknowledgements

Full Changelog: v0.4.0-preview.3...v0.4.1-preview.1

v0.4.0-preview.3

20 Oct 19:59
2da9299

Choose a tag to compare

v0.4.0-preview.3 Pre-release
Pre-release

This release adds icons and metadata support (SEP-973), the new McpMetaAttribute for attaching custom metadata to tools, prompts, and resources, and .NET 10.0 target framework support. It also includes several bug fixes including faster shutdown for Streamable HTTP servers, proper exception propagation through tool call filters, and a fix for templated resource matching. This release contains breaking changes — see below for details and migration guidance.

Breaking Changes

Refer to the C# SDK Versioning documentation for details on versioning and breaking change policies.

  1. McpException refactored; ErrorCode and error-code constructors moved to new McpProtocolException #844

    • McpException.ErrorCode property, McpException(string, McpErrorCode), and McpException(string, Exception?, McpErrorCode) constructors were removed. Use McpProtocolException for error-code scenarios.
    • McpException thrown from tools and tool call filters now produces an errored CallToolResult instead of a JSON-RPC error. Use McpProtocolException to produce a JSON-RPC error with a specific error code.
  2. McpServerResource.ReadAsync return type changed; new abstract IsMatch method #897

    • McpServerResource.ReadAsync return type changed from ValueTask<ReadResourceResult?> to ValueTask<ReadResourceResult>. Custom subclasses must update their signatures and throw InvalidOperationException instead of returning null for non-matching URIs.
    • New abstract method bool IsMatch(string uri) must be implemented by any custom McpServerResource subclass.
  3. StreamableHttpServerTransport method renames #843

    • HandleGetRequest renamed to HandleGetRequestAsync and HandlePostRequest renamed to HandlePostRequestAsync. Update call sites accordingly.

What's Changed

  • Implement SEP-973: Icons and metadata support for Implementations, Resources, Tools, and Prompts #802 by @MackinnonBuck (co-authored by @jozkee @Copilot)
  • Fix slow shutdown when a Streamable HTTP client is connected #843 by @halter73
  • Propagate tool call exceptions through filters #844 by @halter73 (co-authored by @stephentoub)
  • Add net10.0 assets and run some fixers #875 by @stephentoub
  • Synthesize handlers for empty tool/prompt/resource collections #865 by @stephentoub (co-authored by @Copilot)
  • Convert EverythingServer to use Streamable HTTP #709 by @mikekistler (co-authored by @halter73)
  • Add McpMetaAttribute for attaching metadata to tools, prompts, and resources #857 by @stephentoub (co-authored by @Copilot)
  • Fix regression matching templated McpServerResources #897 by @halter73
  • Call Regex.IsMatch when Match is not needed #903 by @halter73

Documentation Updates

Test Improvements

  • Remove problematic System.Net.Http package reference from tests #867 by @stephentoub
  • Add comprehensive test coverage for resource capability preservation with WithResources #896 by @stephentoub (co-authored by @Copilot)

Repository Infrastructure Updates

  • Bump version to 0.4.0-preview.3 by @halter73
  • Onboard repository to Dependabot for automated testing and AI dependency updates #800 by @eiriktsarpalis (co-authored by @Copilot)
  • Bump actions/setup-node from 4.3.0 to 5.0.0 #845
  • Bump actions/upload-pages-artifact from 3.0.1 to 4.0.0 #848
  • Bump danielpalme/ReportGenerator-GitHub-Action from 5.4.4 to 5.4.17 #847
  • Bump actions/setup-dotnet from 4.3.1 to 5.0.0 #846
  • Bump becheran/mlc from 0.21.0 to 1.0.0 #852
  • Bump actions/checkout from 4.2.2 to 5.0.0 #851
  • Bump actions/download-artifact from 4.2.1 to 5.0.0 #849
  • Fix sample projects to work in GitHub Codespaces by installing .NET 9.0 SDK #854 by @eiriktsarpalis (co-authored by @Copilot)
  • Set up Copilot instructions for repository #858 by @stephentoub (co-authored by @Copilot)
  • Pin global.json to rc.1 SDK #869 by @halter73
  • Pin GitHub workflows to rc.1 SDK #871 by @halter73
  • Add copilot-setup-steps.yml to preinstall .NET 10 SDK in GitHub Copilot environment #877 by @stephentoub (co-authored by @Copilot)
  • Move copilot-setup-steps.yml to workflows directory per GitHub documentation #879 by @stephentoub (co-authored by @Copilot)
  • Delete .github/workflows/copilot-setup-steps.yml #882 by @stephentoub
  • Add copilot setup steps #885 by @stephentoub
  • Update copilot-setup-steps.yml to use global.json for .NET SDK version #888 by @stephentoub (co-authored by @Copilot)
  • Bump the opentelemetry-testing group with 2 updates #901
  • Bump actions/setup-node from 5.0.0 to 6.0.0 #900
  • Update download-artifact path reference #905 by @jeffhandley

Acknowledgements

Full Changelog: v0.4.0-preview.2...v0.4.0-preview.3

v0.4.0-preview.2

08 Oct 18:26
da30f0e

Choose a tag to compare

v0.4.0-preview.2 Pre-release
Pre-release

This release includes a breaking change to the Streamable HTTP transport's Stateless mode, making it truly sessionless by removing the data protection dependency and session ID tracking. It also fixes an issue with sending server notifications from request-specific McpServer instances used outside their original scope.

Breaking Changes

Refer to the C# SDK Versioning documentation for details on versioning and breaking change policies.

  1. Make "Stateless" mode sessionless #760
    • McpServer.ClientInfo will always be null in stateless mode because stateless mode no longer uses a session ID or relies on data protection
    • If you need ClientInfo in your handlers, use the default stateful mode

What's Changed

  • Move options validation to constructor #826 by @halter73
  • Make "Stateless" mode sessionless #760 by @halter73
  • Update sample with URI validation #824 by @localden
  • Fix support for sending server notifications with request-specific McpServer instances used outside their original scope #832 by @eiriktsarpalis

Repository Infrastructure Updates

Acknowledgements

Full Changelog: v0.4.0-preview.1...v0.4.0-preview.2

v0.4.0-preview.1

25 Sep 16:37
be2d0f5

Choose a tag to compare

v0.4.0-preview.1 Pre-release
Pre-release

The 0.4.0-preview.1 release of the Model Context Protocol C# SDK introduces several significant breaking API changes to improve the SDK's evolution path. Interfaces have been replaced by abstract classes, factory classes have been deprecated in favor of static factory methods, SSE transport types have been renamed to HTTP, and handlers/collections have been decoupled from protocol types. This release also adds new features including ElicitAsync<T>, middleware and authorization support for server-side handlers, WithXx overloads that take target instances, and improvements to dynamic client registration.

Breaking Changes

The 0.4.0-preview.1 release includes several breaking API changes as we continue to refine the API surface area for the path toward a 1.0.0 stable release. Refer to the C# SDK Versioning documentation for information regarding our versioning, breaking change, and support approaches.

  1. Interfaces were replaced by abstract classes to better allow evolution of the API surface in future versions.
  2. Factory classes were deprecated and replaced by static factory methods to improve usability and align with existing .NET patterns such as HttpClient.
  3. The 'Sse' (Server-Sent Events) APIs were renamed to use 'Http', aligning with the revised Transports nomenclature.
  4. APIs for handlers and callbacks were decoupled from the protocol representation for improved separation of concerns.

Interfaces replaced by abstract classes

The IMcpClient, IMcpServer, and IMcpEndpoint interfaces are marked as [Obsolete] and will be removed in an upcoming release. These interfaces are replaced by new abstract classes.

Old New
IMcpClient McpClient
IMcpServer McpServer
IMcpEndpoint McpSession

Action: Replace usages of the obsolete interfaces with the new abstract types. Change variable, field, and parameter types. Optional, but recommended: rename identifiers like endpointsession for clarity.

Factory classes deprecated

The McpClientFactory and McpServerFactory classes are marked as [Obsolete] and will be removed in an upcoming release.

Old New
McpClientFactory.CreateAsync(...) McpClient.CreateAsync(...)
McpServerFactory.CreateAsync(...) McpServer.CreateAsync(...)

Action: Replace calls to the factory classes with the static factory methods on the abstract classes.

Rename SseClientTransport to HttpClientTransport

The SseClientTransport and SseClientTransportOptions classes were renamed to reflect Http naming instead of Sse.

Old New
SseClientTransport HttpClientTransport
SseClientTransportOptions HttpClientTransportOptions

Action: Update usage of these types to utilize the new type names.

Decouple handlers and collections from protocol types

Handlers and collections in the Capabilities types are now obsolete; they've been moved to McpClientOptions and McpServerOptions.

Old New
myClientOptions.Capabilities.NotificationHandlers myClientOptions.Handlers.NotificationHandlers
myClientOptions.Capabilities.Elicitation.ElicitationHandler myClientOptions.Handlers.ElicitationHandler
myClientOptions.Capabilities.Roots.RootsHandler myClientOptions.Handlers.RootsHandler
myClientOptions.Capabilities.Sampling.SamplingHandler myClientOptions.Handlers.SamplingHandler
myServerOptions.Capabilities.NotificationHandlers myServerOptions.Handlers.NotificationHandlers
myServerOptions.Capabilities.Completions.CompleteHandler myServerOptions.Handlers.CompleteHandler
myServerOptions.Capabilities.Logging.SetLoggingLevelHandler myServerOptions.Handlers.SetLoggingLevelHandler
myServerOptions.Capabilities.Prompts.ListPromptsHandler myServerOptions.Handlers.ListPromptsHandler
myServerOptions.Capabilities.Prompts.GetPromptHandler myServerOptions.Handlers.GetPromptHandler
myServerOptions.Capabilities.Prompts.PromptCollection myServerOptions.PromptCollection
myServerOptions.Capabilities.Resources.ListResourceTemplatesHandler myServerOptions.Handlers.ListResourceTemplatesHandler
myServerOptions.Capabilities.Resources.ListResourcesHandler myServerOptions.Handlers.ListResourcesHandler
myServerOptions.Capabilities.Resources.ReadResourceHandler myServerOptions.Handlers.ReadResourceHandler
myServerOptions.Capabilities.Resources.SubscribeToResourcesHandler myServerOptions.Handlers.SubscribeToResourcesHandler
myServerOptions.Capabilities.Resources.UnsubscribeFromResourcesHandler myServerOptions.Handlers.UnsubscribeFromResourcesHandler
myServerOptions.Capabilities.Resources.ResourceCollection myServerOptions.ResourceCollection
myServerOptions.Capabilities.Tools.ListToolsHandler myServerOptions.Handlers.ListToolsHandler
myServerOptions.Capabilities.Tools.CallToolHandler myServerOptions.Handlers.CallToolHandler
myServerOptions.Capabilities.Tools.ToolCollection myServerOptions.ToolCollection

Action: Replace usages of the obsolete handlers and collections with the corresponding APIs on the options types.

Collections

Old

new McpServerOptions() 
{
    Capabilities = new() 
    {
        Tools = new() 
        { 
            ToolCollection = [McpServerTool.Create(...)] 
        }
    }
};

New

new McpServerOptions()
{
    ToolCollection = [McpServerTool.Create(...)]
};

Handlers

Old

new McpServerOptions()
{
    Capabilities = new()
    {
        Tools = new()
        {
            CallToolHandler = (request, ct) => { ... }
        }
    }
};

New

new McpServerOptions()
{
    Handlers = new()
    {
        CallToolHandler = (request, ct) => { ... }
    }
};

What's Changed

Documentation Updates

Repository Infrastructure Updates

Acknowledgements

Full Changelog: v0.3.0-preview.4...v0.4.0-preview.1

v0.3.0-preview.4

20 Aug 19:09
15f8e89

Choose a tag to compare

v0.3.0-preview.4 Pre-release
Pre-release

This release includes bug fixes for ResourceLinkBlock deserialization and IEnumerable serialization, performance improvements to idle session tracking, enhanced MCP session logging, new samples, and the initial framework for conceptual documentation.

What's Changed

  • Respect HandleResponse() and SkipHandler() calls in OnResourceMetadataRequest #607 by @halter73
  • UnreferenceDisposable made slimmer #627 by @Scooletz
  • IdleTracking uses lists instead of SortedSet #629 by @Scooletz
  • Fix ResourceLinkBlock deserialization by adding missing "name" case #645 by @eiriktsarpalis (co-authored by @Copilot)
  • Add an in-memory transport sample #664 by @stephentoub
  • Remove 'Sse' from AspNetCoreSseServer sample name #665 by @halter73
  • Fix NotSupportedException when returning IEnumerable #675 by @eiriktsarpalis (co-authored by @Copilot)
  • Enhance HTTP and MCP session logging #608 by @theojiang25
  • Remove special-casing of string enumerables in McpServerTool #699 by @stephentoub
  • Prune idle sessions before starting new ones #701 by @halter73

Documentation Updates

Repository Infrastructure Updates

  • Bump version to 0.3.0-preview.4 by @halter73

Acknowledgements

Full Changelog: v0.3.0-preview.3...v0.3.0-preview.4

v0.3.0-preview.3

16 Jul 13:18
3156818

Choose a tag to compare

v0.3.0-preview.3 Pre-release
Pre-release

This release improves .NET Framework support by adding cancellable stream reader polyfills, fixes a crash when ResourceMetadata is dynamically provided via events, ensures IsExternalInit type forwarding for multi-TFM consumers, and enables IHttpContextAccessor in Streamable HTTP tool calls by flowing ExecutionContext with JSON-RPC messages. It also updates Microsoft.Extensions.AI to 9.7.1.

What's Changed

Repository Infrastructure Updates

  • Bump version to 0.3.0-preview.3 by @halter73

Acknowledgements

Full Changelog: v0.3.0-preview.2...v0.3.0-preview.3

v0.3.0-preview.2

03 Jul 21:49
a6fd6fc

Choose a tag to compare

v0.3.0-preview.2 Pre-release
Pre-release

This release introduces authorization support using ASP.NET Core's native authentication and authorization integration, enabling OAuth 2.0-protected MCP servers. It also includes improvements to URI template handling, structured output support in McpClientTool, constructor injection for IMcpServer, and a breaking change to default name casing for tools, prompts, and resources.

Breaking Changes

Refer to the C# SDK Versioning documentation for details on versioning and breaking change policies.

  1. Change default name casing of McpServerXx.Create tools/prompts/resources #568
    • Tools and resources created via McpServerTool.Create, McpServerPrompt.Create, and McpServerResource.Create without an explicit name now derive lower_snake_case names instead of using the PascalCase method name (e.g., "Echo""echo", "EchoWithUserName""echo_with_user_name").
    • Set the Name property on the [McpServerTool] attribute or pass it via the options parameter to preserve existing names.

What's Changed

Documentation Updates

  • Document default value for UseStructuredContent #539 by @S-Luiten
  • Update README.md to fix the server sample build issue #546 by @Anduin2017

Repository Infrastructure Updates

Acknowledgements

Full Changelog: v0.3.0-preview.1...v0.3.0-preview.2

v0.3.0-preview.1

20 Jun 16:18
283a052

Choose a tag to compare

v0.3.0-preview.1 Pre-release
Pre-release

The v0.3.0-preview.1 release introduces spec-aligned content type renames, session ID support across transports, structured output for server tools, and improved Streamable HTTP client behavior.

Breaking Changes

Refer to the C# SDK Versioning documentation for information regarding our versioning, breaking change, and support approaches.

  1. Content type renames to match spec #513
    • Content renamed to ContentBlock with subclasses TextContentBlock, ImageContentBlock, AudioContentBlock, and ResourceContentBlock; CallToolResponse renamed to CallToolResult; CancelledNotification renamed to CancelledNotificationParams; ProgressNotification renamed to ProgressNotificationParams; Reference replaced with derived types ResourceReference, ResourceTemplateReference, and PromptReference; CallToolRequestParams sealed
    • Migration: Update all type name references throughout consuming code; search-and-replace is mostly sufficient
  2. Session ID support added across transports #466
    • SessionId property added to the ITransport and IMcpEndpoint interfaces, requiring all custom implementations to add this member; StreamableHttpServerTransport.InitializeRequest property replaced with OnInitRequestReceived callback
    • Migration: Add public string? SessionId => null; to custom ITransport/IMcpEndpoint implementations; replace reads of .InitializeRequest with callback via .OnInitRequestReceived

What's Changed

Documentation Updates

Repository Infrastructure Updates

Acknowledgements

Full Changelog: v0.2.0-preview.3...v0.3.0-preview.1

v0.2.0-preview.3

03 Jun 20:42
046903c

Choose a tag to compare

v0.2.0-preview.3 Pre-release
Pre-release

This release introduces the ModelContextProtocol.Core package, splitting the SDK into layered packages to provide client and low-level server APIs with minimal dependencies. Protocol record types are converted to classes for better forward compatibility, elicitation support is added, and protocol version negotiation is improved.

Breaking Changes

Refer to the C# SDK Versioning documentation for details on versioning and breaking change policies.

  1. Add ModelContextProtocol.Core package #428
    • Client, protocol, transport, and core types moved from the ModelContextProtocol assembly to a new ModelContextProtocol.Core assembly; existing ModelContextProtocol package now references ModelContextProtocol.Core and provides hosting/DI extensions
    • Migration: Applications referencing ModelContextProtocol retain access to all types with no changes needed; applications wanting minimal dependencies can reference ModelContextProtocol.Core directly
  2. Convert records to classes #470
    • Nine protocol types converted from record/record struct to class: SseClientTransportOptions, StdioClientTransportOptions, ProgressNotificationValue, Annotations, InitializeResult, JsonRpcErrorDetail, PingResult, Resource, ResourceTemplate; ProgressNotificationValue changed from value type to reference type
    • Migration: Remove uses of structural equality, with expressions, and deconstruction on the affected types
  3. Improve protocol version handling #468
    • McpClientOptions.ProtocolVersion and McpServerOptions.ProtocolVersion changed from string to string?; default protocol version updated from 2024-11-05 to 2025-03-26; server now negotiates the protocol version based on the client's requested version
    • Migration: Update any code that relies on the ProtocolVersion type or the default protocol version value

What's Changed

Repository Infrastructure Updates

Acknowledgements

Full Changelog: v0.2.0-preview.2...v0.2.0-preview.3

v0.2.0-preview.2

29 May 17:01
6351b3d

Choose a tag to compare

v0.2.0-preview.2 Pre-release
Pre-release

This release replaces UseStreamableHttp with a TransportMode enum for more flexible transport configuration, with auto-detection as the new default. It also improves SSE client transport compatibility, relaxes accept header validation, and adds tool invocation error logging.

Breaking Changes

Refer to the C# SDK Versioning documentation for details on versioning and breaking change policies.

  1. Replace UseStreamableHttp with TransportMode #456
    • SseClientTransportOptions.UseStreamableHttp property removed and replaced with TransportMode of type HttpTransportMode
    • Default behavior changed from SSE-only to auto-detect (tries Streamable HTTP first, falls back to SSE)
    • Migration: UseStreamableHttp = trueTransportMode = HttpTransportMode.StreamableHttp; default/false → TransportMode = HttpTransportMode.Sse (to preserve old behavior)

What's Changed

Documentation Updates

Repository Infrastructure Updates

Acknowledgements

Full Changelog: 0.2.0-preview.1...v0.2.0-preview.2