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.
- Interfaces were replaced by abstract classes to better allow evolution of the API surface in future versions.
- Factory classes were deprecated and replaced by static factory methods to improve usability and align with existing .NET patterns such as
HttpClient. - The 'Sse' (Server-Sent Events) APIs were renamed to use 'Http', aligning with the revised Transports nomenclature.
- 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 endpoint → session 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
- Add WithXx overloads that take target instance #706 by @stephentoub
- Improvements to dynamic client registration #609 by @S-Luiten
- Improved samples: added weather tool in AspNetCoreSseServer and option to connect via HTTP to AspNetCoreSseServer #469 by @sabbadino
- Convert ValueStringBuilder.cs to file-scoped namespaces #746 by @Revazashvili
- Per RouteValue Tools Sample #724 by @PederHP
- Add middleware and authz support for server-side handlers #733 by @halter73
- Add ElicitAsync<T> #715 by @mehrandvd (co-authored by @eiriktsarpalis @stephentoub)
- Restructure
IMcpEndpoint,IMcpClient, andIMcpServer#723 by @MackinnonBuck (co-authored by @halter73) - Add McpSession.NegotiatedProtocolVersion property #794 by @eiriktsarpalis
- Decouple Handlers and Collections from protocol types #765 by @jozkee
- Fix stdio client transport CLI argument escaping #811 by @eiriktsarpalis
Documentation Updates
- Add articles on logging and progress #717 by @mikekistler
- Clarify default value in ElicitResult documentation #731 by @timheuer
- Fix typo in LoggingTools.cs #740 by @ElanHasson
- Correct 'McpTool' to 'McpServerTool' in README #775 by @asklar
- Add conceptual docs on accessing HttpContext #771 by @mikekistler (co-authored by @Copilot)
Repository Infrastructure Updates
- Bump version to 0.3.0-preview.5 by @halter73
- Update packages and Infra #732 by @eiriktsarpalis
- Include docs samples in solution build #751 by @mikekistler
- Update MEAI dependencies #801 by @eiriktsarpalis
- Add devcontainer.json to support .NET 9 samples in GitHub Codespaces #779 by @eiriktsarpalis (co-authored by @Copilot)
- Bump M.E.AI version #817 by @stephentoub
- Bump to 0.4.0-preview.1 for releasing breaking changes #813 by @jeffhandley
Acknowledgements
- @sabbadino made their first contribution in #469
- @S-Luiten made their first contribution in #609
- @Revazashvili made their first contribution in #746
- @ElanHasson made their first contribution in #740
- @mehrandvd made their first contribution in #715
- @asklar made their first contribution in #775
- @MackinnonBuck made their first contribution in #723
- @jozkee made their first contribution in #765
- @JH8676 submitted #668 (resolved by #794)
- @adner submitted #594 (resolved by #811)
- @DavidParks8 @sayiedanwartt-design reviewed pull requests
Full Changelog: v0.3.0-preview.4...v0.4.0-preview.1