Skip to content

Commit d826cd3

Browse files
Remove all obsolete API definitions and related tests
Co-authored-by: MackinnonBuck <[email protected]>
1 parent 701597c commit d826cd3

18 files changed

+2
-1906
lines changed

src/ModelContextProtocol.Core/Client/McpClientExtensions.cs

Lines changed: 0 additions & 589 deletions
Large diffs are not rendered by default.

src/ModelContextProtocol.Core/IMcpEndpoint.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ public interface IMcpEndpoint : IAsyncDisposable
6767
/// <remarks>
6868
/// <para>
6969
/// This method provides low-level access to send any JSON-RPC message. For specific message types,
70-
/// consider using the higher-level methods such as <see cref="SendRequestAsync"/> or extension methods
71-
/// like <see cref="McpEndpointExtensions.SendNotificationAsync(IMcpEndpoint, string, CancellationToken)"/>,
72-
/// which provide a simpler API.
70+
/// consider using the higher-level methods such as <see cref="SendRequestAsync"/> or
71+
/// <see cref="McpSession.SendNotificationAsync"/>, which provide a simpler API.
7372
/// </para>
7473
/// <para>
7574
/// The method will serialize the message and transmit it using the underlying transport mechanism.

src/ModelContextProtocol.Core/McpEndpointExtensions.cs

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -23,130 +23,4 @@ namespace ModelContextProtocol;
2323
/// </remarks>
2424
public static class McpEndpointExtensions
2525
{
26-
/// <summary>
27-
/// Sends a JSON-RPC request and attempts to deserialize the result to <typeparamref name="TResult"/>.
28-
/// </summary>
29-
/// <typeparam name="TParameters">The type of the request parameters to serialize from.</typeparam>
30-
/// <typeparam name="TResult">The type of the result to deserialize to.</typeparam>
31-
/// <param name="endpoint">The MCP client or server instance.</param>
32-
/// <param name="method">The JSON-RPC method name to invoke.</param>
33-
/// <param name="parameters">Object representing the request parameters.</param>
34-
/// <param name="requestId">The request id for the request.</param>
35-
/// <param name="serializerOptions">The options governing request serialization.</param>
36-
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
37-
/// <returns>A task that represents the asynchronous operation. The task result contains the deserialized result.</returns>
38-
[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
39-
[EditorBrowsable(EditorBrowsableState.Never)]
40-
public static ValueTask<TResult> SendRequestAsync<TParameters, TResult>(
41-
this IMcpEndpoint endpoint,
42-
string method,
43-
TParameters parameters,
44-
JsonSerializerOptions? serializerOptions = null,
45-
RequestId requestId = default,
46-
CancellationToken cancellationToken = default)
47-
where TResult : notnull
48-
=> AsSessionOrThrow(endpoint).SendRequestAsync<TParameters, TResult>(method, parameters, serializerOptions, requestId, cancellationToken);
49-
50-
/// <summary>
51-
/// Sends a parameterless notification to the connected endpoint.
52-
/// </summary>
53-
/// <param name="client">The MCP client or server instance.</param>
54-
/// <param name="method">The notification method name.</param>
55-
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
56-
/// <returns>A task that represents the asynchronous send operation.</returns>
57-
/// <remarks>
58-
/// <para>
59-
/// This method sends a notification without any parameters. Notifications are one-way messages
60-
/// that don't expect a response. They are commonly used for events, status updates, or to signal
61-
/// changes in state.
62-
/// </para>
63-
/// </remarks>
64-
[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
65-
[EditorBrowsable(EditorBrowsableState.Never)]
66-
public static Task SendNotificationAsync(this IMcpEndpoint client, string method, CancellationToken cancellationToken = default)
67-
=> AsSessionOrThrow(client).SendNotificationAsync(method, cancellationToken);
68-
69-
/// <summary>
70-
/// Sends a notification with parameters to the connected endpoint.
71-
/// </summary>
72-
/// <typeparam name="TParameters">The type of the notification parameters to serialize.</typeparam>
73-
/// <param name="endpoint">The MCP client or server instance.</param>
74-
/// <param name="method">The JSON-RPC method name for the notification.</param>
75-
/// <param name="parameters">Object representing the notification parameters.</param>
76-
/// <param name="serializerOptions">The options governing parameter serialization. If null, default options are used.</param>
77-
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
78-
/// <returns>A task that represents the asynchronous send operation.</returns>
79-
/// <remarks>
80-
/// <para>
81-
/// This method sends a notification with parameters to the connected endpoint. Notifications are one-way
82-
/// messages that don't expect a response, commonly used for events, status updates, or signaling changes.
83-
/// </para>
84-
/// <para>
85-
/// The parameters object is serialized to JSON according to the provided serializer options or the default
86-
/// options if none are specified.
87-
/// </para>
88-
/// <para>
89-
/// The Model Context Protocol defines several standard notification methods in <see cref="NotificationMethods"/>,
90-
/// but custom methods can also be used for application-specific notifications.
91-
/// </para>
92-
/// </remarks>
93-
[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
94-
[EditorBrowsable(EditorBrowsableState.Never)]
95-
public static Task SendNotificationAsync<TParameters>(
96-
this IMcpEndpoint endpoint,
97-
string method,
98-
TParameters parameters,
99-
JsonSerializerOptions? serializerOptions = null,
100-
CancellationToken cancellationToken = default)
101-
=> AsSessionOrThrow(endpoint).SendNotificationAsync(method, parameters, serializerOptions, cancellationToken);
102-
103-
/// <summary>
104-
/// Notifies the connected endpoint of progress for a long-running operation.
105-
/// </summary>
106-
/// <param name="endpoint">The endpoint issuing the notification.</param>
107-
/// <param name="progressToken">The <see cref="ProgressToken"/> identifying the operation for which progress is being reported.</param>
108-
/// <param name="progress">The progress update to send, containing information such as percentage complete or status message.</param>
109-
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
110-
/// <returns>A task representing the completion of the notification operation (not the operation being tracked).</returns>
111-
/// <exception cref="ArgumentNullException"><paramref name="endpoint"/> is <see langword="null"/>.</exception>
112-
/// <remarks>
113-
/// <para>
114-
/// This method sends a progress notification to the connected endpoint using the Model Context Protocol's
115-
/// standardized progress notification format. Progress updates are identified by a <see cref="ProgressToken"/>
116-
/// that allows the recipient to correlate multiple updates with a specific long-running operation.
117-
/// </para>
118-
/// <para>
119-
/// Progress notifications are sent asynchronously and don't block the operation from continuing.
120-
/// </para>
121-
/// </remarks>
122-
[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
123-
[EditorBrowsable(EditorBrowsableState.Never)]
124-
public static Task NotifyProgressAsync(
125-
this IMcpEndpoint endpoint,
126-
ProgressToken progressToken,
127-
ProgressNotificationValue progress,
128-
CancellationToken cancellationToken = default)
129-
=> AsSessionOrThrow(endpoint).NotifyProgressAsync(progressToken, progress, cancellationToken);
130-
131-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
132-
#pragma warning disable CS0618 // Type or member is obsolete
133-
private static McpSession AsSessionOrThrow(IMcpEndpoint endpoint, [CallerMemberName] string memberName = "")
134-
#pragma warning restore CS0618 // Type or member is obsolete
135-
{
136-
if (endpoint is not McpSession session)
137-
{
138-
ThrowInvalidEndpointType(memberName);
139-
}
140-
141-
return session;
142-
143-
[DoesNotReturn]
144-
[MethodImpl(MethodImplOptions.NoInlining)]
145-
static void ThrowInvalidEndpointType(string memberName)
146-
=> throw new InvalidOperationException(
147-
$"Only arguments assignable to '{nameof(McpSession)}' are supported. " +
148-
$"Prefer using '{nameof(McpServer)}.{memberName}' instead, as " +
149-
$"'{nameof(McpEndpointExtensions)}.{memberName}' is obsolete and will be " +
150-
$"removed in the future.");
151-
}
15226
}

src/ModelContextProtocol.Core/Protocol/ClientCapabilities.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,4 @@ public sealed class ClientCapabilities
6767
[JsonPropertyName("elicitation")]
6868
public ElicitationCapability? Elicitation { get; set; }
6969

70-
/// <summary>Gets or sets notification handlers to register with the client.</summary>
71-
/// <remarks>
72-
/// <para>
73-
/// When constructed, the client will enumerate these handlers once, which may contain multiple handlers per notification method key.
74-
/// The client will not re-enumerate the sequence after initialization.
75-
/// </para>
76-
/// <para>
77-
/// Notification handlers allow the client to respond to server-sent notifications for specific methods.
78-
/// Each key in the collection is a notification method name, and each value is a callback that will be invoked
79-
/// when a notification with that method is received.
80-
/// </para>
81-
/// <para>
82-
/// Handlers provided via <see cref="NotificationHandlers"/> will be registered with the client for the lifetime of the client.
83-
/// For transient handlers, <see cref="McpSession.RegisterNotificationHandler"/> may be used to register a handler that can
84-
/// then be unregistered by disposing of the <see cref="IAsyncDisposable"/> returned from the method.
85-
/// </para>
86-
/// </remarks>
87-
[JsonIgnore]
88-
[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
89-
[EditorBrowsable(EditorBrowsableState.Never)]
90-
public IEnumerable<KeyValuePair<string, Func<JsonRpcNotification, CancellationToken, ValueTask>>>? NotificationHandlers { get; set; }
9170
}

src/ModelContextProtocol.Core/Protocol/CompletionsCapability.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,4 @@ namespace ModelContextProtocol.Protocol;
2828
/// </remarks>
2929
public sealed class CompletionsCapability
3030
{
31-
/// <summary>
32-
/// Gets or sets the handler for completion requests.
33-
/// </summary>
34-
/// <remarks>
35-
/// This handler provides auto-completion suggestions for prompt arguments or resource references in the Model Context Protocol.
36-
/// The handler receives a reference type (e.g., "ref/prompt" or "ref/resource") and the current argument value,
37-
/// and should return appropriate completion suggestions.
38-
/// </remarks>
39-
[JsonIgnore]
40-
[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
41-
[EditorBrowsable(EditorBrowsableState.Never)]
42-
public McpRequestHandler<CompleteRequestParams, CompleteResult>? CompleteHandler { get; set; }
4331
}

src/ModelContextProtocol.Core/Protocol/ElicitationCapability.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,4 @@ namespace ModelContextProtocol.Protocol;
2323
/// </remarks>
2424
public sealed class ElicitationCapability
2525
{
26-
/// <summary>
27-
/// Gets or sets the handler for processing <see cref="RequestMethods.ElicitationCreate"/> requests.
28-
/// </summary>
29-
/// <remarks>
30-
/// <para>
31-
/// This handler function is called when an MCP server requests the client to provide additional
32-
/// information during interactions. The client must set this property for the elicitation capability to work.
33-
/// </para>
34-
/// <para>
35-
/// The handler receives message parameters and a cancellation token.
36-
/// It should return a <see cref="ElicitResult"/> containing the response to the elicitation request.
37-
/// </para>
38-
/// </remarks>
39-
[JsonIgnore]
40-
[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
41-
[EditorBrowsable(EditorBrowsableState.Never)]
42-
public Func<ElicitRequestParams?, CancellationToken, ValueTask<ElicitResult>>? ElicitationHandler { get; set; }
4326
}

src/ModelContextProtocol.Core/Protocol/LoggingCapability.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,4 @@ namespace ModelContextProtocol.Protocol;
2020
/// </remarks>
2121
public sealed class LoggingCapability
2222
{
23-
/// <summary>
24-
/// Gets or sets the handler for set logging level requests from clients.
25-
/// </summary>
26-
[JsonIgnore]
27-
[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
28-
[EditorBrowsable(EditorBrowsableState.Never)]
29-
public McpRequestHandler<SetLevelRequestParams, EmptyResult>? SetLoggingLevelHandler { get; set; }
3023
}

src/ModelContextProtocol.Core/Protocol/PromptsCapability.cs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -32,58 +32,4 @@ public sealed class PromptsCapability
3232
[JsonPropertyName("listChanged")]
3333
public bool? ListChanged { get; set; }
3434

35-
/// <summary>
36-
/// Gets or sets the handler for <see cref="RequestMethods.PromptsList"/> requests.
37-
/// </summary>
38-
/// <remarks>
39-
/// This handler is invoked when a client requests a list of available prompts from the server
40-
/// via a <see cref="RequestMethods.PromptsList"/> request. Results from this handler are returned
41-
/// along with any prompts defined in <see cref="PromptCollection"/>.
42-
/// </remarks>
43-
[JsonIgnore]
44-
[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
45-
[EditorBrowsable(EditorBrowsableState.Never)]
46-
public McpRequestHandler<ListPromptsRequestParams, ListPromptsResult>? ListPromptsHandler { get; set; }
47-
48-
/// <summary>
49-
/// Gets or sets the handler for <see cref="RequestMethods.PromptsGet"/> requests.
50-
/// </summary>
51-
/// <remarks>
52-
/// <para>
53-
/// This handler is invoked when a client requests details for a specific prompt by name and provides arguments
54-
/// for the prompt if needed. The handler receives the request context containing the prompt name and any arguments,
55-
/// and should return a <see cref="GetPromptResult"/> with the prompt messages and other details.
56-
/// </para>
57-
/// <para>
58-
/// This handler will be invoked if the requested prompt name is not found in the <see cref="PromptCollection"/>,
59-
/// allowing for dynamic prompt generation or retrieval from external sources.
60-
/// </para>
61-
/// </remarks>
62-
[JsonIgnore]
63-
[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
64-
[EditorBrowsable(EditorBrowsableState.Never)]
65-
public McpRequestHandler<GetPromptRequestParams, GetPromptResult>? GetPromptHandler { get; set; }
66-
67-
/// <summary>
68-
/// Gets or sets a collection of prompts that will be served by the server.
69-
/// </summary>
70-
/// <remarks>
71-
/// <para>
72-
/// The <see cref="PromptCollection"/> contains the predefined prompts that clients can request from the server.
73-
/// This collection works in conjunction with <see cref="ListPromptsHandler"/> and <see cref="GetPromptHandler"/>
74-
/// when those are provided:
75-
/// </para>
76-
/// <para>
77-
/// - For <see cref="RequestMethods.PromptsList"/> requests: The server returns all prompts from this collection
78-
/// plus any additional prompts provided by the <see cref="ListPromptsHandler"/> if it's set.
79-
/// </para>
80-
/// <para>
81-
/// - For <see cref="RequestMethods.PromptsGet"/> requests: The server first checks this collection for the requested prompt.
82-
/// If not found, it will invoke the <see cref="GetPromptHandler"/> as a fallback if one is set.
83-
/// </para>
84-
/// </remarks>
85-
[JsonIgnore]
86-
[Obsolete($"Use {nameof(McpServerOptions.PromptCollection)} instead. This member will be removed in a subsequent release.")] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
87-
[EditorBrowsable(EditorBrowsableState.Never)]
88-
public McpServerPrimitiveCollection<McpServerPrompt>? PromptCollection { get; set; }
8935
}

0 commit comments

Comments
 (0)