Skip to content

feat: add timeout#334

Merged
akitaSummer merged 3 commits intoeggjs:masterfrom
akitaSummer:feat/add-timeout
Jul 1, 2025
Merged

feat: add timeout#334
akitaSummer merged 3 commits intoeggjs:masterfrom
akitaSummer:feat/add-timeout

Conversation

@akitaSummer
Copy link
Contributor

@akitaSummer akitaSummer commented Jul 1, 2025

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Summary by CodeRabbit

  • New Features

    • Added support for an optional timeout property in various controller and resource configuration interfaces.
    • Controllers can now be configured with a timeout value, allowing for more granular control over execution timing.
    • Introduced an optional title property for prompt configurations to enhance prompt metadata.
    • Simplified and unified resource, tool, and prompt registration methods with structured option objects for easier configuration.
  • Bug Fixes

    • None.
  • Tests

    • Updated tests to verify the correct handling of the new timeout and title properties in controller and prompt metadata.

@coderabbitai
Copy link

coderabbitai bot commented Jul 1, 2025

## Walkthrough

The changes introduce an optional `timeout` property to various MCP-related parameter interfaces and propagate its handling throughout the decorator, metadata, and utility layers. Supporting methods for storing and retrieving controller parameters were added, and related tests and fixtures were updated to verify the new property.

## Changes

| File(s)                                                                                   | Change Summary                                                                                          |
|-------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|
| core/types/controller-decorator/MCPController.ts<br>core/types/controller-decorator/MCPPromptParams.ts<br>core/types/controller-decorator/MCPResourceParams.ts<br>core/types/controller-decorator/MCPToolParams.ts | Added optional `timeout?: number` property to several MCP parameter interfaces; added `title?: string` to MCPPromptParams. |
| core/types/controller-decorator/MetadataKey.ts                                            | Added exported constant symbol `CONTROLLER_MCP_CONTROLLER_PARAMS_MAP`.                                 |
| core/controller-decorator/src/util/MCPInfoUtil.ts                                         | Added static methods to set/get MCP controller params metadata on classes.                             |
| core/controller-decorator/src/decorator/mcp/MCPController.ts                              | Decorator now stores the full params object using `MCPInfoUtil.setMCPControllerParams`.                |
| core/controller-decorator/src/impl/mcp/MCPControllerMetaBuilder.ts                        | Passes MCP controller params from metadata to `MCPControllerMeta` during build.                        |
| core/controller-decorator/src/model/MCPControllerMeta.ts                                  | Added optional readonly `timeout` property and constructor parameter for MCP controller params.        |
| core/controller-decorator/src/model/MCPPromptMeta.ts                                     | Added optional readonly `title` property and constructor parameter for MCP prompt metadata.            |
| core/controller-decorator/test/fixtures/MCPController.ts                                  | Decorator usage updated to include `timeout: 60000` in example controller.                             |
| core/controller-decorator/test/MCPMeta.test.ts                                            | Test extended to assert the `timeout` property on controller metadata.                                 |
| plugin/controller/test/mcp/helper.test.ts                                                 | Updated tests to include new `description` and `title` properties in MCPPromptMeta assertions.         |
| plugin/controller/lib/impl/mcp/MCPServerHelper.ts                                         | Refactored resource, tool, and prompt registration methods to use unified registration calls with options objects. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant MCPController (Decorator)
    participant MCPInfoUtil
    participant MCPControllerMetaBuilder
    participant MCPControllerMeta

    User->>MCPController: Apply decorator with params (including timeout)
    MCPController->>MCPInfoUtil: setMCPControllerParams(params, constructor)
    MCPController-->>User: Decorated class

    MCPControllerMetaBuilder->>MCPInfoUtil: getMCPControllerParams(clazz)
    MCPInfoUtil-->>MCPControllerMetaBuilder: params (possibly with timeout)
    MCPControllerMetaBuilder->>MCPControllerMeta: Construct with params (timeout)
    MCPControllerMeta-->>MCPControllerMetaBuilder: MCPControllerMeta instance with timeout

