Skip to content

Conversation

himanshusinghs
Copy link
Contributor

@himanshusinghs himanshusinghs commented Sep 23, 2025

Description

This PR flips the earlier behaviour of MongoDB MCP server auto-starting on VS Code activation. Instead of auto-starting by default, we now show a notification, only when user actually connects to a connection in VSCode, asking users to enable or disable auto-start.

Additionally we've enabled the readOnly mode by default.

Key Changes

New Behavior

  • No auto-start by default: MCP server only starts when explicitly enabled by the user.
  • Repeated notifications: If the user doesn't select an option or the notification auto-dismisses, we will ask again on every new connection attempt.
  • User choice persistence: Once a user makes a decision ('Auto start enabled'/'Start Once'/'Auto start disabled'), their preference is saved and respected
  • Readonly mode enabled by default: The readonly mode is set to be enabled by default.

Migration for Existing Users

We've migrated old config values to preserve explicit user preferences. In the previous logic, only "disabled" represented an intentional user action, so we preserve that choice while treating all other values as requiring user confirmation.

Old mdb.mcp.server value New mdb.mcp.server value Reason
"ask" "prompt" Previous default - ask for permission
"enabled" "prompt" Was auto-set by extension - ask for permission
"disabled" "autoStartDisabled" Explicit user choice - preserve preference
anything else the same as before Explicit user choice - preserve preference

Configuration Values

The new configuration accepts these values:

  • "prompt" (default) - Show notification to request permission
  • "autoStartEnabled" - Automatically start MCP server on VS Code launch, no notifications
  • "autoStartDisabled" - Never auto-start, no notifications

Screenshots

When server is not already running

image

When server is already running

image

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@himanshusinghs himanshusinghs requested a review from a team as a code owner September 23, 2025 12:06
@Copilot Copilot AI review requested due to automatic review settings September 23, 2025 12:06
Copy link
Contributor

@Copilot 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 pull request changes the MongoDB MCP server startup behavior from auto-starting by default to requiring explicit user permission. Instead of automatically starting the MCP server on VS Code activation, the extension now shows a notification asking users to enable or disable auto-start functionality.

Key changes:

  • Replaces auto-start behavior with user permission requests via notifications
  • Migrates old configuration values (ask, enabled, disabled) to new values (Ask, Auto Start Enabled, Auto Start Disabled)
  • Updates the default mdb.mcp.readOnly setting from false to true

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/mcp/mcpController.ts Core logic changes for permission-based MCP server startup and config migration
src/test/suite/mcp/mcpController.test.ts Updated tests to reflect new configuration values and behavior
package.json Updated configuration schema with new enum values and defaults

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@Copilot 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 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

This commit flips the earlier behaviour of MongoDB MCP server
auto-starting on VSCode activate. We will now popup a notification
asking user to enable auto-start or disable it. If the user does not
select any option or the notification auto-dimisses then we will ask for
the same on every start of VSCode and every new connection attempt.
@himanshusinghs himanshusinghs force-pushed the fix/VSCODE-704-flip-mcp-auto-start-behaviour branch from 6436b35 to 6c48e71 Compare September 23, 2025 20:17
Copy link
Contributor

@Copilot 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 6 out of 6 changed files in this pull request and generated 6 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@Copilot 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 6 out of 6 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

mdb.mcp.server could have any value stored in the user config. This
commit splits the retrieval of the stored value in two interfaces.
1. To be used for migration. Retrieves the value as is stored in the
   user config
2. To be used for rest of the logic. Retrieves the value stored in the
   user config and maps it to known and identified values
   ('prompt','autoStartEnabled', 'autoStartDisabled')
We will now keep a track of connection managers created per client
connection and on connection updates, update all the active connection
managers.

Additionally when a client disconnects, we will listen to close event
and cleanup the connection manager from the tracked list.
Copy link
Contributor

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

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

Looks okay - I have mostly stylistic comments. I tried to find it in the tests, but can't seem to - we should validate that when we call MCPController.stopServer() all connection managers are closed and also they're removed from the clientConnectionManagers array.

Additionally, maybe I'm missing it, but the tests for multiple connected clients don't seem to validate that they all have their own states (e.g. disconnecting client 1 doesn't disconnect the connection manager for client 2).

@himanshusinghs
Copy link
Contributor Author

I added the additional tests 955a371 and 0a4f818, thanks for the suggestions, those were certainly needed for clarity around the expected behaviour.

We now show popup only when user connects to a connection in VSCode and
the necessary requirements to prompt are met.

Additionally a few tests are modified to reflect the new reality.
@himanshusinghs himanshusinghs requested a review from Copilot October 1, 2025 15:17
Copy link
Contributor

@Copilot 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 7 out of 9 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

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

Looks good - final nits from me.

@himanshusinghs himanshusinghs merged commit f0e064b into main Oct 6, 2025
13 checks passed
@himanshusinghs himanshusinghs deleted the fix/VSCODE-704-flip-mcp-auto-start-behaviour branch October 6, 2025 08:32
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.

3 participants