Skip to content

Commit b1741f7

Browse files
Copilotstephentoub
andcommitted
Seal McpClientHandlers and add setter to McpServerOptions.Handlers for consistency
- McpClientHandlers is now sealed, matching McpServerHandlers - McpServerOptions.Handlers now has get+set with null validation, matching McpClientOptions.Handlers Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
1 parent 09b2c8b commit b1741f7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/ModelContextProtocol.Core/Client/McpClientHandlers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace ModelContextProtocol.Client;
2222
/// is done based on an ordinal, case-sensitive string comparison.
2323
/// </para>
2424
/// </remarks>
25-
public class McpClientHandlers
25+
public sealed class McpClientHandlers
2626
{
2727
/// <summary>Gets or sets notification handlers to register with the client.</summary>
2828
/// <remarks>

src/ModelContextProtocol.Core/Server/McpServerOptions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,15 @@ public sealed class McpServerOptions
9797
/// <summary>
9898
/// Gets or sets the container of handlers used by the server for processing protocol messages.
9999
/// </summary>
100-
public McpServerHandlers Handlers { get; } = new();
100+
public McpServerHandlers Handlers
101+
{
102+
get => field ??= new();
103+
set
104+
{
105+
Throw.IfNull(value);
106+
field = value;
107+
}
108+
}
101109

102110
/// <summary>
103111
/// Gets the filter collections for MCP server handlers.

0 commit comments

Comments
 (0)