-
Notifications
You must be signed in to change notification settings - Fork 167
feat: introduces dry mode for CLI MCP-297 #747
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
Conversation
458d2d4 to
9c54a3b
Compare
| "apiDeprecationErrors", | ||
| "apiStrict", | ||
| "disableEmbeddingsValidation", | ||
| "dry", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should live here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL we have been doing this for all our variables... that's not great :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be dryRun instead? dry sounds a bit awkward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should live here
yargs-parser parses the arguments considering theseOPTIONSprovided to it and gathers the rest (ones that are not part ofOPTIONS) as unknown arguments which we use further to post warnings about unknown arguments passed.
The alternative is to not pass yargs-parser these OPTIONS and do the verification manually which I don't think bring much value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dry sounds a bit awkward.
more like dry sounds a bit dry? 😄 I have updated the name to
dryRuninstead
src/transports/dryModeRunner.ts
Outdated
| export class DryModeRunner extends TransportRunnerBase { | ||
| private server: Server | undefined; | ||
| private exitProcess: DryModeTestHelpers["exit"]; | ||
| private consoleLogger: DryModeTestHelpers["logger"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private consoleLogger: DryModeTestHelpers["logger"]; | |
| private logger: DryModeTestHelpers["logger"]; |
(nit) this also isn't dependent on a console
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it is dependent on console :) logger is a base class property which I did not want to override because otherwise I would have to conform to the interface.
And because in dryMode we plan to exit as soon as we dump, there is not much sense in logging via Session loggers. This should ideally work the same way as our warnings do and they work through console logging.
src/transports/dryModeRunner.ts
Outdated
| this.consoleLogger.log(JSON.stringify(tools, null, 2)); | ||
| } | ||
|
|
||
| static async assertDryMode( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't really an assertion, is it?
I think we should move this logic into index.ts
new this(...)I never knew you could do that 😃 JS is cool and terrible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't really an assertion, is it?
thanks for pointing this. I have renamed the helpers to be more aligned with what they do.
src/transports/dryModeRunner.ts
Outdated
| this.consoleLogger = logger; | ||
| } | ||
|
|
||
| async start(): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just have this do everything? i.e. combine all the dump functions into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed on the suggestion and have combined dump calls within the start method itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a dry-run mode for the CLI that dumps the server's configuration and enabled tools to the console without starting the server. This is useful for debugging configuration issues and understanding which tools are available.
Key changes:
- Added
--dryRunCLI flag and corresponding configuration option - Created
DryRunModeRunnerclass to handle dry-run execution - Added comprehensive test coverage for the new functionality
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/common/config/userConfig.ts |
Added dryRun boolean configuration field with default value of false |
src/common/config/argsParserOptions.ts |
Registered dryRun as a valid CLI argument option |
src/index.ts |
Refactored help/version handlers and added dry-run request handling logic |
src/transports/dryModeRunner.ts |
New runner class that connects to an in-memory transport and dumps configuration/tools |
tests/unit/transports/dryModeRunner.test.ts |
Unit tests for the DryRunModeRunner class |
tests/unit/common/config.test.ts |
Updated expected defaults to include dryRun: false |
tests/e2e/cli.test.ts |
New e2e tests for CLI entrypoint including dry-run validation |
tests/integration/helpers.ts |
Updated import path for InMemoryTransport |
tests/integration/tools/mongodb/mongodbTool.test.ts |
Updated import path for InMemoryTransport |
package.json |
Changed pretest:accuracy hook to general pretest to ensure build runs before all tests |
3df1573 to
2b38a3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Pull Request Test Coverage Report for Build 19697411085Details
💛 - Coveralls |
70a1e58 to
450dee7
Compare
| process.exit(0); | ||
| } | ||
|
|
||
| export async function handleDryRunRequest(config: UserConfig): Promise<never> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function might as well be moved to dryModeRunner.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although I also am fine with keeping as is because of usage of process.exit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe these functions shouldn't process.exit themselves and instead return and then a larger function would process.exit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function might as well be moved to [dryModeRunner.ts]
It was originally there but I moved it to index file based on the suggestion here. For me, either is fine but I still moved it to index only to have all the CLI args handling in one place.
I think its fine for them to take control of exiting - that's a pattern I have seen commander where different args have different action paths and they all independently terminate the process.
gagik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one note about process.exit
1. assert function are not assertions so fixed them with relevant names 2. moved static method logic to cli entry point and added e2e for test cases
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
450dee7 to
5884a5a
Compare
Proposed changes
Introduces dry mode for dumping used configuration and enabled tools.
Checklist