Skip to content

Conversation

@nzmarktaylor
Copy link

Refactor tool initialization and request handling to include reset timeout on progress (resetTimeoutOnProgress=true) when a new env variable MCP_RESET_TIMEOUT_ON_PROGRESS=true.

Some MCP servers with long-running processes provide progress feedback that allows the client to know that the server is still working on the request, this progress resets the timeout counter allowing for longer calls. To support this we need to provide resetTimeoutOnProgress=true and a callback method, when making calls to MCP tools.

To ensure backwards compatibility we have wrapped this change with an environment variable called MCP_RESET_TIMEOUT_ON_PROGRESS, which defaults to false (no effect on existing implementations), but when set to 'true' it will allow timeout resets for MCP servers that provide progress reports.

Refactor tool initialization and request handling to include reset timeout on progress (resetTimeoutOnProgress=true) when a new env variable MCP_RESET_TIMEOUT_ON_PROGRESS=true.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @nzmarktaylor, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the MCP tool integration by allowing for dynamic timeout management during long-running server processes. It refactors the tool initialization and request handling to incorporate a resetTimeoutOnProgress option, which, when enabled via a new environment variable, ensures that client requests do not time out prematurely if the server is actively providing progress updates. This change maintains backward compatibility by requiring explicit opt-in.

Highlights

  • Timeout Reset on Progress: Introduced a new feature that allows the client to reset the timeout counter for MCP tool requests when the server provides progress feedback, preventing premature timeouts for long-running operations.
  • Environment Variable Control: The new timeout reset behavior is controlled by an environment variable, MCP_RESET_TIMEOUT_ON_PROGRESS. Setting this to 'true' enables the feature.
  • Backward Compatibility: The feature is opt-in and defaults to 'false', ensuring that existing implementations are not affected unless the environment variable is explicitly set.
  • On-Progress Callback: An onprogress callback is now conditionally provided to the client request, which is necessary for the SDK to include a progressToken in requests when timeout reset is active.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a resetTimeoutOnProgress option for MCP tool requests, which is a valuable addition for handling long-running server processes. The implementation correctly uses an environment variable for configuration to ensure backward compatibility. However, my review identified a critical typo that would cause a runtime error, and an instance of code duplication that should be refactored to improve maintainability. Addressing these points will strengthen the implementation.

While preparing the change for the PR a copy and paste error was introduced, this commit is just to fix the critical issue caused by that
Optimize environment variable usage for DRY principles - to address gemini-code-assist request
@nzmarktaylor
Copy link
Author

@gemini-code-assist can you please review the code for the PR again, I have addressed the issues you found.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a resetTimeoutOnProgress option for MCP tool requests, controlled by the MCP_RESET_TIMEOUT_ON_PROGRESS environment variable. The changes look good overall, but I've found an inconsistency in how the new options are applied. In one place, a required callback is missing, which could lead to unexpected timeouts. My review includes a suggestion to fix this.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

1 participant