Skip to content

Commit 85956c7

Browse files
committed
Remove setters from McpServerOptions.Filters and Handlers
- We can add internal properties later to lazily check if the getters have been used to avoid allocations if we care
1 parent 854776f commit 85956c7

2 files changed

Lines changed: 269 additions & 279 deletions

File tree

src/ModelContextProtocol.Core/Server/McpServerOptions.cs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,35 +83,19 @@ public sealed class McpServerOptions
8383
public Implementation? KnownClientInfo { get; set; }
8484

8585
/// <summary>
86-
/// Gets the filter collections for MCP server handlers.
86+
/// Gets or sets the container of handlers used by the server for processing protocol messages.
87+
/// </summary>
88+
public McpServerHandlers Handlers { get; } = new();
89+
90+
/// <summary>
91+
/// Gets the filter collections for incoming and outgoing messages and requests.
8792
/// </summary>
8893
/// <remarks>
8994
/// This property provides access to filter collections that can be used to modify the behavior
9095
/// of various MCP server handlers. The first filter added is the outermost (first to execute),
9196
/// and each subsequent filter wraps closer to the handler.
9297
/// </remarks>
93-
public McpServerFilters Filters
94-
{
95-
get => field ??= new();
96-
set
97-
{
98-
Throw.IfNull(value);
99-
field = value;
100-
}
101-
}
102-
103-
/// <summary>
104-
/// Gets or sets the container of handlers used by the server for processing protocol messages.
105-
/// </summary>
106-
public McpServerHandlers Handlers
107-
{
108-
get => field ??= new();
109-
set
110-
{
111-
Throw.IfNull(value);
112-
field = value;
113-
}
114-
}
98+
public McpServerFilters Filters { get; } = new();
11599

116100
/// <summary>
117101
/// Gets or sets a collection of tools served by the server.

0 commit comments

Comments
 (0)