Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ private async Task<McpClient> ConnectAsync()
Endpoint = new("http://localhost:5000"),
}, HttpClient, LoggerFactory);

return await McpClient.CreateAsync(transport, cancellationToken: TestContext.Current.CancellationToken, loggerFactory: LoggerFactory);
// This server supports discovery; slow startup must not trigger legacy fallback.
return await McpClient.CreateAsync(transport, new()
{
DiscoverProbeTimeout = Timeout.InfiniteTimeSpan,
InitializationTimeout = TestConstants.DefaultTimeout,
}, cancellationToken: TestContext.Current.CancellationToken, loggerFactory: LoggerFactory);
}

[Fact]
Expand Down
17 changes: 15 additions & 2 deletions tests/ModelContextProtocol.Tests/ClientIntegrationTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging;
using ModelContextProtocol.Client;
using ModelContextProtocol.Tests.Utils;
using System.Runtime.InteropServices;

namespace ModelContextProtocol.Tests;
Expand Down Expand Up @@ -45,11 +46,23 @@ public void Initialize(ILoggerFactory loggerFactory)
_loggerFactory = loggerFactory;
}

public Task<McpClient> CreateClientAsync(string clientId, McpClientOptions? clientOptions = null) =>
McpClient.CreateAsync(new StdioClientTransport(clientId switch
public Task<McpClient> CreateClientAsync(string clientId, McpClientOptions? clientOptions = null)
{
if (clientId == "test_server" && clientOptions is null)
{
// This server supports discovery; slow startup must not trigger legacy fallback.
clientOptions = new()
{
DiscoverProbeTimeout = Timeout.InfiniteTimeSpan,
InitializationTimeout = TestConstants.DefaultTimeout,
};
}

return McpClient.CreateAsync(new StdioClientTransport(clientId switch
{
"everything" => EverythingServerTransportOptions,
"test_server" => TestServerTransportOptions,
_ => throw new ArgumentException($"Unknown client ID: {clientId}")
}), clientOptions, loggerFactory: _loggerFactory);
}
}
Loading