v0.4.0-preview.1
Pre-releaseBreaking Changes
The v0.4.0-preview.1 release includes several breaking API changes, included in #723 and #765.
- 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 articles on logging and progress by @mikekistler in #717
- Update packages and Infra by @eiriktsarpalis in #732
- Clarify default value in ElicitResult documentation by @timheuer in #731
- Add WithXx overloads that take target instance by @stephentoub in #706
- Improvements to dynamic client registration by @S-Luiten in #609
- Improved samples: added weather tool in AspNetCoreSseServer and option to connect via http to AspNetCoreSseServer. by @sabbadino in #469
- Convert ValueStringBuilder.cs to file-scoped namespaces by @Revazashvili in #746
- Include docs samples in solution build by @mikekistler in #751
- Fix typo in LoggingTools.cs by @ElanHasson in #740
- Per RouteValue Tools Sample by @PederHP in #724
- Add middleware and authz support for server-side handlers by @halter73 in #733
- Add ElicitAsync (#630) by @mehrandvd in #715
- Correct 'McpTool' to 'McpServerTool' in README by @asklar in #775
- Restructure
IMcpEndpoint
,IMcpClient
, andIMcpServer
by @MackinnonBuck in #723 - Add McpSession.NegotiatedProtocolVersion property. by @eiriktsarpalis in #794
- Update MEAI dependencies. by @eiriktsarpalis in #801
- Add conceptual docs on accessing HttpContext by @mikekistler in #771
- Decouple Handlers and Collections from protocol types by @jozkee in #765
- Add devcontainer.json to support .NET 9 samples in GitHub Codespaces by @Copilot in #779
- Fix stdio client transport CLI argument escaping. by @eiriktsarpalis in #811
- Bump M.E.AI version by @stephentoub in #817
- Bump to 0.4.0-preview.1 for releasing breaking changes by @jeffhandley in #813
New Contributors
- @sabbadino made their first contribution in #469
- @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
Full Changelog: v0.3.0-preview.4...v0.4.0-preview.1