Skip to content

Commit c57f917

Browse files
authored
Fix a few bugs in the docs (#1379)
1 parent 2ec082b commit c57f917

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

docs/concepts/filters.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ Execution flow: `filter1 -> filter2 -> filter3 -> baseHandler -> filter3 -> filt
317317
{
318318
var logger = context.Services?.GetService<ILogger<Program>>();
319319

320-
logger?.LogInformation($"Processing request from {context.Meta.ProgressToken}");
320+
logger?.LogInformation($"Processing request from {context.Params?.ProgressToken}");
321321
var result = await next(context, cancellationToken);
322322
logger?.LogInformation($"Returning {result.Tools?.Count ?? 0} tools");
323323
return result;
@@ -339,11 +339,11 @@ Execution flow: `filter1 -> filter2 -> filter3 -> baseHandler -> filter3 -> filt
339339
catch (Exception ex)
340340
{
341341
var logger = context.Services?.GetService<ILogger<Program>>();
342-
logger?.LogError(ex, "Error while processing CallTool request for {ProgressToken}", context.Meta.ProgressToken);
342+
logger?.LogError(ex, "Error while processing CallTool request for {ProgressToken}", context.Params?.ProgressToken);
343343

344344
return new CallToolResult
345345
{
346-
Content = new[] { new TextContent { Type = "text", Text = "An unexpected error occurred while processing the tool call." } },
346+
Content = [new TextContentBlock { Text = "An unexpected error occurred while processing the tool call." }],
347347
IsError = true
348348
};
349349
}
@@ -576,7 +576,7 @@ You can also create custom authorization filters using the filter methods:
576576
{
577577
return new CallToolResult
578578
{
579-
Content = [new TextContent { Text = "Custom: Authentication required" }],
579+
Content = [new TextContentBlock { Text = "Custom: Authentication required" }],
580580
IsError = true
581581
};
582582
}

docs/concepts/logging/logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ server to perform any special logic it wants to perform when a client sets the l
5454
SDK already takes care of setting the <xref:ModelContextProtocol.Server.McpServer.LoggingLevel> in the <xref:ModelContextProtocol.Server.McpServer>, so most servers will not need to
5555
implement this.
5656

57-
MCP Servers using the MCP C# SDK can obtain an [ILoggerProvider](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.iloggerprovider) from the IMcpServer <xref:ModelContextProtocol.Server.McpServer.AsClientLoggerProvider> extension method,
57+
MCP Servers using the MCP C# SDK can obtain an [ILoggerProvider](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.iloggerprovider) from the <xref:ModelContextProtocol.Server.McpServer.AsClientLoggerProvider> method on <xref:ModelContextProtocol.Server.McpServer>,
5858
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.
5959

6060
[!code-csharp[](samples/server/Tools/LoggingTools.cs?name=snippet_LoggingConfiguration)]

docs/concepts/progress/progress.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The client should also provide a notification handler to process "notifications/
3737
There are two ways to do this. The first is to register a notification handler using the <xref:ModelContextProtocol.McpSession.RegisterNotificationHandler*> method on the <xref:ModelContextProtocol.Client.McpClient> instance. A handler registered this way will receive all progress notifications sent by the server.
3838

3939
```csharp
40-
mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification,
40+
await using var handler = mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification,
4141
(notification, cancellationToken) =>
4242
{
4343
if (JsonSerializer.Deserialize<ProgressNotificationParams>(notification.Params) is { } pn &&
@@ -47,7 +47,7 @@ mcpClient.RegisterNotificationHandler(NotificationMethods.ProgressNotification,
4747
Console.WriteLine($"Tool progress: {pn.Progress.Progress} of {pn.Progress.Total} - {pn.Progress.Message}");
4848
}
4949
return ValueTask.CompletedTask;
50-
}).ConfigureAwait(false);
50+
});
5151
```
5252

5353
The second way is to pass a [`Progress<T>`](https://learn.microsoft.com/dotnet/api/system.progress-1) instance to the tool method. `Progress<T>` is a standard .NET type that provides a way to receive progress updates.

docs/concepts/tasks/tasks.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ The `InMemoryMcpTaskStore` constructor accepts several optional parameters:
7575

7676
```csharp
7777
var taskStore = new InMemoryMcpTaskStore(
78-
defaultTtl: TimeSpan.FromHours(1), // Default task retention time
79-
maxTtl: TimeSpan.FromHours(24), // Maximum allowed TTL
80-
pollInterval: TimeSpan.FromSeconds(1), // Suggested client poll interval
78+
defaultTtl: TimeSpan.FromHours(1), // Default task retention time
79+
maxTtl: TimeSpan.FromHours(24), // Maximum allowed TTL
80+
pollInterval: TimeSpan.FromSeconds(1), // Suggested client poll interval
8181
cleanupInterval: TimeSpan.FromMinutes(5), // Background cleanup frequency
82-
pageSize: 100 // Tasks per page for listing
82+
pageSize: 100, // Tasks per page for listing
83+
maxTasks: 1000, // Maximum total tasks allowed
84+
maxTasksPerSession: 100 // Maximum tasks per session
8385
);
8486
```
8587

@@ -435,7 +437,7 @@ try
435437
{
436438
var task = await client.GetTaskAsync(taskId, cancellationToken: ct);
437439
}
438-
catch (McpException ex) when (ex.ErrorCode == McpErrorCode.InvalidParams)
440+
catch (McpProtocolException ex) when (ex.ErrorCode == McpErrorCode.InvalidParams)
439441
{
440442
Console.WriteLine($"Task not found: {taskId}");
441443
}

0 commit comments

Comments
 (0)