Skip to content

Commit 9efdf47

Browse files
committed
Address feedback
1 parent b519e7a commit 9efdf47

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/ModelContextProtocol/Logging/Log.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ internal static partial class Log
6868
[LoggerMessage(Level = LogLevel.Error, Message = "Request failed for {endpointName} with method {method}: {message} ({code})")]
6969
internal static partial void RequestFailed(this ILogger logger, string endpointName, string method, string message, int code);
7070

71-
[LoggerMessage(Level = LogLevel.Information, Message = "Request '{requestId}' canceled via client notification.")]
72-
internal static partial void RequestCanceled(this ILogger logger, RequestId requestId);
71+
[LoggerMessage(Level = LogLevel.Information, Message = "Request '{requestId}' canceled via client notification with reason '{Reason}'.")]
72+
internal static partial void RequestCanceled(this ILogger logger, RequestId requestId, string? reason);
7373

7474
[LoggerMessage(Level = LogLevel.Information, Message = "Request response received payload for {endpointName}: {payload}")]
7575
internal static partial void RequestResponseReceivedPayload(this ILogger logger, string endpointName, string payload);

src/ModelContextProtocol/Shared/McpSession.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal sealed class McpSession : IDisposable
2626
/// Collection of requests received on this session and currently being handled. The value provides a <see cref="CancellationTokenSource"/>
2727
/// that can be used to request cancellation of the in-flight handler.
2828
/// </summary>
29-
private readonly ConcurrentDictionary<RequestId, CancellationTokenSource> s_handlingRequests = new();
29+
private readonly ConcurrentDictionary<RequestId, CancellationTokenSource> _handlingRequests = new();
3030
private readonly JsonSerializerOptions _jsonOptions;
3131
private readonly ILogger _logger;
3232

@@ -88,7 +88,7 @@ async Task ProcessMessageAsync()
8888
if (messageWithId is not null)
8989
{
9090
combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
91-
s_handlingRequests[messageWithId.Id] = combinedCts;
91+
_handlingRequests[messageWithId.Id] = combinedCts;
9292
}
9393

9494
// Fire and forget the message handling to avoid blocking the transport
@@ -136,7 +136,7 @@ await _transport.SendMessageAsync(new JsonRpcError
136136
{
137137
if (messageWithId is not null)
138138
{
139-
s_handlingRequests.TryRemove(messageWithId.Id, out _);
139+
_handlingRequests.TryRemove(messageWithId.Id, out _);
140140
combinedCts!.Dispose();
141141
}
142142
}
@@ -180,10 +180,10 @@ private async Task HandleNotification(JsonRpcNotification notification)
180180
try
181181
{
182182
if (GetCancelledNotificationParams(notification.Params) is CancelledNotification cn &&
183-
s_handlingRequests.TryGetValue(cn.RequestId, out var cts))
183+
_handlingRequests.TryGetValue(cn.RequestId, out var cts))
184184
{
185185
await cts.CancelAsync().ConfigureAwait(false);
186-
_logger.RequestCanceled(cn.RequestId);
186+
_logger.RequestCanceled(cn.RequestId, cn.Reason);
187187
}
188188
}
189189
catch

0 commit comments

Comments
 (0)