File tree Expand file tree Collapse file tree 3 files changed +4
-7
lines changed
Expand file tree Collapse file tree 3 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ MCP includes a [ping mechanism] that allows either side of a connection to verif
1616Use the < xref:ModelContextProtocol.Client.McpClient.PingAsync* > method to verify the server is responsive:
1717
1818``` csharp
19- await client .PingAsync (cancellationToken );
19+ await client .PingAsync (cancellationToken : cancellationToken );
2020```
2121
2222### Automatic ping handling
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ builder.Services.AddMcpServer()
215215 if (ctx .Params ? .Uri is { } uri )
216216 {
217217 // Track the subscription (e.g., in a concurrent dictionary)
218- subscriptions [context .Server .SessionId ].TryAdd (uri , 0 );
218+ subscriptions [ctx .Server .SessionId ].TryAdd (uri , 0 );
219219 }
220220 return new EmptyResult ();
221221 })
Original file line number Diff line number Diff line change @@ -100,11 +100,8 @@ McpClientOptions options = new()
100100 SamplingHandler = async (request , progress , cancellationToken ) =>
101101 {
102102 // Forward to your LLM, apply content filtering, etc.
103- string prompt = request ? .Messages ? .LastOrDefault ()? .Content switch
104- {
105- TextContentBlock text => text .Text ,
106- _ => string .Empty
107- };
103+ string prompt = request ? .Messages ? .LastOrDefault ()? .Content
104+ .OfType <TextContentBlock >().FirstOrDefault ()? .Text ?? string .Empty ;
108105
109106 return new CreateMessageResult
110107 {
You can’t perform that action at this time.
0 commit comments