Make MCP client initialization timeout configurable via ToolOptions - #212
Merged
Grant Harris (gwharris7) merged 7 commits intoJun 8, 2026
Merged
Grant Harris (gwharris7) merged 7 commits into
Grant Harris (gwharris7) merged 7 commits into
Conversation
Add nullable McpClientInitializationTimeoutSeconds property to ToolOptions so consumers can override the MCP client initialization timeout. When null (default), the MCP SDK default is used. When set, both McpClientOptions and HttpClient.Timeout are configured to match. Co-Authored-By: Claude Code <noreply@anthropic.com>
Rodrigo Matiazo (matiazo)
requested review from
Copilot,
Rahul Devikar (rahuldevikar761) and
Sellakumaran Kanagarathnam (sellakumaran)
March 10, 2026 19:50
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in configuration surface to the Tooling layer so SDK consumers can override the MCP client initialization timeout (handshake/connection setup) via ToolOptions, helping environments where MCP initialization regularly exceeds the SDK default.
Changes:
- Added
ToolOptions.McpClientInitializationTimeoutSeconds(nullable) to allow overriding MCP initialization timeout. - When set, applies the timeout to both
HttpClient.TimeoutandMcpClientOptions.InitializationTimeoutduring MCP client creation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Tooling/Core/Models/ToolOptions.cs | Introduces a new nullable option to configure MCP client initialization timeout (in seconds). |
| src/Tooling/Core/Services/McpToolServerConfigurationService.cs | Applies the configured timeout when creating the HTTP client and MCP client options for MCP client initialization. |
- Add input validation (1-600s range) with ArgumentOutOfRangeException - Document valid range in ToolOptions XML docs - Preserve original SDK behavior when timeout is null: call McpClientFactory.CreateAsync without McpClientOptions instead of passing a default instance - Add 13 unit tests covering: null default, valid/invalid values, ArgumentOutOfRangeException for out-of-bounds inputs Co-Authored-By: Claude Code <noreply@anthropic.com>
ajmfehr
previously approved these changes
Apr 3, 2026
- Extract GetValidatedInitializationTimeout internal static helper so the timeout TimeSpan is computed once and reused for both HttpClient.Timeout and McpClientOptions.InitializationTimeout. - Use nameof(ToolOptions.McpClientInitializationTimeoutSeconds) as the ArgumentOutOfRangeException ParamName so the offending property is obvious to consumers. - Loosen the GetMcpClientToolsAsync exception assertion to accept either a direct ArgumentOutOfRangeException or one wrapped by InvalidOperationException so the test is decoupled from the outer catch behavior. - Remove the unused IConfiguration mock field from the timeout test class. - Add direct unit coverage for GetValidatedInitializationTimeout (null, valid, and invalid inputs) so the behavioral change is verifiable without a McpClientFactory seam. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sellakumaran Kanagarathnam (sellakumaran)
approved these changes
Jun 4, 2026
ajmfehr
approved these changes
Jun 8, 2026
Grant Harris (gwharris7)
disabled auto-merge
June 8, 2026 17:04
Grant Harris (gwharris7)
enabled auto-merge (squash)
June 8, 2026 17:04
auto-merge was automatically disabled
June 8, 2026 17:42
Pull request was closed
Grant Harris (gwharris7)
enabled auto-merge (squash)
June 8, 2026 17:42
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
McpClientInitializationTimeoutSecondsproperty toToolOptionsso consumers can override the MCP client initialization timeoutnull), the MCP SDK default (60s) is used — no behavioral change for existing consumersMcpClientOptions.InitializationTimeoutandHttpClient.Timeoutare configured to matchMotivation
Consumers connecting to the MCP platform may experience
OperationCanceledExceptionwhen downstream dependencies are slow. The MCP SDK's default 60-second initialization timeout is not configurable throughToolOptions, leaving no way for consumers to adjust it for their agents.Usage
Changes
src/Tooling/Core/Models/ToolOptions.cs— Addint? McpClientInitializationTimeoutSecondspropertysrc/Tooling/Core/Services/McpToolServerConfigurationService.cs— Apply timeout only when explicitly setTest plan
null) uses MCP SDK default timeoutMcpClientOptions.InitializationTimeoutandHttpClient.TimeoutGenerated with Claude Code