Possibly related issues

Possibly related PRs

  • feat: add mcp #307: Initial introduction of MCPController decorator, MCPInfoUtil utilities, and MCPControllerMeta class that this PR extends by adding full params handling and timeout support.

Suggested labels

enhancement

Suggested reviewers

  • killagu

Poem

In fields of code, a timeout appears,
Controllers now rest, without any fears.
Utilities store, and builders retrieve,
Metadata flows—oh, how we weave!
With every test, the rabbits cheer—
“Sixty thousand hops, and all is clear!”
🐇⏰


<!-- walkthrough_end -->
<!-- This is an auto-generated comment: all tool run failures by coderabbit.ai -->

> [!WARNING]
> There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
> 
> <details>
> <summary>🔧 ESLint</summary>
> 
> > If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
> 
> <details>
> <summary>plugin/controller/lib/impl/mcp/MCPServerHelper.ts</summary>
> 
> 
> Oops! Something went wrong! :(
> 
> ESLint: 8.57.1
> 
> ESLint couldn't find the plugin "eslint-plugin-eggache".
> 
> (The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)
> 
> It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
> 
>     npm install eslint-plugin-eggache@latest --save-dev
> 
> The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".
> 
> If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
> 
> 
> </details>
> 
> <details>
> <summary>plugin/controller/test/mcp/helper.test.ts</summary>
> 
> 
> Oops! Something went wrong! :(
> 
> ESLint: 8.57.1
> 
> ESLint couldn't find the plugin "eslint-plugin-eggache".
> 
> (The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)
> 
> It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
> 
>     npm install eslint-plugin-eggache@latest --save-dev
> 
> The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".
> 
> If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
> 
> 
> </details>
> 
> </details>

<!-- end of auto-generated comment: all tool run failures by coderabbit.ai -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAMxJqLjRaenE2fDxoyAB3NGQHAWZ1Gno5MNgPbERKdABrdTQAZUc2PjzrOwxHARqAZl6AFjD8co9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SdfcydCigpxLXZVujWYAFYODveVYoFFa8yvtrDvdc/0MhekTECrEnVCgGaVGtuZgYoWqYvtorN0adqoI4sMfdrSWVlMfVgdXzD2maLS4MbrNlgesimqdqcHvqZcwAG50BbhkDz2sTVDoQdM5U4ZxbQlXGfwDBcIklAIOWQIJ7k6oIQQuAqA6ILimIUJ9l0I1B2JsIuJeu/xIIihcBes5REBetF3AE6Betn4iZOJuI+vq9ehq9K9aBK8ABOAYAARgGCu4ACY0ASBq9bvaAABWAADke5SG+4AHZ/vegvurvK8ew6ASABAGBHvgejvluIBIBq8SBegGAvu0BQfaA3uSBK9Huvvq8ruBAHuBgvvK9K9/uSArvbvq9ceNUHvaAfuEg4e+vgfYgyfqfXvUfaAruruvuKfYgGABB+fbu6AfvYgPv/uQervJogerveh/u4f4eoBKJ1ANvdNtvkZdvaBesAIjugA== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=eggjs/tegg&utm_content=334):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

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.

Summary of Changes

Hello @akitaSummer, 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 introduces a new timeout configuration option across various Model Context Protocol (MCP) decorators. The changes involve extending existing type definitions, establishing a robust metadata storage and retrieval mechanism for controller parameters, and ensuring the timeout value is correctly integrated into the controller's metadata for subsequent use. A new test case has also been added to validate this functionality.

Highlights

  • New Feature: Timeout Configuration: I've introduced a timeout property that can now be specified within various Model Context Protocol (MCP) related decorators, including @MCPController, @MCPPrompt, @MCPResource, and @MCPTool. This allows for setting specific timeout durations for these components.
  • Metadata Management Enhancement: To support the new timeout feature, I've implemented a mechanism to store and retrieve MCPControllerParams as metadata. This involves defining a new metadata key (CONTROLLER_MCP_CONTROLLER_PARAMS_MAP) and adding utility methods in MCPInfoUtil to manage this data.
  • Data Flow Integration: The timeout value provided in the @MCPController decorator is now correctly propagated through the MCPControllerMetaBuilder and stored within the MCPControllerMeta object. This ensures the configuration is accessible where needed.
  • Type Definition Updates: I've updated the relevant TypeScript interfaces (MCPControllerParams, MCPPromptParams, MCPResourceUriParams, MCPResourceTemplateParams, MCPToolParams) to include the new optional timeout?: number property, ensuring type safety and clarity for developers.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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 timeout feature for MCP controllers by adding a timeout property to the parameters of MCPController, MCPPrompt, MCPTool, and MCPResource decorators. While the configuration for the controller-level timeout is correctly stored in the controller's metadata, the core logic to enforce this timeout appears to be missing, rendering the feature non-functional. Additionally, the implementation for method-level timeouts (for prompts, tools, and resources) is incomplete, as the timeout values are defined in interfaces but not yet utilized. Feedback is provided to address the missing timeout enforcement logic and to improve test coverage to validate the feature's functionality.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
core/controller-decorator/test/MCPMeta.test.ts (1)

24-24: Consider enhancing test coverage for timeout functionality.

The basic assertion is good, but consider adding additional test cases to cover:

  • Default behavior when timeout is not specified
  • Different timeout values
  • Edge cases (zero, negative values)
 assert(fooControllerMetaData.timeout === 60000);
+
+// Additional test cases for timeout
+it('should handle missing timeout', () => {
+  // Test controller without timeout specified
+});
+
+it('should handle different timeout values', () => {
+  // Test various timeout configurations
+});
core/types/controller-decorator/MCPToolParams.ts (1)

13-13: Add documentation for the timeout property.

The timeout property addition is good, but consider adding JSDoc comments to clarify its purpose and units.

 export interface MCPToolParams {
   name?: string;
   description?: string;
+  /** Timeout in milliseconds for tool execution */
   timeout?: number;
 }
core/types/controller-decorator/MCPPromptParams.ts (1)

13-13: Add documentation for consistency with other interfaces.

The timeout property follows the same pattern as other interfaces. Consider adding JSDoc documentation to match the suggestion for MCPToolParams.

 export interface MCPPromptParams {
   name?: string;
   description?: string;
+  /** Timeout in milliseconds for prompt execution */
   timeout?: number;
 }
core/types/controller-decorator/MCPController.ts (1)

6-6: Consider validation and documentation for the controller timeout.

The timeout property addition is consistent with other interfaces. Since this is the main controller interface, consider:

  1. Adding JSDoc documentation
  2. Validation for reasonable timeout values in the implementation
 export interface MCPControllerParams {
   protoName?: string;
   controllerName?: string;
   name?: string;
   version?: string;
+  /** Timeout in milliseconds for controller operations */
   timeout?: number;
 }

Also consider implementing validation in the decorator to ensure timeout values are reasonable (positive numbers, reasonable upper bounds).

core/controller-decorator/src/model/MCPControllerMeta.ts (1)

39-39: Consider potential parameter redundancy.

The constructor now accepts both individual parameters (like name, version) and a meta object that could contain the same properties. While this maintains backward compatibility, it could lead to confusion if both are provided.

Consider documenting the precedence or adding validation to ensure consistency between individual parameters and the meta object.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ef57bf and 0306d69.

📒 Files selected for processing (11)
  • core/controller-decorator/src/decorator/mcp/MCPController.ts (1 hunks)
  • core/controller-decorator/src/impl/mcp/MCPControllerMetaBuilder.ts (1 hunks)
  • core/controller-decorator/src/model/MCPControllerMeta.ts (4 hunks)
  • core/controller-decorator/src/util/MCPInfoUtil.ts (2 hunks)
  • core/controller-decorator/test/MCPMeta.test.ts (1 hunks)
  • core/controller-decorator/test/fixtures/MCPController.ts (1 hunks)
  • core/types/controller-decorator/MCPController.ts (1 hunks)
  • core/types/controller-decorator/MCPPromptParams.ts (1 hunks)
  • core/types/controller-decorator/MCPResourceParams.ts (1 hunks)
  • core/types/controller-decorator/MCPToolParams.ts (1 hunks)
  • core/types/controller-decorator/MetadataKey.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
core/controller-decorator/src/decorator/mcp/MCPController.ts (1)
core/controller-decorator/src/util/MCPInfoUtil.ts (1)
  • MCPInfoUtil (42-166)
core/controller-decorator/src/impl/mcp/MCPControllerMetaBuilder.ts (2)
core/controller-decorator/src/util/MCPInfoUtil.ts (1)
  • MCPInfoUtil (42-166)
core/controller-decorator/src/model/MCPControllerMeta.ts (1)
  • MCPControllerMeta (7-73)
core/controller-decorator/src/util/MCPInfoUtil.ts (4)
core/types/controller-decorator/MCPController.ts (1)
  • MCPControllerParams (1-7)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/types/controller-decorator/MetadataKey.ts (1)
  • CONTROLLER_MCP_CONTROLLER_PARAMS_MAP (29-29)
core/controller-decorator/src/model/MCPControllerMeta.ts (1)
core/types/controller-decorator/MCPController.ts (1)
  • MCPControllerParams (1-7)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Runner-ubuntu (22)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Analyze (typescript)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-ubuntu (20)
🔇 Additional comments (12)
core/types/controller-decorator/MetadataKey.ts (1)

29-29: LGTM: Metadata key follows established patterns.

The new metadata key is correctly implemented following the same naming convention and pattern as other metadata keys in the file.

core/controller-decorator/test/fixtures/MCPController.ts (1)

21-21: LGTM: Timeout property correctly added to test fixture.

The timeout value of 60000ms (60 seconds) is appropriate for testing the new timeout functionality.

core/types/controller-decorator/MCPResourceParams.ts (2)

8-8: LGTM: Timeout property correctly added to MCPResourceUriParams.

The optional timeout property is properly typed and consistent with the broader timeout feature implementation.


15-15: LGTM: Timeout property correctly added to MCPResourceTemplateParams.

The optional timeout property maintains consistency with the MCPResourceUriParams interface.

core/controller-decorator/src/decorator/mcp/MCPController.ts (1)

32-32: LGTM: Parameter storage correctly added to preserve timeout property.

The call to setMCPControllerParams properly stores the entire parameter object, ensuring the timeout property is preserved along with other controller parameters.

core/controller-decorator/src/impl/mcp/MCPControllerMetaBuilder.ts (2)

76-76: LGTM: Controller parameters correctly retrieved for metadata construction.

The retrieval of MCP controller parameters using MCPInfoUtil.getMCPControllerParams follows the established pattern and enables access to the timeout property.


79-79: LGTM: Metadata parameter correctly passed to constructor.

The meta parameter is properly passed to the MCPControllerMeta constructor, allowing the timeout property to be initialized from the stored controller parameters.

core/controller-decorator/src/util/MCPInfoUtil.ts (2)

17-18: LGTM: Required imports correctly added.

The imports for MCPControllerParams and CONTROLLER_MCP_CONTROLLER_PARAMS_MAP are necessary for the new controller parameter management functionality.


60-66: LGTM: Controller parameter management methods correctly implemented.

The new setMCPControllerParams and getMCPControllerParams methods follow the established pattern of other metadata management methods in the class. They properly handle the MCPControllerParams type and use the correct metadata key for storage and retrieval.

core/controller-decorator/src/model/MCPControllerMeta.ts (3)

2-2: LGTM!

The import addition is necessary for the new constructor parameter type.


21-21: LGTM!

The timeout property follows the established pattern of being readonly and optional, consistent with other properties in the class.


53-53: LGTM!

The timeout assignment correctly uses optional chaining to handle the case where meta is undefined, following good TypeScript practices.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
plugin/controller/test/mcp/helper.test.ts (1)

48-58: Consider adding timeout test coverage.

While the PR is titled "feat: add timeout" and the AI summary mentions timeout functionality being added to interfaces, this test doesn't verify timeout behavior. Consider adding test cases to ensure the timeout property is properly handled.

Would you like me to help generate additional test cases to cover the timeout functionality?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0306d69 and 0e3c8a9.

📒 Files selected for processing (3)
  • core/controller-decorator/src/model/MCPPromptMeta.ts (3 hunks)
  • core/types/controller-decorator/MCPPromptParams.ts (1 hunks)
  • plugin/controller/test/mcp/helper.test.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • core/controller-decorator/src/model/MCPPromptMeta.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/types/controller-decorator/MCPPromptParams.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (22)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Analyze (typescript)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
plugin/controller/test/mcp/helper.test.ts (1)

52-53: LGTM: New properties added to test setup.

The addition of description and title properties to the promptMeta configuration is consistent with the interface changes mentioned in the PR summary.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
plugin/controller/lib/impl/mcp/MCPServerHelper.ts (1)

1-12: Timeout Support in MCP Registration APIs Requires Manual Implementation

The MCP SDK’s registerResource, registerTool, and registerPrompt methods do not accept a timeout option in their signatures. By default, the SDK enforces a protocol-level timeout (30–60 s), which can only be overridden via server configuration or an options parameter when handling requests—not at registration time.

To satisfy the PR’s intent of adding timeouts, please update your handlers in plugin/controller/lib/impl/mcp/MCPServerHelper.ts to enforce timeouts manually or via server config:

• Wrap each callback in a Promise.race against a timeout promise:

server.registerResource(name, async (resource) => {
  return Promise.race([
    userReadCallback(resource),
    new Promise((_, reject) =>
      setTimeout(() => reject(new Error('Resource request timed out')), 5000)
    ),
  ]);
});

• Or instantiate/configure McpServer with a custom timeout if your SDK version supports an options.timeout override when creating the server or handling calls.

Locations to update:

  • plugin/controller/lib/impl/mcp/MCPServerHelper.ts – implementations of registerResource, registerTool, and registerPrompt

Ensure you’re on the latest @modelcontextprotocol/sdk release for any built-in timeout overrides; otherwise, the manual wrapping approach is required.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3c8a9 and 38f6702.

📒 Files selected for processing (2)
  • plugin/controller/lib/impl/mcp/MCPServerHelper.ts (3 hunks)
  • plugin/controller/test/mcp/helper.test.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugin/controller/test/mcp/helper.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (22)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (typescript)
🔇 Additional comments (1)
plugin/controller/lib/impl/mcp/MCPServerHelper.ts (1)

53-57: Ensure timeout is propagated in resource registration

The PR adds a timeout property in metadata but the call to this.server.registerResource isn’t including it. Please verify that MCPResourceMeta defines timeout and that registerResource accepts it, then update as follows:

  • File: plugin/controller/lib/impl/mcp/MCPServerHelper.ts
  • Lines: around 53–57

Suggested change:

-    if (resourceMeta.uri || resourceMeta.template) {
-      this.server.registerResource(
-        name,
-        resourceMeta.uri ?? resourceMeta.template!,
-        resourceMeta.metadata ?? {},
-        handler
-      );
+    if (resourceMeta.uri || resourceMeta.template) {
+      const metadata = {
+        ...(resourceMeta.metadata ?? {}),
+        ...(resourceMeta.timeout != null ? { timeout: resourceMeta.timeout } : {}),
+      };
+      this.server.registerResource(
+        name,
+        resourceMeta.uri ?? resourceMeta.template!,
+        metadata,
+        handler
+      );
    } else {
      throw new Error(`MCPResource ${name} must have uri or template`);
    }

@akitaSummer akitaSummer merged commit 6d5d94b into eggjs:master Jul 1, 2025
13 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 26, 2025
4 tasks
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.

2 participants