|
1 | | -using Microsoft.Extensions.DependencyInjection; |
| 1 | +using Microsoft.Extensions.DependencyInjection; |
2 | 2 | using Microsoft.Extensions.Logging; |
3 | 3 | using Microsoft.Extensions.Logging.Abstractions; |
4 | 4 |
|
@@ -203,9 +203,9 @@ private async Task ConnectInternalAsync( |
203 | 203 | // Configure server options |
204 | 204 | var serverOptions = new McpServerOptions |
205 | 205 | { |
206 | | - ServerInfo = new Protocol.Types.Implementation { Name = "InMemoryServer", Version = "1.0" }, |
| 206 | + ServerInfo = new Types.Implementation { Name = "InMemoryServer", Version = "1.0" }, |
207 | 207 | ProtocolVersion = "2024", |
208 | | - Capabilities = new Protocol.Types.ServerCapabilities() |
| 208 | + Capabilities = new Types.ServerCapabilities() |
209 | 209 | }; |
210 | 210 |
|
211 | 211 | services.AddOptions<McpServerOptions>().Configure(options => |
@@ -320,6 +320,20 @@ private async Task CleanupAsync(CancellationToken cancellationToken = default) |
320 | 320 | // Complete the shared channel |
321 | 321 | _sharedChannel.Writer.Complete(); |
322 | 322 |
|
| 323 | + // now wait for the server task to complete |
| 324 | + if (_serverTask != null) |
| 325 | + { |
| 326 | + try |
| 327 | + { |
| 328 | + _logger.TransportWaitingForReadTask(_endpointName); |
| 329 | + await Task.WhenAny(_serverTask, Task.Delay(500, cancellationToken)); |
| 330 | + } |
| 331 | + catch (Exception ex) |
| 332 | + { |
| 333 | + _logger.TransportCleanupReadTaskFailed(_endpointName, ex); |
| 334 | + } |
| 335 | + } |
| 336 | + |
323 | 337 | // Then cancel the server and tasks |
324 | 338 | if (_cancellationTokenSource != null) |
325 | 339 | { |
|
0 commit comments