From 49cf4a8ca86dbf610b2882dd9eacdb03dc72f782 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 23:11:27 +0000 Subject: [PATCH 1/4] Initial plan From 2d5f5690456ba7ac9c084c5535bd184ec06d9927 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 23:22:19 +0000 Subject: [PATCH 2/4] Add explicit protected constructors with [Experimental] to McpClient and McpServer Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> --- docs/list-of-diagnostics.md | 3 ++- src/Common/Experimentals.cs | 15 +++++++++++++++ src/ModelContextProtocol.Core/Client/McpClient.cs | 11 ++++++++++- .../Client/McpClientImpl.cs | 1 + .../Server/DestinationBoundMcpServer.cs | 2 ++ src/ModelContextProtocol.Core/Server/McpServer.cs | 9 +++++++++ .../Server/McpServerImpl.cs | 1 + .../Server/McpServerTests.cs | 2 ++ 8 files changed, 42 insertions(+), 2 deletions(-) diff --git a/docs/list-of-diagnostics.md b/docs/list-of-diagnostics.md index 573d97fea..483a6041f 100644 --- a/docs/list-of-diagnostics.md +++ b/docs/list-of-diagnostics.md @@ -23,4 +23,5 @@ If you use experimental APIs, you will get one of the diagnostics shown below. T | Diagnostic ID | Description | | :------------ | :---------- | -| `MCPEXP001` | MCP experimental APIs including Tasks and Extensions. Tasks provide a mechanism for asynchronous long-running operations that can be polled for status and results (see [MCP Tasks specification](https://modelcontextprotocol.io/specification/draft/basic/utilities/tasks)). Extensions provide a framework for extending the Model Context Protocol while maintaining interoperability (see [SEP-2133](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133)). | \ No newline at end of file +| `MCPEXP001` | MCP experimental APIs including Tasks and Extensions. Tasks provide a mechanism for asynchronous long-running operations that can be polled for status and results (see [MCP Tasks specification](https://modelcontextprotocol.io/specification/draft/basic/utilities/tasks)). Extensions provide a framework for extending the Model Context Protocol while maintaining interoperability (see [SEP-2133](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133)). | +| `MCPEXP002` | Subclassing `McpClient` and `McpServer` is experimental and subject to change. | \ No newline at end of file diff --git a/src/Common/Experimentals.cs b/src/Common/Experimentals.cs index ec2c7c550..d76996e2b 100644 --- a/src/Common/Experimentals.cs +++ b/src/Common/Experimentals.cs @@ -56,4 +56,19 @@ internal static class Experimentals /// URL for the experimental MCP Extensions feature. /// public const string Extensions_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp001"; + + /// + /// Diagnostic ID for experimental subclassing of McpClient and McpServer. + /// + public const string Subclassing_DiagnosticId = "MCPEXP002"; + + /// + /// Message for experimental subclassing of McpClient and McpServer. + /// + public const string Subclassing_Message = "Subclassing McpClient and McpServer is experimental and subject to change."; + + /// + /// URL for experimental subclassing of McpClient and McpServer. + /// + public const string Subclassing_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp002"; } diff --git a/src/ModelContextProtocol.Core/Client/McpClient.cs b/src/ModelContextProtocol.Core/Client/McpClient.cs index 28a37f258..acd0bb12d 100644 --- a/src/ModelContextProtocol.Core/Client/McpClient.cs +++ b/src/ModelContextProtocol.Core/Client/McpClient.cs @@ -1,4 +1,5 @@ -using ModelContextProtocol.Protocol; +using System.Diagnostics.CodeAnalysis; +using ModelContextProtocol.Protocol; namespace ModelContextProtocol.Client; @@ -7,6 +8,14 @@ namespace ModelContextProtocol.Client; /// public abstract partial class McpClient : McpSession { + /// + /// Initializes a new instance of the class. + /// + [Experimental(Experimentals.Subclassing_DiagnosticId, UrlFormat = Experimentals.Subclassing_Url)] + protected McpClient() + { + } + /// /// Gets the capabilities supported by the connected server. /// diff --git a/src/ModelContextProtocol.Core/Client/McpClientImpl.cs b/src/ModelContextProtocol.Core/Client/McpClientImpl.cs index 9375e2760..ab45a8a9f 100644 --- a/src/ModelContextProtocol.Core/Client/McpClientImpl.cs +++ b/src/ModelContextProtocol.Core/Client/McpClientImpl.cs @@ -6,6 +6,7 @@ namespace ModelContextProtocol.Client; /// +#pragma warning disable MCPEXP002 // Subclassing McpClient is experimental internal sealed partial class McpClientImpl : McpClient { private static Implementation DefaultImplementation { get; } = new() diff --git a/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs b/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs index 784e0f9a6..cc8bdd09c 100644 --- a/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs +++ b/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs @@ -3,7 +3,9 @@ namespace ModelContextProtocol.Server; +#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental internal sealed class DestinationBoundMcpServer(McpServerImpl server, ITransport? transport) : McpServer +#pragma warning restore MCPEXP002 { public override string? SessionId => transport?.SessionId ?? server.SessionId; public override string? NegotiatedProtocolVersion => server.NegotiatedProtocolVersion; diff --git a/src/ModelContextProtocol.Core/Server/McpServer.cs b/src/ModelContextProtocol.Core/Server/McpServer.cs index 2d8ea6826..b8b41bdc3 100644 --- a/src/ModelContextProtocol.Core/Server/McpServer.cs +++ b/src/ModelContextProtocol.Core/Server/McpServer.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using ModelContextProtocol.Protocol; namespace ModelContextProtocol.Server; @@ -7,6 +8,14 @@ namespace ModelContextProtocol.Server; /// public abstract partial class McpServer : McpSession { + /// + /// Initializes a new instance of the class. + /// + [Experimental(Experimentals.Subclassing_DiagnosticId, UrlFormat = Experimentals.Subclassing_Url)] + protected McpServer() + { + } + /// /// Gets the capabilities supported by the client. /// diff --git a/src/ModelContextProtocol.Core/Server/McpServerImpl.cs b/src/ModelContextProtocol.Core/Server/McpServerImpl.cs index 52e538e7e..8f302a95d 100644 --- a/src/ModelContextProtocol.Core/Server/McpServerImpl.cs +++ b/src/ModelContextProtocol.Core/Server/McpServerImpl.cs @@ -9,6 +9,7 @@ namespace ModelContextProtocol.Server; /// +#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental internal sealed partial class McpServerImpl : McpServer { internal static Implementation DefaultImplementation { get; } = new() diff --git a/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs b/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs index 046f08e8b..b880459b3 100644 --- a/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs +++ b/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs @@ -943,7 +943,9 @@ private static async Task InitializeServerAsync(TestServerTransport transport, C await tcs.Task.WaitAsync(TestConstants.DefaultTimeout, cancellationToken); } +#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental private sealed class TestServerForIChatClient(bool supportsSampling) : McpServer +#pragma warning restore MCPEXP002 { public override ClientCapabilities? ClientCapabilities => supportsSampling ? new ClientCapabilities { Sampling = new SamplingCapability() } : From ff5e1dc54643eca7522c242fef2eafca8bf55ab0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 23:30:36 +0000 Subject: [PATCH 3/4] Use existing MCPEXP001 diagnostic and add proper pragma warning restore Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> --- docs/list-of-diagnostics.md | 3 +-- src/Common/Experimentals.cs | 15 --------------- src/ModelContextProtocol.Core/Client/McpClient.cs | 2 +- .../Client/McpClientImpl.cs | 3 ++- .../Server/DestinationBoundMcpServer.cs | 4 ++-- src/ModelContextProtocol.Core/Server/McpServer.cs | 2 +- .../Server/McpServerImpl.cs | 3 ++- .../Server/McpServerTests.cs | 4 ++-- 8 files changed, 11 insertions(+), 25 deletions(-) diff --git a/docs/list-of-diagnostics.md b/docs/list-of-diagnostics.md index 483a6041f..573d97fea 100644 --- a/docs/list-of-diagnostics.md +++ b/docs/list-of-diagnostics.md @@ -23,5 +23,4 @@ If you use experimental APIs, you will get one of the diagnostics shown below. T | Diagnostic ID | Description | | :------------ | :---------- | -| `MCPEXP001` | MCP experimental APIs including Tasks and Extensions. Tasks provide a mechanism for asynchronous long-running operations that can be polled for status and results (see [MCP Tasks specification](https://modelcontextprotocol.io/specification/draft/basic/utilities/tasks)). Extensions provide a framework for extending the Model Context Protocol while maintaining interoperability (see [SEP-2133](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133)). | -| `MCPEXP002` | Subclassing `McpClient` and `McpServer` is experimental and subject to change. | \ No newline at end of file +| `MCPEXP001` | MCP experimental APIs including Tasks and Extensions. Tasks provide a mechanism for asynchronous long-running operations that can be polled for status and results (see [MCP Tasks specification](https://modelcontextprotocol.io/specification/draft/basic/utilities/tasks)). Extensions provide a framework for extending the Model Context Protocol while maintaining interoperability (see [SEP-2133](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133)). | \ No newline at end of file diff --git a/src/Common/Experimentals.cs b/src/Common/Experimentals.cs index d76996e2b..ec2c7c550 100644 --- a/src/Common/Experimentals.cs +++ b/src/Common/Experimentals.cs @@ -56,19 +56,4 @@ internal static class Experimentals /// URL for the experimental MCP Extensions feature. /// public const string Extensions_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp001"; - - /// - /// Diagnostic ID for experimental subclassing of McpClient and McpServer. - /// - public const string Subclassing_DiagnosticId = "MCPEXP002"; - - /// - /// Message for experimental subclassing of McpClient and McpServer. - /// - public const string Subclassing_Message = "Subclassing McpClient and McpServer is experimental and subject to change."; - - /// - /// URL for experimental subclassing of McpClient and McpServer. - /// - public const string Subclassing_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp002"; } diff --git a/src/ModelContextProtocol.Core/Client/McpClient.cs b/src/ModelContextProtocol.Core/Client/McpClient.cs index acd0bb12d..169137d20 100644 --- a/src/ModelContextProtocol.Core/Client/McpClient.cs +++ b/src/ModelContextProtocol.Core/Client/McpClient.cs @@ -11,7 +11,7 @@ public abstract partial class McpClient : McpSession /// /// Initializes a new instance of the class. /// - [Experimental(Experimentals.Subclassing_DiagnosticId, UrlFormat = Experimentals.Subclassing_Url)] + [Experimental(Experimentals.Tasks_DiagnosticId, UrlFormat = Experimentals.Tasks_Url)] protected McpClient() { } diff --git a/src/ModelContextProtocol.Core/Client/McpClientImpl.cs b/src/ModelContextProtocol.Core/Client/McpClientImpl.cs index ab45a8a9f..9034cfcb0 100644 --- a/src/ModelContextProtocol.Core/Client/McpClientImpl.cs +++ b/src/ModelContextProtocol.Core/Client/McpClientImpl.cs @@ -6,9 +6,10 @@ namespace ModelContextProtocol.Client; /// -#pragma warning disable MCPEXP002 // Subclassing McpClient is experimental +#pragma warning disable MCPEXP001 internal sealed partial class McpClientImpl : McpClient { +#pragma warning restore MCPEXP001 private static Implementation DefaultImplementation { get; } = new() { Name = AssemblyNameHelper.DefaultAssemblyName.Name ?? nameof(McpClient), diff --git a/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs b/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs index cc8bdd09c..854b5c712 100644 --- a/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs +++ b/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs @@ -3,9 +3,9 @@ namespace ModelContextProtocol.Server; -#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental +#pragma warning disable MCPEXP001 internal sealed class DestinationBoundMcpServer(McpServerImpl server, ITransport? transport) : McpServer -#pragma warning restore MCPEXP002 +#pragma warning restore MCPEXP001 { public override string? SessionId => transport?.SessionId ?? server.SessionId; public override string? NegotiatedProtocolVersion => server.NegotiatedProtocolVersion; diff --git a/src/ModelContextProtocol.Core/Server/McpServer.cs b/src/ModelContextProtocol.Core/Server/McpServer.cs index b8b41bdc3..cf141b3cd 100644 --- a/src/ModelContextProtocol.Core/Server/McpServer.cs +++ b/src/ModelContextProtocol.Core/Server/McpServer.cs @@ -11,7 +11,7 @@ public abstract partial class McpServer : McpSession /// /// Initializes a new instance of the class. /// - [Experimental(Experimentals.Subclassing_DiagnosticId, UrlFormat = Experimentals.Subclassing_Url)] + [Experimental(Experimentals.Tasks_DiagnosticId, UrlFormat = Experimentals.Tasks_Url)] protected McpServer() { } diff --git a/src/ModelContextProtocol.Core/Server/McpServerImpl.cs b/src/ModelContextProtocol.Core/Server/McpServerImpl.cs index 8f302a95d..e9ec6a111 100644 --- a/src/ModelContextProtocol.Core/Server/McpServerImpl.cs +++ b/src/ModelContextProtocol.Core/Server/McpServerImpl.cs @@ -9,9 +9,10 @@ namespace ModelContextProtocol.Server; /// -#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental +#pragma warning disable MCPEXP001 internal sealed partial class McpServerImpl : McpServer { +#pragma warning restore MCPEXP001 internal static Implementation DefaultImplementation { get; } = new() { Name = AssemblyNameHelper.DefaultAssemblyName.Name ?? nameof(McpServer), diff --git a/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs b/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs index b880459b3..f39993065 100644 --- a/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs +++ b/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs @@ -943,9 +943,9 @@ private static async Task InitializeServerAsync(TestServerTransport transport, C await tcs.Task.WaitAsync(TestConstants.DefaultTimeout, cancellationToken); } -#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental +#pragma warning disable MCPEXP001 private sealed class TestServerForIChatClient(bool supportsSampling) : McpServer -#pragma warning restore MCPEXP002 +#pragma warning restore MCPEXP001 { public override ClientCapabilities? ClientCapabilities => supportsSampling ? new ClientCapabilities { Sampling = new SamplingCapability() } : From 5140ed05d5dc13b2539436bac59e9e0efb34f7b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 00:58:29 +0000 Subject: [PATCH 4/4] Introduce distinct MCPEXP002 diagnostic for subclassing McpClient/McpServer Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com> --- docs/list-of-diagnostics.md | 3 ++- src/Common/Experimentals.cs | 15 +++++++++++++++ src/ModelContextProtocol.Core/Client/McpClient.cs | 2 +- .../Client/McpClientImpl.cs | 4 ++-- .../Server/DestinationBoundMcpServer.cs | 4 ++-- src/ModelContextProtocol.Core/Server/McpServer.cs | 2 +- .../Server/McpServerImpl.cs | 4 ++-- .../Server/McpServerTests.cs | 4 ++-- 8 files changed, 27 insertions(+), 11 deletions(-) diff --git a/docs/list-of-diagnostics.md b/docs/list-of-diagnostics.md index 573d97fea..c501928ae 100644 --- a/docs/list-of-diagnostics.md +++ b/docs/list-of-diagnostics.md @@ -23,4 +23,5 @@ If you use experimental APIs, you will get one of the diagnostics shown below. T | Diagnostic ID | Description | | :------------ | :---------- | -| `MCPEXP001` | MCP experimental APIs including Tasks and Extensions. Tasks provide a mechanism for asynchronous long-running operations that can be polled for status and results (see [MCP Tasks specification](https://modelcontextprotocol.io/specification/draft/basic/utilities/tasks)). Extensions provide a framework for extending the Model Context Protocol while maintaining interoperability (see [SEP-2133](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133)). | \ No newline at end of file +| `MCPEXP001` | MCP experimental APIs including Tasks and Extensions. Tasks provide a mechanism for asynchronous long-running operations that can be polled for status and results (see [MCP Tasks specification](https://modelcontextprotocol.io/specification/draft/basic/utilities/tasks)). Extensions provide a framework for extending the Model Context Protocol while maintaining interoperability (see [SEP-2133](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133)). | +| `MCPEXP002` | Subclassing `McpClient` and `McpServer` is experimental and subject to change (see [#1363](https://github.com/modelcontextprotocol/csharp-sdk/pull/1363)). | \ No newline at end of file diff --git a/src/Common/Experimentals.cs b/src/Common/Experimentals.cs index ec2c7c550..dd37a0766 100644 --- a/src/Common/Experimentals.cs +++ b/src/Common/Experimentals.cs @@ -56,4 +56,19 @@ internal static class Experimentals /// URL for the experimental MCP Extensions feature. /// public const string Extensions_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp001"; + + /// + /// Diagnostic ID for experimental subclassing of McpClient and McpServer. + /// + public const string Subclassing_DiagnosticId = "MCPEXP002"; + + /// + /// Message for experimental subclassing of McpClient and McpServer. + /// + public const string Subclassing_Message = "Subclassing McpClient and McpServer is experimental and subject to change."; + + /// + /// URL for experimental subclassing of McpClient and McpServer. + /// + public const string Subclassing_Url = "https://github.com/modelcontextprotocol/csharp-sdk/pull/1363"; } diff --git a/src/ModelContextProtocol.Core/Client/McpClient.cs b/src/ModelContextProtocol.Core/Client/McpClient.cs index 169137d20..acd0bb12d 100644 --- a/src/ModelContextProtocol.Core/Client/McpClient.cs +++ b/src/ModelContextProtocol.Core/Client/McpClient.cs @@ -11,7 +11,7 @@ public abstract partial class McpClient : McpSession /// /// Initializes a new instance of the class. /// - [Experimental(Experimentals.Tasks_DiagnosticId, UrlFormat = Experimentals.Tasks_Url)] + [Experimental(Experimentals.Subclassing_DiagnosticId, UrlFormat = Experimentals.Subclassing_Url)] protected McpClient() { } diff --git a/src/ModelContextProtocol.Core/Client/McpClientImpl.cs b/src/ModelContextProtocol.Core/Client/McpClientImpl.cs index 9034cfcb0..8317656d0 100644 --- a/src/ModelContextProtocol.Core/Client/McpClientImpl.cs +++ b/src/ModelContextProtocol.Core/Client/McpClientImpl.cs @@ -6,10 +6,9 @@ namespace ModelContextProtocol.Client; /// -#pragma warning disable MCPEXP001 +#pragma warning disable MCPEXP002 internal sealed partial class McpClientImpl : McpClient { -#pragma warning restore MCPEXP001 private static Implementation DefaultImplementation { get; } = new() { Name = AssemblyNameHelper.DefaultAssemblyName.Name ?? nameof(McpClient), @@ -39,6 +38,7 @@ internal sealed partial class McpClientImpl : McpClient /// Options for the client, defining protocol version and capabilities. /// The logger factory. internal McpClientImpl(ITransport transport, string endpointName, McpClientOptions? options, ILoggerFactory? loggerFactory) +#pragma warning restore MCPEXP002 { options ??= new(); diff --git a/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs b/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs index 854b5c712..957f58a51 100644 --- a/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs +++ b/src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs @@ -3,9 +3,9 @@ namespace ModelContextProtocol.Server; -#pragma warning disable MCPEXP001 +#pragma warning disable MCPEXP002 internal sealed class DestinationBoundMcpServer(McpServerImpl server, ITransport? transport) : McpServer -#pragma warning restore MCPEXP001 +#pragma warning restore MCPEXP002 { public override string? SessionId => transport?.SessionId ?? server.SessionId; public override string? NegotiatedProtocolVersion => server.NegotiatedProtocolVersion; diff --git a/src/ModelContextProtocol.Core/Server/McpServer.cs b/src/ModelContextProtocol.Core/Server/McpServer.cs index cf141b3cd..b8b41bdc3 100644 --- a/src/ModelContextProtocol.Core/Server/McpServer.cs +++ b/src/ModelContextProtocol.Core/Server/McpServer.cs @@ -11,7 +11,7 @@ public abstract partial class McpServer : McpSession /// /// Initializes a new instance of the class. /// - [Experimental(Experimentals.Tasks_DiagnosticId, UrlFormat = Experimentals.Tasks_Url)] + [Experimental(Experimentals.Subclassing_DiagnosticId, UrlFormat = Experimentals.Subclassing_Url)] protected McpServer() { } diff --git a/src/ModelContextProtocol.Core/Server/McpServerImpl.cs b/src/ModelContextProtocol.Core/Server/McpServerImpl.cs index e9ec6a111..39feae5d6 100644 --- a/src/ModelContextProtocol.Core/Server/McpServerImpl.cs +++ b/src/ModelContextProtocol.Core/Server/McpServerImpl.cs @@ -9,10 +9,9 @@ namespace ModelContextProtocol.Server; /// -#pragma warning disable MCPEXP001 +#pragma warning disable MCPEXP002 internal sealed partial class McpServerImpl : McpServer { -#pragma warning restore MCPEXP001 internal static Implementation DefaultImplementation { get; } = new() { Name = AssemblyNameHelper.DefaultAssemblyName.Name ?? nameof(McpServer), @@ -56,6 +55,7 @@ internal sealed partial class McpServerImpl : McpServer /// Optional service provider to use for dependency injection /// The server was incorrectly configured. public McpServerImpl(ITransport transport, McpServerOptions options, ILoggerFactory? loggerFactory, IServiceProvider? serviceProvider) +#pragma warning restore MCPEXP002 { Throw.IfNull(transport); Throw.IfNull(options); diff --git a/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs b/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs index f39993065..53fd50685 100644 --- a/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs +++ b/tests/ModelContextProtocol.Tests/Server/McpServerTests.cs @@ -943,9 +943,9 @@ private static async Task InitializeServerAsync(TestServerTransport transport, C await tcs.Task.WaitAsync(TestConstants.DefaultTimeout, cancellationToken); } -#pragma warning disable MCPEXP001 +#pragma warning disable MCPEXP002 private sealed class TestServerForIChatClient(bool supportsSampling) : McpServer -#pragma warning restore MCPEXP001 +#pragma warning restore MCPEXP002 { public override ClientCapabilities? ClientCapabilities => supportsSampling ? new ClientCapabilities { Sampling = new SamplingCapability() } :