Add per-request timeout configuration support#38
Merged
Conversation
… client The --timeout flag was parsed from CLI options but never propagated to the actual request. The timeout now flows through the full chain: CLI → withMcpClient → withSessionClient → SessionClient → BridgeClient → Bridge → McpClient. - BridgeClient.request() accepts optional timeout parameter (seconds) - IpcMessage includes timeout field forwarded to bridge process - Bridge applies per-request timeout override on McpClient before each call - SessionClient stores and passes timeout to all BridgeClient requests - withSessionClient/withMcpClient thread timeout from CLI options https://claude.ai/code/session_01HmGaGAavxHEZcSRfNguGeo
Tests that --timeout causes tool calls to fail when the server is slower than the timeout, succeeds when generous enough, and produces valid JSON errors in --json mode. https://claude.ai/code/session_01HmGaGAavxHEZcSRfNguGeo
The MCP SDK may produce different error messages on timeout depending on timing (timeout, abort, or session-not-found). Relax assertion to check for failure and non-empty stderr rather than specific "timeout" text. Also increase delays for CI reliability. https://claude.ai/code/session_01HmGaGAavxHEZcSRfNguGeo
jancurn
added a commit
that referenced
this pull request
Mar 7, 2026
* fix: thread --timeout flag through session commands to bridge and MCP client The --timeout flag was parsed from CLI options but never propagated to the actual request. The timeout now flows through the full chain: CLI → withMcpClient → withSessionClient → SessionClient → BridgeClient → Bridge → McpClient. - BridgeClient.request() accepts optional timeout parameter (seconds) - IpcMessage includes timeout field forwarded to bridge process - Bridge applies per-request timeout override on McpClient before each call - SessionClient stores and passes timeout to all BridgeClient requests - withSessionClient/withMcpClient thread timeout from CLI options https://claude.ai/code/session_01HmGaGAavxHEZcSRfNguGeo * test: add E2E integration tests for --timeout flag Tests that --timeout causes tool calls to fail when the server is slower than the timeout, succeeds when generous enough, and produces valid JSON errors in --json mode. https://claude.ai/code/session_01HmGaGAavxHEZcSRfNguGeo * fix: make timeout E2E test resilient to varying error messages The MCP SDK may produce different error messages on timeout depending on timing (timeout, abort, or session-not-found). Relax assertion to check for failure and non-empty stderr rather than specific "timeout" text. Also increase delays for CI reliability. https://claude.ai/code/session_01HmGaGAavxHEZcSRfNguGeo * docs: add --timeout fix to changelog https://claude.ai/code/session_01HmGaGAavxHEZcSRfNguGeo --------- Co-authored-by: Claude <noreply@anthropic.com>
jancurn
pushed a commit
that referenced
this pull request
Mar 7, 2026
…ommands - Add RequestOptionsOverride type and 'set-request-options' IPC message - CLI sends --header flags to bridge via IPC before each command - Bridge applies headers to MCP client transport in-memory (no persistence) - McpClient gains updateTransportHeaders() for runtime header updates - BridgeClient gains sendRequestOptions() for one-way IPC messages - Add debug logging to existing setRequestTimeout() (from PR #38) - Remove --profile option from session commands (use connect --profile) - Timeout handled by PR #38's per-request IPC path (no duplication)
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
This PR adds support for configurable per-request timeouts throughout the MCP client stack, allowing users to override the default 3-minute timeout on a per-request basis via a CLI
--timeoutflag.Key Changes
SessionClient: Added
setRequestTimeout()method andrequestTimeoutproperty to store per-request timeout values. Updated all MCP operation methods to pass the timeout to bridge client requests.BridgeClient: Modified
request()method to accept an optionaltimeoutparameter (in seconds), convert it to milliseconds, and use it instead of the defaultREQUEST_TIMEOUTconstant. The timeout is also included in the IPC message payload.McpClient: Added
setRequestTimeout()method to allow setting timeout values (in milliseconds) for subsequent requests.BridgeProcess: Added logic to extract per-request timeout from IPC messages and apply it to the client before executing requests.
CLI helpers: Updated
withMcpClient()to accept atimeoutoption and pass it through towithSessionClient().Type definitions: Extended
IpcMessageinterface to include optionaltimeoutfield for per-request timeout specification.Implementation Details
https://claude.ai/code/session_01HmGaGAavxHEZcSRfNguGeo