Skip to content

Conversation

@himanshusinghs
Copy link
Collaborator

Proposed changes

Introduces dry mode for dumping used configuration and enabled tools.

Checklist

@himanshusinghs himanshusinghs requested a review from a team as a code owner November 24, 2025 12:17
@himanshusinghs himanshusinghs force-pushed the feat/MCP-297-dry-run-mode branch from 458d2d4 to 9c54a3b Compare November 24, 2025 14:36
@himanshusinghs himanshusinghs changed the base branch from feat/MCP-292-config-file to main November 24, 2025 14:36
"apiDeprecationErrors",
"apiStrict",
"disableEmbeddingsValidation",
"dry",
Copy link
Collaborator

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

Copy link
Collaborator

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 :(

Copy link
Collaborator

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.

Copy link
Collaborator Author

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 these OPTIONS provided to it and gathers the rest (ones that are not part of OPTIONS) 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.

Copy link
Collaborator Author

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 dryRun instead

export class DryModeRunner extends TransportRunnerBase {
private server: Server | undefined;
private exitProcess: DryModeTestHelpers["exit"];
private consoleLogger: DryModeTestHelpers["logger"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
private consoleLogger: DryModeTestHelpers["logger"];
private logger: DryModeTestHelpers["logger"];

(nit) this also isn't dependent on a console

Copy link
Collaborator Author

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.

this.consoleLogger.log(JSON.stringify(tools, null, 2));
}

static async assertDryMode(
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

this.consoleLogger = logger;
}

async start(): Promise<void> {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copilot AI review requested due to automatic review settings November 25, 2025 11:33
Copy link
Contributor

Copilot AI left a 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 --dryRun CLI flag and corresponding configuration option
  • Created DryRunModeRunner class 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

@himanshusinghs himanshusinghs force-pushed the feat/MCP-297-dry-run-mode branch from 3df1573 to 2b38a3f Compare November 25, 2025 11:34
Copy link
Contributor

Copilot AI left a 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.

@coveralls
Copy link
Collaborator

coveralls commented Nov 25, 2025

Pull Request Test Coverage Report for Build 19697411085

Details

  • 38 of 76 (50.0%) changed or added relevant lines in 4 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.3%) to 80.141%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/transports/dryModeRunner.ts 31 33 93.94%
src/index.ts 0 36 0.0%
Files with Coverage Reduction New Missed Lines %
src/index.ts 1 0.65%
Totals Coverage Status
Change from base Build 19677845049: 0.3%
Covered Lines: 6477
Relevant Lines: 7987

💛 - Coveralls

process.exit(0);
}

export async function handleDryRunRequest(config: UserConfig): Promise<never> {
Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator

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?

Copy link
Collaborator Author

@himanshusinghs himanshusinghs Nov 26, 2025

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.

Copy link
Collaborator

@gagik gagik left a 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

himanshusinghs and others added 8 commits November 26, 2025 09:23
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>
@himanshusinghs himanshusinghs force-pushed the feat/MCP-297-dry-run-mode branch from 450dee7 to 5884a5a Compare November 26, 2025 08:33
@himanshusinghs himanshusinghs merged commit 17cdcd1 into main Nov 26, 2025
18 checks passed
@himanshusinghs himanshusinghs deleted the feat/MCP-297-dry-run-mode branch November 26, 2025 11:07
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.

5 participants