diff --git a/docs/concepts/filters.md b/docs/concepts/filters.md index 321c8193b..9f63dd962 100644 --- a/docs/concepts/filters.md +++ b/docs/concepts/filters.md @@ -317,7 +317,7 @@ Execution flow: `filter1 -> filter2 -> filter3 -> baseHandler -> filter3 -> filt { var logger = context.Services?.GetService>(); - logger?.LogInformation($"Processing request from {context.Meta.ProgressToken}"); + logger?.LogInformation($"Processing request from {context.Params?.ProgressToken}"); var result = await next(context, cancellationToken); logger?.LogInformation($"Returning {result.Tools?.Count ?? 0} tools"); return result; @@ -339,11 +339,11 @@ Execution flow: `filter1 -> filter2 -> filter3 -> baseHandler -> filter3 -> filt catch (Exception ex) { var logger = context.Services?.GetService>(); - logger?.LogError(ex, "Error while processing CallTool request for {ProgressToken}", context.Meta.ProgressToken); + logger?.LogError(ex, "Error while processing CallTool request for {ProgressToken}", context.Params?.ProgressToken); return new CallToolResult { - Content = new[] { new TextContent { Type = "text", Text = "An unexpected error occurred while processing the tool call." } }, + Content = [new TextContentBlock { Text = "An unexpected error occurred while processing the tool call." }], IsError = true }; } @@ -576,7 +576,7 @@ You can also create custom authorization filters using the filter methods: { return new CallToolResult { - Content = [new TextContent { Text = "Custom: Authentication required" }], + Content = [new TextContentBlock { Text = "Custom: Authentication required" }], IsError = true }; } diff --git a/docs/concepts/logging/logging.md b/docs/concepts/logging/logging.md index 5a74af088..f50e874cc 100644 --- a/docs/concepts/logging/logging.md +++ b/docs/concepts/logging/logging.md @@ -54,7 +54,7 @@ server to perform any special logic it wants to perform when a client sets the l SDK already takes care of setting the in the , so most servers will not need to implement this. -MCP Servers using the MCP C# SDK can obtain an [ILoggerProvider](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.iloggerprovider) from the IMcpServer extension method, +MCP Servers using the MCP C# SDK can obtain an [ILoggerProvider](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.iloggerprovider) from the method on , and from that can create an [ILogger](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger) instance for logging messages that should be sent to the MCP client. [!code-csharp[](samples/server/Tools/LoggingTools.cs?name=snippet_LoggingConfiguration)] diff --git a/docs/concepts/progress/progress.md b/docs/concepts/progress/progress.md index 003d65e67..e259a224e 100644 --- a/docs/concepts/progress/progress.md +++ b/docs/concepts/progress/progress.md @@ -37,7 +37,7 @@ The client should also provide a notification handler to process "notifications/ There are two ways to do this. The first is to register a notification handler using the method on the instance. A handler registered this way will receive all progress notifications sent by the server. ```csharp -mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification, +await using var handler = mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification, (notification, cancellationToken) => { if (JsonSerializer.Deserialize(notification.Params) is { } pn && @@ -47,7 +47,7 @@ mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification, Console.WriteLine($"Tool progress: {pn.Progress.Progress} of {pn.Progress.Total} - {pn.Progress.Message}"); } return ValueTask.CompletedTask; - }).ConfigureAwait(false); + }); ``` The second way is to pass a [`Progress`](https://learn.microsoft.com/dotnet/api/system.progress-1) instance to the tool method. `Progress` is a standard .NET type that provides a way to receive progress updates. diff --git a/docs/concepts/tasks/tasks.md b/docs/concepts/tasks/tasks.md index 1b312d9c5..412b56b7e 100644 --- a/docs/concepts/tasks/tasks.md +++ b/docs/concepts/tasks/tasks.md @@ -75,11 +75,13 @@ The `InMemoryMcpTaskStore` constructor accepts several optional parameters: ```csharp var taskStore = new InMemoryMcpTaskStore( - defaultTtl: TimeSpan.FromHours(1), // Default task retention time - maxTtl: TimeSpan.FromHours(24), // Maximum allowed TTL - pollInterval: TimeSpan.FromSeconds(1), // Suggested client poll interval + defaultTtl: TimeSpan.FromHours(1), // Default task retention time + maxTtl: TimeSpan.FromHours(24), // Maximum allowed TTL + pollInterval: TimeSpan.FromSeconds(1), // Suggested client poll interval cleanupInterval: TimeSpan.FromMinutes(5), // Background cleanup frequency - pageSize: 100 // Tasks per page for listing + pageSize: 100, // Tasks per page for listing + maxTasks: 1000, // Maximum total tasks allowed + maxTasksPerSession: 100 // Maximum tasks per session ); ``` @@ -435,7 +437,7 @@ try { var task = await client.GetTaskAsync(taskId, cancellationToken: ct); } -catch (McpException ex) when (ex.ErrorCode == McpErrorCode.InvalidParams) +catch (McpProtocolException ex) when (ex.ErrorCode == McpErrorCode.InvalidParams) { Console.WriteLine($"Task not found: {taskId}"); }