Skip to content

Add requestTimeout to MCP server #134

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
wants to merge 3 commits into from

Conversation

EvanMi
Copy link

@EvanMi EvanMi commented Apr 10, 2025

Add timeout config for sever call client.

In Sampling process, Server will send request to client, then client may call LLM, this may cost some time more then 10 seconds, so the fix 10 seconds is too short.

Motivation and Context

How Has This Been Tested?

yes

Breaking Changes

if don't use this feature, they don't need to.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@tzolov tzolov added this to the 0.10.0 milestone Apr 15, 2025
@tzolov tzolov added enhancement New feature or request server labels Apr 15, 2025
@tzolov tzolov self-assigned this Apr 15, 2025
tzolov pushed a commit that referenced this pull request Apr 15, 2025
Adds the ability to configure request timeouts for MCP server operations. This enhancement
allows setting a custom duration to wait for server responses before timing out requests,
which applies to all requests made through the client including tool calls, resource access,
and prompt operations.

- Add requestTimeout parameter to McpServerSession constructor
- Add requestTimeout field and builder method to server classes
- Pass timeout configuration through to session creation
- Add tests for both success and failure scenarios across different transport implementations
- Default timeout is set to 10 seconds if not explicitly configured.
@tzolov
Copy link
Contributor

tzolov commented Apr 15, 2025

Thank you @EvanMi !

Rebased, cherry-picked and merged at 472f07e

@tzolov tzolov closed this Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants