Skip to content

v0.4.0-preview.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@jeffhandley jeffhandley released this 25 Sep 16:37
be2d0f5

Breaking Changes

The v0.4.0-preview.1 release includes several breaking API changes, included in #723 and #765.

  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

New Contributors

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