Skip to content

Fix [mcp client times out after 60 seconds (ignoring timeout option) #245] #849

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

andrea-tomassi
Copy link

This PR fixes the timeout issue where MCP clients would timeout after 60 seconds even when receiving progress notifications from servers performing long-running operations.

Problem
The TypeScript/JavaScript SDK was timing out after 60 seconds regardless of progress updates from the server, while the Python SDK correctly handled progress notifications by resetting the timeout. This inconsistency caused issues for users with long-running MCP tools that send periodic progress updates.

Error encountered:

McpError: MCP error -32001: Request timed out
at Timeout.timeoutHandler (file:///.../@modelcontextprotocol/sdk/dist/esm/shared/protocol.js:282:49)
...
code: -32001,
data: { timeout: 60000 }
Root Cause
The resetTimeoutOnProgress option in RequestOptions defaulted to false, meaning that progress notifications would not reset the request timeout. This required users to explicitly opt-in to the intuitive behavior of keeping connections alive when progress is being reported.

Solution
Changed the default value of resetTimeoutOnProgress from false to true, making the TypeScript/JavaScript SDK behave consistently with the Python SDK. This ensures that:

Progress notifications automatically reset the timeout by default
Long-running operations with progress updates won't timeout prematurely
Backward compatibility is maintained (users can still set resetTimeoutOnProgress: false explicitly)
Changes
Protocol behavior: resetTimeoutOnProgress now defaults to true instead of false
Documentation: Updated JSDoc comments to reflect the new default
Tests: Added comprehensive test coverage for the new default behavior and updated existing tests to prevent interference
Verification
The fix has been verified with:

All existing tests pass (670 total tests)
New test specifically validates default timeout reset behavior
Manual testing with demonstration script confirms progress notifications reset timeout
Build and linting pass successfully
Example of the fix in action:

// Before: Would timeout after 60s despite progress
const result = await client.request(longRunningRequest, schema, {
onprogress: (progress) => console.log(progress)
});

// After: Automatically resets timeout on each progress notification
const result = await client.request(longRunningRequest, schema, {
onprogress: (progress) => console.log(progress) // timeout resets on each call
});
Fixes mcp client times out after 60 seconds (ignoring timeout option) #245

Copilot AI and others added 4 commits August 6, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mcp client times out after 60 seconds (ignoring timeout option)
2 participants