Skip to content

Commit 19f216c

Browse files
authored
Merge branch 'main' into copilot/fix-exception-for-null-mime-type
2 parents 8135f12 + d9ae6bc commit 19f216c

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/ModelContextProtocol.Core/Client/McpClientImpl.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ internal sealed partial class McpClientImpl : McpClient
2222
private readonly SemaphoreSlim _disposeLock = new(1, 1);
2323
private readonly McpTaskCancellationTokenProvider? _taskCancellationTokenProvider;
2424

25-
private CancellationTokenSource? _connectCts;
26-
2725
private ServerCapabilities? _serverCapabilities;
2826
private Implementation? _serverInfo;
2927
private string? _serverInstructions;
@@ -526,9 +524,6 @@ private void RegisterTaskHandlers(RequestHandlers requestHandlers, IMcpTaskStore
526524
/// </summary>
527525
public async Task ConnectAsync(CancellationToken cancellationToken = default)
528526
{
529-
_connectCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
530-
cancellationToken = _connectCts.Token;
531-
532527
try
533528
{
534529
// We don't want the ConnectAsync token to cancel the message processing loop after we've successfully connected.

src/ModelContextProtocol.Core/Server/McpServerImpl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public McpServerImpl(ITransport transport, McpServerOptions options, ILoggerFact
5858
Throw.IfNull(transport);
5959
Throw.IfNull(options);
6060

61-
options ??= new();
62-
6361
_sessionTransport = transport;
6462
ServerOptions = options;
6563
Services = serviceProvider;

tests/ModelContextProtocol.Tests/DiagnosticTests.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ await RunConnected(async (client, server) =>
3535

3636
// Wait for server-side activities to be exported. The server processes messages
3737
// via fire-and-forget tasks, so activities may not be immediately available
38-
// after the client operation completes.
39-
await WaitForAsync(() => activities.Count(a => a.Kind == ActivityKind.Server) >= 4);
38+
// after the client operation completes. Wait for the specific activity we need
39+
// rather than a count, as other server activities may be exported first.
40+
await WaitForAsync(() => activities.Any(a =>
41+
a.DisplayName == "tools/call DoubleValue" && a.Kind == ActivityKind.Server));
4042
}
4143

4244
Assert.NotEmpty(activities);
@@ -103,8 +105,11 @@ await RunConnected(async (client, server) =>
103105
await Assert.ThrowsAsync<McpProtocolException>(async () => await client.CallToolAsync("does-not-exist", cancellationToken: TestContext.Current.CancellationToken));
104106
}, []);
105107

106-
// Wait for server-side activities to be exported.
107-
await WaitForAsync(() => activities.Count(a => a.Kind == ActivityKind.Server) >= 4);
108+
// Wait for server-side activities to be exported. Wait for specific activities
109+
// rather than a count, as other server activities may be exported first.
110+
await WaitForAsync(() =>
111+
activities.Any(a => a.DisplayName == "tools/call Throw" && a.Kind == ActivityKind.Server) &&
112+
activities.Any(a => a.DisplayName == "tools/call does-not-exist" && a.Kind == ActivityKind.Server));
108113
}
109114

110115
Assert.NotEmpty(activities);
@@ -173,8 +178,10 @@ await RunConnected(async (client, server) =>
173178
await tool.InvokeAsync(new() { ["amount"] = 42 }, TestContext.Current.CancellationToken);
174179
}, []);
175180

176-
// Wait for server-side activities to be exported.
177-
await WaitForAsync(() => activities.Count(a => a.Kind == ActivityKind.Server) >= 3);
181+
// Wait for server-side activities to be exported. Wait for specific activities
182+
// rather than a count, as other server activities may be exported first.
183+
await WaitForAsync(() => activities.Any(a =>
184+
a.DisplayName == "tools/call DoubleValue" && a.Kind == ActivityKind.Server));
178185
}
179186

180187
// The outer activity should have MCP-specific attributes added to it

0 commit comments

Comments
 (0)