@@ -28,7 +28,7 @@ public static class McpClientExtensions
2828 /// <remarks>
2929 /// <para>
3030 /// This method is used to check if the MCP server is online and responding to requests.
31- /// It can be useful for health checking, ensuring the connection is established, or verifying
31+ /// It can be useful for health checking, ensuring the connection is established, or verifying
3232 /// that the client has proper authorization to communicate with the server.
3333 /// </para>
3434 /// <para>
@@ -41,7 +41,7 @@ public static class McpClientExtensions
4141 [ Obsolete ( $ "Use { nameof ( McpClient ) } .{ nameof ( McpClient . PingAsync ) } instead. This member will be removed in a subsequent release.") ] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
4242 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
4343 public static Task PingAsync ( this IMcpClient client , CancellationToken cancellationToken = default )
44- => AsClientOrThrow ( client ) . PingAsync ( cancellationToken ) ;
44+ => AsClientOrThrow ( client ) . PingAsync ( null , cancellationToken ) . AsTask ( ) ;
4545
4646 /// <summary>
4747 /// Retrieves a list of available tools from the server.
@@ -56,7 +56,7 @@ public static Task PingAsync(this IMcpClient client, CancellationToken cancellat
5656 /// It automatically handles pagination with cursors if the server responds with only a portion per request.
5757 /// </para>
5858 /// <para>
59- /// For servers with a large number of tools and that responds with paginated responses, consider using
59+ /// For servers with a large number of tools and that responds with paginated responses, consider using
6060 /// <see cref="EnumerateToolsAsync"/> instead, as it streams tools as they arrive rather than loading them all at once.
6161 /// </para>
6262 /// <para>
@@ -68,13 +68,13 @@ public static Task PingAsync(this IMcpClient client, CancellationToken cancellat
6868 /// <code>
6969 /// // Get all tools available on the server
7070 /// var tools = await mcpClient.ListToolsAsync();
71- ///
71+ ///
7272 /// // Use tools with an AI client
7373 /// ChatOptions chatOptions = new()
7474 /// {
7575 /// Tools = [.. tools]
7676 /// };
77- ///
77+ ///
7878 /// await foreach (var update in chatClient.GetStreamingResponseAsync(userMessage, chatOptions))
7979 /// {
8080 /// Console.Write(update);
@@ -88,7 +88,7 @@ public static ValueTask<IList<McpClientTool>> ListToolsAsync(
8888 this IMcpClient client ,
8989 JsonSerializerOptions ? serializerOptions = null ,
9090 CancellationToken cancellationToken = default )
91- => AsClientOrThrow ( client ) . ListToolsAsync ( serializerOptions , cancellationToken ) ;
91+ => AsClientOrThrow ( client ) . ListToolsAsync ( new RequestOptions { JsonSerializerOptions = serializerOptions } , cancellationToken ) ;
9292
9393 /// <summary>
9494 /// Creates an enumerable for asynchronously enumerating all available tools from the server.
@@ -128,7 +128,7 @@ public static IAsyncEnumerable<McpClientTool> EnumerateToolsAsync(
128128 this IMcpClient client ,
129129 JsonSerializerOptions ? serializerOptions = null ,
130130 CancellationToken cancellationToken = default )
131- => AsClientOrThrow ( client ) . EnumerateToolsAsync ( serializerOptions , cancellationToken ) ;
131+ => AsClientOrThrow ( client ) . EnumerateToolsAsync ( new RequestOptions { JsonSerializerOptions = serializerOptions } , cancellationToken ) ;
132132
133133 /// <summary>
134134 /// Retrieves a list of available prompts from the server.
@@ -142,7 +142,7 @@ public static IAsyncEnumerable<McpClientTool> EnumerateToolsAsync(
142142 /// It automatically handles pagination with cursors if the server responds with only a portion per request.
143143 /// </para>
144144 /// <para>
145- /// For servers with a large number of prompts and that responds with paginated responses, consider using
145+ /// For servers with a large number of prompts and that responds with paginated responses, consider using
146146 /// <see cref="EnumeratePromptsAsync"/> instead, as it streams prompts as they arrive rather than loading them all at once.
147147 /// </para>
148148 /// </remarks>
@@ -151,7 +151,7 @@ public static IAsyncEnumerable<McpClientTool> EnumerateToolsAsync(
151151 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
152152 public static ValueTask < IList < McpClientPrompt > > ListPromptsAsync (
153153 this IMcpClient client , CancellationToken cancellationToken = default )
154- => AsClientOrThrow ( client ) . ListPromptsAsync ( cancellationToken ) ;
154+ => AsClientOrThrow ( client ) . ListPromptsAsync ( null , cancellationToken ) ;
155155
156156 /// <summary>
157157 /// Creates an enumerable for asynchronously enumerating all available prompts from the server.
@@ -184,7 +184,7 @@ public static ValueTask<IList<McpClientPrompt>> ListPromptsAsync(
184184 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
185185 public static IAsyncEnumerable < McpClientPrompt > EnumeratePromptsAsync (
186186 this IMcpClient client , CancellationToken cancellationToken = default )
187- => AsClientOrThrow ( client ) . EnumeratePromptsAsync ( cancellationToken ) ;
187+ => AsClientOrThrow ( client ) . EnumeratePromptsAsync ( null , cancellationToken ) ;
188188
189189 /// <summary>
190190 /// Retrieves a specific prompt from the MCP server.
@@ -201,7 +201,7 @@ public static IAsyncEnumerable<McpClientPrompt> EnumeratePromptsAsync(
201201 /// The server will process the arguments and return a prompt containing messages or other content.
202202 /// </para>
203203 /// <para>
204- /// Arguments are serialized into JSON and passed to the server, where they may be used to customize the
204+ /// Arguments are serialized into JSON and passed to the server, where they may be used to customize the
205205 /// prompt's behavior or content. Each prompt may have different argument requirements.
206206 /// </para>
207207 /// <para>
@@ -219,7 +219,7 @@ public static ValueTask<GetPromptResult> GetPromptAsync(
219219 IReadOnlyDictionary < string , object ? > ? arguments = null ,
220220 JsonSerializerOptions ? serializerOptions = null ,
221221 CancellationToken cancellationToken = default )
222- => AsClientOrThrow ( client ) . GetPromptAsync ( name , arguments , serializerOptions , cancellationToken ) ;
222+ => AsClientOrThrow ( client ) . GetPromptAsync ( name , arguments , new RequestOptions { JsonSerializerOptions = serializerOptions } , cancellationToken ) ;
223223
224224 /// <summary>
225225 /// Retrieves a list of available resource templates from the server.
@@ -233,7 +233,7 @@ public static ValueTask<GetPromptResult> GetPromptAsync(
233233 /// It automatically handles pagination with cursors if the server responds with only a portion per request.
234234 /// </para>
235235 /// <para>
236- /// For servers with a large number of resource templates and that responds with paginated responses, consider using
236+ /// For servers with a large number of resource templates and that responds with paginated responses, consider using
237237 /// <see cref="EnumerateResourceTemplatesAsync"/> instead, as it streams templates as they arrive rather than loading them all at once.
238238 /// </para>
239239 /// </remarks>
@@ -242,7 +242,7 @@ public static ValueTask<GetPromptResult> GetPromptAsync(
242242 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
243243 public static ValueTask < IList < McpClientResourceTemplate > > ListResourceTemplatesAsync (
244244 this IMcpClient client , CancellationToken cancellationToken = default )
245- => AsClientOrThrow ( client ) . ListResourceTemplatesAsync ( cancellationToken ) ;
245+ => AsClientOrThrow ( client ) . ListResourceTemplatesAsync ( null , cancellationToken ) ;
246246
247247 /// <summary>
248248 /// Creates an enumerable for asynchronously enumerating all available resource templates from the server.
@@ -275,7 +275,7 @@ public static ValueTask<IList<McpClientResourceTemplate>> ListResourceTemplatesA
275275 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
276276 public static IAsyncEnumerable < McpClientResourceTemplate > EnumerateResourceTemplatesAsync (
277277 this IMcpClient client , CancellationToken cancellationToken = default )
278- => AsClientOrThrow ( client ) . EnumerateResourceTemplatesAsync ( cancellationToken ) ;
278+ => AsClientOrThrow ( client ) . EnumerateResourceTemplatesAsync ( null , cancellationToken ) ;
279279
280280 /// <summary>
281281 /// Retrieves a list of available resources from the server.
@@ -289,15 +289,15 @@ public static IAsyncEnumerable<McpClientResourceTemplate> EnumerateResourceTempl
289289 /// It automatically handles pagination with cursors if the server responds with only a portion per request.
290290 /// </para>
291291 /// <para>
292- /// For servers with a large number of resources and that responds with paginated responses, consider using
292+ /// For servers with a large number of resources and that responds with paginated responses, consider using
293293 /// <see cref="EnumerateResourcesAsync"/> instead, as it streams resources as they arrive rather than loading them all at once.
294294 /// </para>
295295 /// </remarks>
296296 /// <example>
297297 /// <code>
298298 /// // Get all resources available on the server
299299 /// var resources = await client.ListResourcesAsync();
300- ///
300+ ///
301301 /// // Display information about each resource
302302 /// foreach (var resource in resources)
303303 /// {
@@ -310,7 +310,7 @@ public static IAsyncEnumerable<McpClientResourceTemplate> EnumerateResourceTempl
310310 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
311311 public static ValueTask < IList < McpClientResource > > ListResourcesAsync (
312312 this IMcpClient client , CancellationToken cancellationToken = default )
313- => AsClientOrThrow ( client ) . ListResourcesAsync ( cancellationToken ) ;
313+ => AsClientOrThrow ( client ) . ListResourcesAsync ( null , cancellationToken ) ;
314314
315315 /// <summary>
316316 /// Creates an enumerable for asynchronously enumerating all available resources from the server.
@@ -343,7 +343,7 @@ public static ValueTask<IList<McpClientResource>> ListResourcesAsync(
343343 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
344344 public static IAsyncEnumerable < McpClientResource > EnumerateResourcesAsync (
345345 this IMcpClient client , CancellationToken cancellationToken = default )
346- => AsClientOrThrow ( client ) . EnumerateResourcesAsync ( cancellationToken ) ;
346+ => AsClientOrThrow ( client ) . EnumerateResourcesAsync ( null , cancellationToken ) ;
347347
348348 /// <summary>
349349 /// Reads a resource from the server.
@@ -358,7 +358,7 @@ public static IAsyncEnumerable<McpClientResource> EnumerateResourcesAsync(
358358 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
359359 public static ValueTask < ReadResourceResult > ReadResourceAsync (
360360 this IMcpClient client , string uri , CancellationToken cancellationToken = default )
361- => AsClientOrThrow ( client ) . ReadResourceAsync ( uri , cancellationToken ) ;
361+ => AsClientOrThrow ( client ) . ReadResourceAsync ( uri , null , cancellationToken ) ;
362362
363363 /// <summary>
364364 /// Reads a resource from the server.
@@ -372,7 +372,7 @@ public static ValueTask<ReadResourceResult> ReadResourceAsync(
372372 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
373373 public static ValueTask < ReadResourceResult > ReadResourceAsync (
374374 this IMcpClient client , Uri uri , CancellationToken cancellationToken = default )
375- => AsClientOrThrow ( client ) . ReadResourceAsync ( uri , cancellationToken ) ;
375+ => AsClientOrThrow ( client ) . ReadResourceAsync ( uri , null , cancellationToken ) ;
376376
377377 /// <summary>
378378 /// Reads a resource from the server.
@@ -388,7 +388,7 @@ public static ValueTask<ReadResourceResult> ReadResourceAsync(
388388 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
389389 public static ValueTask < ReadResourceResult > ReadResourceAsync (
390390 this IMcpClient client , string uriTemplate , IReadOnlyDictionary < string , object ? > arguments , CancellationToken cancellationToken = default )
391- => AsClientOrThrow ( client ) . ReadResourceAsync ( uriTemplate , arguments , cancellationToken ) ;
391+ => AsClientOrThrow ( client ) . ReadResourceAsync ( uriTemplate , arguments , null , cancellationToken ) ;
392392
393393 /// <summary>
394394 /// Requests completion suggestions for a prompt argument or resource reference.
@@ -410,7 +410,7 @@ public static ValueTask<ReadResourceResult> ReadResourceAsync(
410410 /// auto-completion in user interfaces.
411411 /// </para>
412412 /// <para>
413- /// When working with resource references, the server will return suggestions relevant to the specified
413+ /// When working with resource references, the server will return suggestions relevant to the specified
414414 /// resource URI.
415415 /// </para>
416416 /// </remarks>
@@ -452,7 +452,7 @@ public static ValueTask<CompleteResult> CompleteAsync(this IMcpClient client, Re
452452 [ Obsolete ( $ "Use { nameof ( McpClient ) } .{ nameof ( McpClient . SubscribeToResourceAsync ) } instead. This member will be removed in a subsequent release.") ] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
453453 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
454454 public static Task SubscribeToResourceAsync ( this IMcpClient client , string uri , CancellationToken cancellationToken = default )
455- => AsClientOrThrow ( client ) . SubscribeToResourceAsync ( uri , cancellationToken ) ;
455+ => AsClientOrThrow ( client ) . SubscribeToResourceAsync ( uri , null , cancellationToken ) ;
456456
457457 /// <summary>
458458 /// Subscribes to a resource on the server to receive notifications when it changes.
@@ -481,7 +481,7 @@ public static Task SubscribeToResourceAsync(this IMcpClient client, string uri,
481481 [ Obsolete ( $ "Use { nameof ( McpClient ) } .{ nameof ( McpClient . SubscribeToResourceAsync ) } instead. This member will be removed in a subsequent release.") ] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
482482 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
483483 public static Task SubscribeToResourceAsync ( this IMcpClient client , Uri uri , CancellationToken cancellationToken = default )
484- => AsClientOrThrow ( client ) . SubscribeToResourceAsync ( uri , cancellationToken ) ;
484+ => AsClientOrThrow ( client ) . SubscribeToResourceAsync ( uri , null , cancellationToken ) ;
485485
486486 /// <summary>
487487 /// Unsubscribes from a resource on the server to stop receiving notifications about its changes.
@@ -510,7 +510,7 @@ public static Task SubscribeToResourceAsync(this IMcpClient client, Uri uri, Can
510510 [ Obsolete ( $ "Use { nameof ( McpClient ) } .{ nameof ( McpClient . UnsubscribeFromResourceAsync ) } instead. This member will be removed in a subsequent release.") ] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
511511 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
512512 public static Task UnsubscribeFromResourceAsync ( this IMcpClient client , string uri , CancellationToken cancellationToken = default )
513- => AsClientOrThrow ( client ) . UnsubscribeFromResourceAsync ( uri , cancellationToken ) ;
513+ => AsClientOrThrow ( client ) . UnsubscribeFromResourceAsync ( uri , null , cancellationToken ) ;
514514
515515 /// <summary>
516516 /// Unsubscribes from a resource on the server to stop receiving notifications about its changes.
@@ -538,7 +538,7 @@ public static Task UnsubscribeFromResourceAsync(this IMcpClient client, string u
538538 [ Obsolete ( $ "Use { nameof ( McpClient ) } .{ nameof ( McpClient . UnsubscribeFromResourceAsync ) } instead. This member will be removed in a subsequent release.") ] // See: https://github.com/modelcontextprotocol/csharp-sdk/issues/774
539539 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
540540 public static Task UnsubscribeFromResourceAsync ( this IMcpClient client , Uri uri , CancellationToken cancellationToken = default )
541- => AsClientOrThrow ( client ) . UnsubscribeFromResourceAsync ( uri , cancellationToken ) ;
541+ => AsClientOrThrow ( client ) . UnsubscribeFromResourceAsync ( uri , null , cancellationToken ) ;
542542
543543 /// <summary>
544544 /// Invokes a tool on the server.
@@ -584,7 +584,7 @@ public static ValueTask<CallToolResult> CallToolAsync(
584584 IProgress < ProgressNotificationValue > ? progress = null ,
585585 JsonSerializerOptions ? serializerOptions = null ,
586586 CancellationToken cancellationToken = default )
587- => AsClientOrThrow ( client ) . CallToolAsync ( toolName , arguments , progress , serializerOptions , cancellationToken ) ;
587+ => AsClientOrThrow ( client ) . CallToolAsync ( toolName , arguments , progress , new RequestOptions { JsonSerializerOptions = serializerOptions } , cancellationToken ) ;
588588
589589 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
590590#pragma warning disable CS0618 // Type or member is obsolete
0 commit comments