Conversation
WalkthroughThe change refactors multiple instances in Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant MCPControllerRegister
participant Transport
participant HTTPResponse
Client->>MCPControllerRegister: Send HTTP request
MCPControllerRegister->>Transport: handleRequest(req, res)
Transport-->>HTTPResponse: Process and send response
HTTPResponse-->>MCPControllerRegister: 'close' event emitted (awaited via awaitEvent)
MCPControllerRegister-->>Client: Complete handling after response closes
sequenceDiagram
participant Client
participant MCPProxy
participant Transport
participant HTTPResponse
Client->>MCPProxy: Send stream request
MCPProxy->>Transport: handleRequest(req, res)
Transport-->>HTTPResponse: Process and send response
HTTPResponse-->>MCPProxy: 'close' event emitted (awaited via awaitEvent)
MCPProxy-->>Client: Complete handling after response closes
Possibly related PRs
Suggested reviewers
Poem
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. 🔧 ESLint
plugin/controller/lib/impl/mcp/MCPControllerRegister.tsOops! 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: 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. plugin/controller/test/mcp/mcp.test.tsOops! 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: 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. plugin/mcp-proxy/index.tsOops! 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: 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.
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
plugin/controller/test/mcp/mcp.test.ts (1)
60-66: 🛠️ Refactor suggestion
⚠️ Potential issueRemove duplicate
afterhooks to comply with test-runner rulesTwo separate
afterhooks are registered:after(async () => { … }); // lines 62-64 … after(() => { … }); // lines 82-84Most runners (mocha, jest) treat multiple identical lifecycle hooks as a code-smell and, as Biome points out, will warn or fail with
noDuplicateTestHooks.
Unless you explicitly need both (e.g. different clean-up scopes), consolidate them:-after(async () => { - await app.close(); -}); - -… - -after(() => { - return app.close(); -}); +after(async () => { + await app.close(); +});(The single
await app.close()is sufficient.)Also applies to: 80-85
🧹 Nitpick comments (3)
plugin/controller/test/mcp/mcp.test.ts (1)
66-70: Restore mocked environment between tests
afterEachcurrently contains only commented-out code:// mm.restore();If mocks aren’t restored, state can leak between specs and cause flakiness.
Uncomment (or delete if unused):-// mm.restore(); +mm.restore();plugin/controller/test/mcp/mcpCluster.test.ts (2)
130-141: 5-secondsetTimeoutpauses make the suite slow – consider event-driven awaitsEach protocol test sleeps for 5 s to collect notifications. With three repetitions this adds 15 s+ to every test run.
If possible, replace the hard wait with a promise that resolves when the expected number of notifications arrives, e.g.:
await new Promise<void>(resolve => { const expected = 5; let seen = 0; client.setNotificationHandler(schema, () => { if (++seen === expected) resolve(); }); });This keeps tests deterministic and dramatically speeds up CI.
Also applies to: 224-232, 322-329
66-70: Restore mocks after each caseSame as in
mcp.test.ts– theafterEachhook only contains a commented‐outmm.restore(). Uncomment to avoid state leakage.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
plugin/controller/lib/impl/mcp/MCPControllerRegister.ts(4 hunks)plugin/controller/package.json(1 hunks)plugin/controller/test/mcp/mcp.test.ts(1 hunks)plugin/controller/test/mcp/mcpCluster.test.ts(1 hunks)plugin/mcp-proxy/index.ts(2 hunks)plugin/mcp-proxy/package.json(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- plugin/controller/package.json
- plugin/mcp-proxy/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
- plugin/controller/lib/impl/mcp/MCPControllerRegister.ts
🧰 Additional context used
🪛 Biome (1.9.4)
plugin/controller/test/mcp/mcpCluster.test.ts
[error] 92-94: Disallow duplicate setup and teardown hooks.
Disallow after duplicacy inside the describe function.
(lint/suspicious/noDuplicateTestHooks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Runner-ubuntu (22)
- GitHub Check: Runner-ubuntu (20)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (typescript)
- GitHub Check: Runner-macos (16)
- GitHub Check: Runner-ubuntu (18)
- GitHub Check: Runner-macos (18)
- GitHub Check: Runner-macos (20)
- GitHub Check: Runner-ubuntu (16)
🔇 Additional comments (2)
plugin/controller/test/mcp/mcpCluster.test.ts (1)
75-88: Cluster bootstrap options: unnecessaryNODE_OPTIONSoverride
NODE_OPTIONS: '--require ts-node/register tsconfig-paths/register'is only needed when spawning TypeScript directly. The fixture app is already compiled viaegg-bin. Removing this env override can shorten start-up time and avoid duplicate registrations. Verify whether tests still pass and then drop the option if not required.plugin/mcp-proxy/index.ts (1)
1-3: ESM/CommonJS inter-op: confirmawait-eventsupports default importYou added
import awaitEvent from 'await-event';
await-eventpublishes its entry point asmodule.exports = function awaitEvent….
With Node ≥ 16 in ESM mode,defaultis undefined unless the package has"default"export mapping.Safer import:
import { default as awaitEvent } from 'await-event'; // for CJS packagesor
const awaitEvent = (await import('await-event')).default;Please verify at runtime; otherwise the new code path will throw
TypeError: awaitEvent is not a function.
Checklist
npm testpassesAffected core subsystem(s)
Description of change
Summary by CodeRabbit