Skip to content

Commit 89d3399

Browse files
committed
Obsolete Roots, Sampling, and Logging surface area per SEP-2577
Mark all public API surface for the Roots, Sampling, and Logging features as [Obsolete] in line with SEP-2577. This covers protocol DTOs, capability properties, method-name constants, convenience methods, handlers, builders, filters, and the related sampling/roots helpers on the input request/response types. There is no functional or wire behavior change; the features continue to work exactly as before. All three features share a single diagnostic ID (MCP9005) so consumers can opt out with one suppression, while feature-specific messages keep the diagnostics distinguishable. Documents the new diagnostic in docs/list-of-diagnostics.md and suppresses MCP9005 where the SDK, tests, and samples exercise the deprecated APIs internally.
1 parent c021d0a commit 89d3399

46 files changed

Lines changed: 118 additions & 2 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
@@ -38,3 +38,4 @@ When APIs are marked as obsolete, a diagnostic is emitted to warn users that the
3838
| `MCP9002` | Removed | The `AddXxxFilter` extension methods on `IMcpServerBuilder` (e.g., `AddListToolsFilter`, `AddCallToolFilter`, `AddIncomingMessageFilter`) were superseded by `WithRequestFilters()` and `WithMessageFilters()`. |
3939
| `MCP9003` | In place | The `RequestContext<TParams>(McpServer, JsonRpcRequest)` constructor is obsolete. Use the overload that accepts a `parameters` argument: `RequestContext<TParams>(McpServer, JsonRpcRequest, TParams)`. |
4040
| `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. |
41+
| `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/Directory.Build.props

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 Roots, Sampling, and Logging obsoletion warning (SEP-2577) in sample projects
6+
that demonstrate the deprecated features, which continue to work. -->
7+
<NoWarn>$(NoWarn);MCP9005</NoWarn>
8+
</PropertyGroup>
9+
</Project>

src/Common/Obsoletions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ internal static class Obsoletions
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#mcp9005";
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
}

src/ModelContextProtocol.Core/ModelContextProtocol.Core.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<PackageReadmeFile>README.md</PackageReadmeFile>
1010
<!-- Suppress the experimental extensions warning -->
1111
<NoWarn>$(NoWarn);MCPEXP001</NoWarn>
12+
<!-- Core implements the Roots, Sampling, and Logging features deprecated by SEP-2577 (MCP9005).
13+
The deprecated types remain in the source-generated JsonSerializerContext and are used throughout
14+
the implementation, so the obsolete-usage diagnostic is suppressed project-wide here while staying
15+
active for external consumers of the package. -->
16+
<NoWarn>$(NoWarn);MCP9005</NoWarn>
1217
</PropertyGroup>
1318

1419
<PropertyGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">

src/ModelContextProtocol.Core/Protocol/ClientCapabilities.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ public sealed class ClientCapabilities
5252
/// </para>
5353
/// </remarks>
5454
[JsonPropertyName("roots")]
55+
[Obsolete(Obsoletions.DeprecatedRoots_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
5556
public RootsCapability? Roots { get; set; }
5657

5758
/// <summary>
5859
/// Gets or sets the client's sampling capability, which indicates whether the client
5960
/// supports issuing requests to an LLM on behalf of the server.
6061
/// </summary>
6162
[JsonPropertyName("sampling")]
63+
[Obsolete(Obsoletions.DeprecatedSampling_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
6264
public SamplingCapability? Sampling { get; set; }
6365

6466
/// <summary>

src/ModelContextProtocol.Core/Protocol/ContentBlock.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,9 @@ public sealed class ResourceLinkBlock : ContentBlock
760760

761761
/// <summary>Represents a request from the assistant to call a tool.</summary>
762762
[DebuggerDisplay("Name = {Name}, Id = {Id}")]
763+
// Sampling support type: this content block only appears inside sampling messages (an assistant tool call),
764+
// so it is deprecated together with sampling per SEP-2577.
765+
[Obsolete(Obsoletions.DeprecatedSampling_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
763766
public sealed class ToolUseContentBlock : ContentBlock
764767
{
765768
/// <inheritdoc/>
@@ -789,6 +792,9 @@ public sealed class ToolUseContentBlock : ContentBlock
789792

790793
/// <summary>Represents the result of a tool use, provided by the user back to the assistant.</summary>
791794
[DebuggerDisplay("{DebuggerDisplay,nq}")]
795+
// Sampling support type: this content block only appears inside sampling messages (a tool result returned to
796+
// the assistant), so it is deprecated together with sampling per SEP-2577.
797+
[Obsolete(Obsoletions.DeprecatedSampling_Message, DiagnosticId = Obsoletions.Deprecated_DiagnosticId, UrlFormat = Obsoletions.Deprecated_Url)]
792798
public sealed class ToolResultContentBlock : ContentBlock
793799
{
794800
/// <inheritdoc/>

0 commit comments

Comments
 (0)