Skip to content

Commit 8ddb3cc

Browse files
tarekghTarek Mahmoud Sayed
andauthored
Obsolete Roots, Sampling, and Logging surface area per SEP-2577 (modelcontextprotocol#1651)
Co-authored-by: Tarek Mahmoud Sayed <tarekms@ntdev.microsoft.com>
1 parent 9b783d7 commit 8ddb3cc

49 files changed

Lines changed: 122 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..'))" />
3+
4+
<PropertyGroup>
5+
<!-- Suppress the Logging obsoletion warning (SEP-2577) in the logging sample projects,
6+
which demonstrate the deprecated logging feature that continues to work. -->
7+
<NoWarn>$(NoWarn);MCP9005</NoWarn>
8+
</PropertyGroup>
9+
</Project>

docs/list-of-diagnostics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ When APIs are marked as obsolete, a diagnostic is emitted to warn users that the
3939
| `MCP9002` | Removed | The `AddXxxFilter` extension methods on `IMcpServerBuilder` (e.g., `AddListToolsFilter`, `AddCallToolFilter`, `AddIncomingMessageFilter`) were superseded by `WithRequestFilters()` and `WithMessageFilters()`. |
4040
| `MCP9003` | In place | The `RequestContext<TParams>(McpServer, JsonRpcRequest)` constructor is obsolete. Use the overload that accepts a `parameters` argument: `RequestContext<TParams>(McpServer, JsonRpcRequest, TParams)`. |
4141
| `MCP9004` | In place | <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.EnableLegacySse> opts into the legacy SSE transport which has no built-in HTTP-level backpressure. Use Streamable HTTP instead. See [Stateless — Legacy SSE transport](xref:stateless#legacy-sse-transport) for details. |
42+
| `MCP9005` | In place | The Roots, Sampling, and Logging features are deprecated as of specification version 2026-07-28 and may be removed in a future version. See SEP-2577 for more information. |

samples/AspNetCoreMcpServer/AspNetCoreMcpServer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<PublishAot>true</PublishAot>
8+
<!-- This sample demonstrates the Sampling feature, which SEP-2577 deprecates (MCP9005) but
9+
which continues to work. Suppress the deprecation warning for this sample only. -->
10+
<NoWarn>$(NoWarn);MCP9005</NoWarn>
811
</PropertyGroup>
912

1013
<ItemGroup>

samples/ChatWithTools/ChatWithTools.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<TargetFramework>net8.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<!-- This sample demonstrates the Sampling feature, which SEP-2577 deprecates (MCP9005) but
9+
which continues to work. Suppress the deprecation warning for this sample only. -->
10+
<NoWarn>$(NoWarn);MCP9005</NoWarn>
811
<!--
912
Anthropic SDK isn't AOT compatible yet
1013
<PublishAot>true</PublishAot>

samples/EverythingServer/EverythingServer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<OutputType>Exe</OutputType>
8+
<!-- This sample demonstrates the Logging and Sampling features, which SEP-2577 deprecates
9+
(MCP9005) but which continue to work. Suppress the deprecation warning for this sample only. -->
10+
<NoWarn>$(NoWarn);MCP9005</NoWarn>
811
</PropertyGroup>
912

1013
<ItemGroup>

samples/TestServerWithHosting/TestServerWithHosting.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<PublishAot Condition="'$(TargetFramework)' == 'net9.0'">true</PublishAot>
9+
<!-- This sample demonstrates the Sampling feature, which SEP-2577 deprecates (MCP9005) but
10+
which continues to work. Suppress the deprecation warning for this sample only. -->
11+
<NoWarn>$(NoWarn);MCP9005</NoWarn>
912
</PropertyGroup>
1013

1114
<ItemGroup>

src/Common/Obsoletions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,18 @@ internal static class Obsoletions
2828

2929
public const string RequestContextParamsConstructor_DiagnosticId = "MCP9003";
3030
public const string RequestContextParamsConstructor_Message = "Use the constructor overload that accepts a parameters argument.";
31-
public const string RequestContextParamsConstructor_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcp9003";
31+
public const string RequestContextParamsConstructor_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis";
3232

3333
public const string EnableLegacySse_DiagnosticId = "MCP9004";
3434
public const string EnableLegacySse_Message = "Legacy SSE transport has no built-in request backpressure and should only be used with completely trusted clients in isolated processes. Use Streamable HTTP instead.";
3535
public const string EnableLegacySse_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis";
36+
37+
// SEP-2577 deprecates the Roots, Sampling, and Logging features as a single coordinated
38+
// deprecation. They share one diagnostic ID (MCP9005) so consumers can opt out with a single
39+
// suppression, while the feature-specific messages keep the diagnostics distinguishable.
40+
public const string Deprecated_DiagnosticId = "MCP9005";
41+
public const string Deprecated_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis";
42+
public const string DeprecatedRoots_Message = "The Roots feature is deprecated as of specification version 2026-07-28 and may be removed in a future version. See SEP-2577 for more information.";
43+
public const string DeprecatedSampling_Message = "The Sampling feature is deprecated as of specification version 2026-07-28 and may be removed in a future version. See SEP-2577 for more information.";
44+
public const string DeprecatedLogging_Message = "The Logging feature is deprecated as of specification version 2026-07-28 and may be removed in a future version. See SEP-2577 for more information.";
3645
}

src/ModelContextProtocol.Core/AIContentExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static class AIContentExtensions
3434
/// </para>
3535
/// </remarks>
3636
/// <exception cref="ArgumentNullException"><paramref name="chatClient"/> is <see langword="null"/>.</exception>
37+
[Obsolete(Obsoletions.DeprecatedSampling_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
3738
public static Func<CreateMessageRequestParams?, IProgress<ProgressNotificationValue>, CancellationToken, ValueTask<CreateMessageResult>> CreateSamplingHandler(
3839
this IChatClient chatClient,
3940
JsonSerializerOptions? serializerOptions = null)

src/ModelContextProtocol.Core/Client/McpClient.Methods.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ public async ValueTask<ResultOrCreatedTask<CallToolResult>> CallToolRawAsync(
12081208
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
12091209
/// <returns>A task representing the asynchronous operation.</returns>
12101210
/// <exception cref="McpException">The request failed or the server returned an error response.</exception>
1211+
[Obsolete(Obsoletions.DeprecatedLogging_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
12111212
public Task SetLoggingLevelAsync(LogLevel level, RequestOptions? options = null, CancellationToken cancellationToken = default) =>
12121213
SetLoggingLevelAsync(McpServerImpl.ToLoggingLevel(level), options, cancellationToken);
12131214

@@ -1219,6 +1220,7 @@ public Task SetLoggingLevelAsync(LogLevel level, RequestOptions? options = null,
12191220
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
12201221
/// <returns>A task representing the asynchronous operation.</returns>
12211222
/// <exception cref="McpException">The request failed or the server returned an error response.</exception>
1223+
[Obsolete(Obsoletions.DeprecatedLogging_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
12221224
public Task SetLoggingLevelAsync(LoggingLevel level, RequestOptions? options = null, CancellationToken cancellationToken = default)
12231225
{
12241226
return SetLoggingLevelAsync(
@@ -1238,6 +1240,7 @@ public Task SetLoggingLevelAsync(LoggingLevel level, RequestOptions? options = n
12381240
/// <returns>The result of the request.</returns>
12391241
/// <exception cref="ArgumentNullException"><paramref name="requestParams"/> is <see langword="null"/>.</exception>
12401242
/// <exception cref="McpException">The request failed or the server returned an error response.</exception>
1243+
[Obsolete(Obsoletions.DeprecatedLogging_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
12411244
public Task SetLoggingLevelAsync(
12421245
SetLevelRequestParams requestParams,
12431246
CancellationToken cancellationToken = default)

src/ModelContextProtocol.Core/Client/McpClientHandlers.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.Extensions.AI;
1+
using Microsoft.Extensions.AI;
22
using ModelContextProtocol.Protocol;
33
using System.Diagnostics.CodeAnalysis;
44

@@ -50,6 +50,7 @@ public sealed class McpClientHandlers
5050
/// This handler is invoked when the server sends a <see cref="RequestMethods.RootsList"/> request to retrieve available roots.
5151
/// The handler receives request parameters and should return a <see cref="ListRootsResult"/> containing the collection of available roots.
5252
/// </remarks>
53+
[Obsolete(Obsoletions.DeprecatedRoots_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
5354
public Func<ListRootsRequestParams?, CancellationToken, ValueTask<ListRootsResult>>? RootsHandler { get; set; }
5455

5556
/// <summary>
@@ -85,5 +86,6 @@ public sealed class McpClientHandlers
8586
/// method with any implementation of <see cref="IChatClient"/>.
8687
/// </para>
8788
/// </remarks>
89+
[Obsolete(Obsoletions.DeprecatedSampling_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
8890
public Func<CreateMessageRequestParams?, IProgress<ProgressNotificationValue>, CancellationToken, ValueTask<CreateMessageResult>>? SamplingHandler { get; set; }
8991
}

0 commit comments

Comments
 (0)