Skip to content

McpClientFactory.CreateAsync incorrectly claims "Initialization timed out" #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AArnott opened this issue Apr 17, 2025 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@AArnott
Copy link

AArnott commented Apr 17, 2025

Describe the bug

When the CancellationToken passed to McpClientFactory.CreateAsync in canceled before the method completes, it throws an ModelContextProtocol.McpException with the message "Initialization timed out".

This doesn't conform to .NET conventions.

To Reproduce

IMcpClient client = await McpClientFactory.CreateAsync(
   configuration.CreateClientTransport(id),
   clientOptions,
   cancellationToken: new CancellationToken(true));

Expected behavior

I expect an OperationCanceledException that merely expresses the operation is canceled -- not that something timed out (as there was in fact no timer).

@AArnott AArnott added the bug Something isn't working label Apr 17, 2025
@stephentoub
Copy link
Contributor

This should be fixed by #321, but I've added a test to it to help confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants