Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f636f4b
Initial plan
Copilot Nov 18, 2025
701597c
Remove internal usages of obsolete capability properties
Copilot Nov 18, 2025
d826cd3
Remove all obsolete API definitions and related tests
Copilot Nov 18, 2025
cd8f7ae
Merge main branch and resolve conflicts
Copilot Nov 19, 2025
3d20111
Merge remote-tracking branch 'origin/main' into copilot/remove-obsole…
Copilot Nov 19, 2025
eb31afb
Remove unused duplicate CreateSamplingHandler and helper methods from…
Copilot Nov 19, 2025
c7deb7f
Delete empty McpEndpointExtensions and McpServerExtensions classes
Copilot Nov 19, 2025
4d6fe0a
Remove obsolete IMcpEndpoint, IMcpClient, IMcpServer interfaces and M…
Copilot Nov 19, 2025
2decb2d
Remove extra newlines before closing braces in capability classes
Copilot Nov 19, 2025
4443cfc
Merge main branch and resolve conflicts (PR #976 integration)
Copilot Nov 20, 2025
44083aa
Revert "Merge main branch and resolve conflicts (PR #976 integration)"
MackinnonBuck Nov 20, 2025
cd9ce13
Merge remote-tracking branch 'origin/main' into copilot/remove-obsole…
MackinnonBuck Nov 20, 2025
93a6877
Remove remaining obsolete EnumSchema and LegacyTitledEnumSchema types…
Copilot Nov 21, 2025
186d85c
Restore EnumSchemaTests.cs and add back valid enum schema tests witho…
Copilot Nov 21, 2025
04e1326
Revert: "Remove remaining obsolete EnumSchema and LegacyTitledEnumSch…
jeffhandley Nov 26, 2025
40df946
Merge branch 'main' into copilot/remove-obsolete-apis
jeffhandley Nov 26, 2025
3c29253
Introduce Obsoletions/Experimentals pattern for custom diagnostics.
jeffhandley Nov 26, 2025
6fcf81c
Fix failing enum schema tests
jeffhandley Nov 26, 2025
981386e
Merge branch 'main' into copilot/remove-obsolete-apis
jeffhandley Nov 27, 2025
95708d6
Revise diagnostic ID ranges for analyzers, obsoletions, experimentals
jeffhandley Nov 27, 2025
7e074f8
Fix XML comment reference to RegisterNotificationHandler
jeffhandley Nov 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
589 changes: 0 additions & 589 deletions src/ModelContextProtocol.Core/Client/McpClientExtensions.cs

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions src/ModelContextProtocol.Core/Client/McpClientImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ private void RegisterHandlers(McpClientOptions options, NotificationHandlers not
{
McpClientHandlers handlers = options.Handlers;

#pragma warning disable CS0618 // Type or member is obsolete
var notificationHandlersFromOptions = handlers.NotificationHandlers ?? options.Capabilities?.NotificationHandlers;
var samplingHandler = handlers.SamplingHandler ?? options.Capabilities?.Sampling?.SamplingHandler;
var rootsHandler = handlers.RootsHandler ?? options.Capabilities?.Roots?.RootsHandler;
var elicitationHandler = handlers.ElicitationHandler ?? options.Capabilities?.Elicitation?.ElicitationHandler;
#pragma warning restore CS0618 // Type or member is obsolete
var notificationHandlersFromOptions = handlers.NotificationHandlers;
var samplingHandler = handlers.SamplingHandler;
var rootsHandler = handlers.RootsHandler;
var elicitationHandler = handlers.ElicitationHandler;

if (notificationHandlersFromOptions is not null)
{
Expand Down
5 changes: 2 additions & 3 deletions src/ModelContextProtocol.Core/IMcpEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ public interface IMcpEndpoint : IAsyncDisposable
/// <remarks>
/// <para>
/// This method provides low-level access to send any JSON-RPC message. For specific message types,
/// consider using the higher-level methods such as <see cref="SendRequestAsync"/> or extension methods
/// like <see cref="McpEndpointExtensions.SendNotificationAsync(IMcpEndpoint, string, CancellationToken)"/>,
/// which provide a simpler API.
/// consider using the higher-level methods such as <see cref="SendRequestAsync"/> or
/// <see cref="McpSession.SendNotificationAsync"/>, which provide a simpler API.
/// </para>
/// <para>
/// The method will serialize the message and transmit it using the underlying transport mechanism.
Expand Down
126 changes: 0 additions & 126 deletions src/ModelContextProtocol.Core/McpEndpointExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,130 +23,4 @@ namespace ModelContextProtocol;
/// </remarks>
public static class McpEndpointExtensions
Comment thread
MackinnonBuck marked this conversation as resolved.
Outdated
{
/// <summary>
/// Sends a JSON-RPC request and attempts to deserialize the result to <typeparamref name="TResult"/>.
/// </summary>
/// <typeparam name="TParameters">The type of the request parameters to serialize from.</typeparam>
/// <typeparam name="TResult">The type of the result to deserialize to.</typeparam>
/// <param name="endpoint">The MCP client or server instance.</param>
/// <param name="method">The JSON-RPC method name to invoke.</param>
/// <param name="parameters">Object representing the request parameters.</param>
/// <param name="requestId">The request id for the request.</param>
/// <param name="serializerOptions">The options governing request serialization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the deserialized result.</returns>
[Obsolete($"Use {nameof(McpSession)}.{nameof(McpSession.SendRequestAsync)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public static ValueTask<TResult> SendRequestAsync<TParameters, TResult>(
this IMcpEndpoint endpoint,
string method,
TParameters parameters,
JsonSerializerOptions? serializerOptions = null,
RequestId requestId = default,
CancellationToken cancellationToken = default)
where TResult : notnull
=> AsSessionOrThrow(endpoint).SendRequestAsync<TParameters, TResult>(method, parameters, serializerOptions, requestId, cancellationToken);

/// <summary>
/// Sends a parameterless notification to the connected endpoint.
/// </summary>
/// <param name="client">The MCP client or server instance.</param>
/// <param name="method">The notification method name.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <returns>A task that represents the asynchronous send operation.</returns>
/// <remarks>
/// <para>
/// This method sends a notification without any parameters. Notifications are one-way messages
/// that don't expect a response. They are commonly used for events, status updates, or to signal
/// changes in state.
/// </para>
/// </remarks>
[Obsolete($"Use {nameof(McpSession)}.{nameof(McpSession.SendNotificationAsync)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public static Task SendNotificationAsync(this IMcpEndpoint client, string method, CancellationToken cancellationToken = default)
=> AsSessionOrThrow(client).SendNotificationAsync(method, cancellationToken);

/// <summary>
/// Sends a notification with parameters to the connected endpoint.
/// </summary>
/// <typeparam name="TParameters">The type of the notification parameters to serialize.</typeparam>
/// <param name="endpoint">The MCP client or server instance.</param>
/// <param name="method">The JSON-RPC method name for the notification.</param>
/// <param name="parameters">Object representing the notification parameters.</param>
/// <param name="serializerOptions">The options governing parameter serialization. If null, default options are used.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <returns>A task that represents the asynchronous send operation.</returns>
/// <remarks>
/// <para>
/// This method sends a notification with parameters to the connected endpoint. Notifications are one-way
/// messages that don't expect a response, commonly used for events, status updates, or signaling changes.
/// </para>
/// <para>
/// The parameters object is serialized to JSON according to the provided serializer options or the default
/// options if none are specified.
/// </para>
/// <para>
/// The Model Context Protocol defines several standard notification methods in <see cref="NotificationMethods"/>,
/// but custom methods can also be used for application-specific notifications.
/// </para>
/// </remarks>
[Obsolete($"Use {nameof(McpSession)}.{nameof(McpSession.SendNotificationAsync)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public static Task SendNotificationAsync<TParameters>(
this IMcpEndpoint endpoint,
string method,
TParameters parameters,
JsonSerializerOptions? serializerOptions = null,
CancellationToken cancellationToken = default)
=> AsSessionOrThrow(endpoint).SendNotificationAsync(method, parameters, serializerOptions, cancellationToken);

/// <summary>
/// Notifies the connected endpoint of progress for a long-running operation.
/// </summary>
/// <param name="endpoint">The endpoint issuing the notification.</param>
/// <param name="progressToken">The <see cref="ProgressToken"/> identifying the operation for which progress is being reported.</param>
/// <param name="progress">The progress update to send, containing information such as percentage complete or status message.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <returns>A task representing the completion of the notification operation (not the operation being tracked).</returns>
/// <exception cref="ArgumentNullException"><paramref name="endpoint"/> is <see langword="null"/>.</exception>
/// <remarks>
/// <para>
/// This method sends a progress notification to the connected endpoint using the Model Context Protocol's
/// standardized progress notification format. Progress updates are identified by a <see cref="ProgressToken"/>
/// that allows the recipient to correlate multiple updates with a specific long-running operation.
/// </para>
/// <para>
/// Progress notifications are sent asynchronously and don't block the operation from continuing.
/// </para>
/// </remarks>
[Obsolete($"Use {nameof(McpSession)}.{nameof(McpSession.NotifyProgressAsync)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public static Task NotifyProgressAsync(
this IMcpEndpoint endpoint,
ProgressToken progressToken,
ProgressNotificationValue progress,
CancellationToken cancellationToken = default)
=> AsSessionOrThrow(endpoint).NotifyProgressAsync(progressToken, progress, cancellationToken);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
#pragma warning disable CS0618 // Type or member is obsolete
private static McpSession AsSessionOrThrow(IMcpEndpoint endpoint, [CallerMemberName] string memberName = "")
#pragma warning restore CS0618 // Type or member is obsolete
{
if (endpoint is not McpSession session)
{
ThrowInvalidEndpointType(memberName);
}

return session;

[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
static void ThrowInvalidEndpointType(string memberName)
=> throw new InvalidOperationException(
$"Only arguments assignable to '{nameof(McpSession)}' are supported. " +
$"Prefer using '{nameof(McpServer)}.{memberName}' instead, as " +
$"'{nameof(McpEndpointExtensions)}.{memberName}' is obsolete and will be " +
$"removed in the future.");
}
}
21 changes: 0 additions & 21 deletions src/ModelContextProtocol.Core/Protocol/ClientCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,4 @@ public sealed class ClientCapabilities
[JsonPropertyName("elicitation")]
public ElicitationCapability? Elicitation { get; set; }

Comment thread
MackinnonBuck marked this conversation as resolved.
Outdated
/// <summary>Gets or sets notification handlers to register with the client.</summary>
/// <remarks>
/// <para>
/// When constructed, the client will enumerate these handlers once, which may contain multiple handlers per notification method key.
/// The client will not re-enumerate the sequence after initialization.
/// </para>
/// <para>
/// Notification handlers allow the client to respond to server-sent notifications for specific methods.
/// Each key in the collection is a notification method name, and each value is a callback that will be invoked
/// when a notification with that method is received.
/// </para>
/// <para>
/// Handlers provided via <see cref="NotificationHandlers"/> will be registered with the client for the lifetime of the client.
/// For transient handlers, <see cref="McpSession.RegisterNotificationHandler"/> may be used to register a handler that can
/// then be unregistered by disposing of the <see cref="IAsyncDisposable"/> returned from the method.
/// </para>
/// </remarks>
[JsonIgnore]
[Obsolete($"Use {nameof(McpClientOptions.Handlers.NotificationHandlers)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public IEnumerable<KeyValuePair<string, Func<JsonRpcNotification, CancellationToken, ValueTask>>>? NotificationHandlers { get; set; }
}
12 changes: 0 additions & 12 deletions src/ModelContextProtocol.Core/Protocol/CompletionsCapability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,4 @@ namespace ModelContextProtocol.Protocol;
/// </remarks>
public sealed class CompletionsCapability
{
/// <summary>
/// Gets or sets the handler for completion requests.
/// </summary>
/// <remarks>
/// This handler provides auto-completion suggestions for prompt arguments or resource references in the Model Context Protocol.
/// The handler receives a reference type (e.g., "ref/prompt" or "ref/resource") and the current argument value,
/// and should return appropriate completion suggestions.
/// </remarks>
[JsonIgnore]
[Obsolete($"Use {nameof(McpServerOptions.Handlers.CompleteHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public McpRequestHandler<CompleteRequestParams, CompleteResult>? CompleteHandler { get; set; }
}
17 changes: 0 additions & 17 deletions src/ModelContextProtocol.Core/Protocol/ElicitationCapability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,4 @@ namespace ModelContextProtocol.Protocol;
/// </remarks>
public sealed class ElicitationCapability
{
/// <summary>
/// Gets or sets the handler for processing <see cref="RequestMethods.ElicitationCreate"/> requests.
/// </summary>
/// <remarks>
/// <para>
/// This handler function is called when an MCP server requests the client to provide additional
/// information during interactions. The client must set this property for the elicitation capability to work.
/// </para>
/// <para>
/// The handler receives message parameters and a cancellation token.
/// It should return a <see cref="ElicitResult"/> containing the response to the elicitation request.
/// </para>
/// </remarks>
[JsonIgnore]
[Obsolete($"Use {nameof(McpClientOptions.Handlers.ElicitationHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public Func<ElicitRequestParams?, CancellationToken, ValueTask<ElicitResult>>? ElicitationHandler { get; set; }
}
7 changes: 0 additions & 7 deletions src/ModelContextProtocol.Core/Protocol/LoggingCapability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,4 @@ namespace ModelContextProtocol.Protocol;
/// </remarks>
public sealed class LoggingCapability
{
/// <summary>
/// Gets or sets the handler for set logging level requests from clients.
/// </summary>
[JsonIgnore]
[Obsolete($"Use {nameof(McpServerOptions.Handlers.SetLoggingLevelHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public McpRequestHandler<SetLevelRequestParams, EmptyResult>? SetLoggingLevelHandler { get; set; }
}
54 changes: 0 additions & 54 deletions src/ModelContextProtocol.Core/Protocol/PromptsCapability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,58 +32,4 @@ public sealed class PromptsCapability
[JsonPropertyName("listChanged")]
public bool? ListChanged { get; set; }

/// <summary>
/// Gets or sets the handler for <see cref="RequestMethods.PromptsList"/> requests.
/// </summary>
/// <remarks>
/// This handler is invoked when a client requests a list of available prompts from the server
/// via a <see cref="RequestMethods.PromptsList"/> request. Results from this handler are returned
/// along with any prompts defined in <see cref="PromptCollection"/>.
/// </remarks>
[JsonIgnore]
[Obsolete($"Use {nameof(McpServerOptions.Handlers.ListPromptsHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public McpRequestHandler<ListPromptsRequestParams, ListPromptsResult>? ListPromptsHandler { get; set; }

/// <summary>
/// Gets or sets the handler for <see cref="RequestMethods.PromptsGet"/> requests.
/// </summary>
/// <remarks>
/// <para>
/// This handler is invoked when a client requests details for a specific prompt by name and provides arguments
/// for the prompt if needed. The handler receives the request context containing the prompt name and any arguments,
/// and should return a <see cref="GetPromptResult"/> with the prompt messages and other details.
/// </para>
/// <para>
/// This handler will be invoked if the requested prompt name is not found in the <see cref="PromptCollection"/>,
/// allowing for dynamic prompt generation or retrieval from external sources.
/// </para>
/// </remarks>
[JsonIgnore]
[Obsolete($"Use {nameof(McpServerOptions.Handlers.GetPromptHandler)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public McpRequestHandler<GetPromptRequestParams, GetPromptResult>? GetPromptHandler { get; set; }

/// <summary>
/// Gets or sets a collection of prompts that will be served by the server.
/// </summary>
/// <remarks>
/// <para>
/// The <see cref="PromptCollection"/> contains the predefined prompts that clients can request from the server.
/// This collection works in conjunction with <see cref="ListPromptsHandler"/> and <see cref="GetPromptHandler"/>
/// when those are provided:
/// </para>
/// <para>
/// - For <see cref="RequestMethods.PromptsList"/> requests: The server returns all prompts from this collection
/// plus any additional prompts provided by the <see cref="ListPromptsHandler"/> if it's set.
/// </para>
/// <para>
/// - For <see cref="RequestMethods.PromptsGet"/> requests: The server first checks this collection for the requested prompt.
/// If not found, it will invoke the <see cref="GetPromptHandler"/> as a fallback if one is set.
/// </para>
/// </remarks>
[JsonIgnore]
[Obsolete($"Use {nameof(McpServerOptions.PromptCollection)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
[EditorBrowsable(EditorBrowsableState.Never)]
public McpServerPrimitiveCollection<McpServerPrompt>? PromptCollection { get; set; }
}
Loading
Loading