Skip to content

Commit 701597c

Browse files
Remove internal usages of obsolete capability properties
Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>
1 parent f636f4b commit 701597c

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

src/ModelContextProtocol.Core/Client/McpClientImpl.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,10 @@ private void RegisterHandlers(McpClientOptions options, NotificationHandlers not
5858
{
5959
McpClientHandlers handlers = options.Handlers;
6060

61-
#pragma warning disable CS0618 // Type or member is obsolete
62-
var notificationHandlersFromOptions = handlers.NotificationHandlers ?? options.Capabilities?.NotificationHandlers;
63-
var samplingHandler = handlers.SamplingHandler ?? options.Capabilities?.Sampling?.SamplingHandler;
64-
var rootsHandler = handlers.RootsHandler ?? options.Capabilities?.Roots?.RootsHandler;
65-
var elicitationHandler = handlers.ElicitationHandler ?? options.Capabilities?.Elicitation?.ElicitationHandler;
66-
#pragma warning restore CS0618 // Type or member is obsolete
61+
var notificationHandlersFromOptions = handlers.NotificationHandlers;
62+
var samplingHandler = handlers.SamplingHandler;
63+
var rootsHandler = handlers.RootsHandler;
64+
var elicitationHandler = handlers.ElicitationHandler;
6765

6866
if (notificationHandlersFromOptions is not null)
6967
{

src/ModelContextProtocol.Core/Server/McpServerImpl.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,6 @@ private void ConfigureCompletion(McpServerOptions options)
230230
var completeHandler = options.Handlers.CompleteHandler;
231231
var completionsCapability = options.Capabilities?.Completions;
232232

233-
#pragma warning disable CS0618 // Type or member is obsolete
234-
completeHandler ??= completionsCapability?.CompleteHandler;
235-
#pragma warning restore CS0618 // Type or member is obsolete
236-
237233
if (completeHandler is null && completionsCapability is null)
238234
{
239235
return;
@@ -266,14 +262,6 @@ private void ConfigureResources(McpServerOptions options)
266262
var resources = options.ResourceCollection;
267263
var resourcesCapability = options.Capabilities?.Resources;
268264

269-
#pragma warning disable CS0618 // Type or member is obsolete
270-
listResourcesHandler ??= resourcesCapability?.ListResourcesHandler;
271-
listResourceTemplatesHandler ??= resourcesCapability?.ListResourceTemplatesHandler;
272-
readResourceHandler ??= resourcesCapability?.ReadResourceHandler;
273-
subscribeHandler ??= resourcesCapability?.SubscribeToResourcesHandler;
274-
unsubscribeHandler ??= resourcesCapability?.UnsubscribeFromResourcesHandler;
275-
#pragma warning restore CS0618 // Type or member is obsolete
276-
277265
if (listResourcesHandler is null && listResourceTemplatesHandler is null && readResourceHandler is null &&
278266
subscribeHandler is null && unsubscribeHandler is null && resources is null &&
279267
resourcesCapability is null)
@@ -427,11 +415,6 @@ private void ConfigurePrompts(McpServerOptions options)
427415
var prompts = options.PromptCollection;
428416
var promptsCapability = options.Capabilities?.Prompts;
429417

430-
#pragma warning disable CS0618 // Type or member is obsolete
431-
listPromptsHandler ??= promptsCapability?.ListPromptsHandler;
432-
getPromptHandler ??= promptsCapability?.GetPromptHandler;
433-
#pragma warning restore CS0618 // Type or member is obsolete
434-
435418
if (listPromptsHandler is null && getPromptHandler is null && prompts is null &&
436419
promptsCapability is null)
437420
{
@@ -515,11 +498,6 @@ private void ConfigureTools(McpServerOptions options)
515498
var tools = options.ToolCollection;
516499
var toolsCapability = options.Capabilities?.Tools;
517500

518-
#pragma warning disable CS0618 // Type or member is obsolete
519-
listToolsHandler ??= toolsCapability?.ListToolsHandler;
520-
callToolHandler ??= toolsCapability?.CallToolHandler;
521-
#pragma warning restore CS0618 // Type or member is obsolete
522-
523501
if (listToolsHandler is null && callToolHandler is null && tools is null &&
524502
toolsCapability is null)
525503
{
@@ -618,10 +596,6 @@ private void ConfigureLogging(McpServerOptions options)
618596
// We don't require that the handler be provided, as we always store the provided log level to the server.
619597
var setLoggingLevelHandler = options.Handlers.SetLoggingLevelHandler;
620598

621-
#pragma warning disable CS0618 // Type or member is obsolete
622-
setLoggingLevelHandler ??= options.Capabilities?.Logging?.SetLoggingLevelHandler;
623-
#pragma warning restore CS0618 // Type or member is obsolete
624-
625599
// Apply filters to the handler
626600
if (setLoggingLevelHandler is not null)
627601
{

0 commit comments

Comments
 (0)