Skip to content

feat: Setting MCP up with AI Tooling CLOUDP-384442#952

Open
rubydong wants to merge 32 commits intomainfrom
feature/setup-mcp-with-ai
Open

feat: Setting MCP up with AI Tooling CLOUDP-384442#952
rubydong wants to merge 32 commits intomainfrom
feature/setup-mcp-with-ai

Conversation

@rubydong
Copy link
Collaborator

@rubydong rubydong commented Mar 4, 2026

Proposed changes

  • Added a new script that currently runs with pnpm run:setup (and in the future would be under npx mongodb-mcp-server setup once published)
  • 6 AI tools are supported (Claude Desktop and Code, Cursor, VS Code, Windsurf, Open Code) across three operating systems (Mac, Windows, Linux). At this moment, everything except for Claude Code has been tested on Mac. Testing for windows and linux is to follow shortly and I'll make a subsequent PR as needed.

Additional Info

Screen.Recording.2026-03-12.at.11.07.20.AM.mov

Checklist

@rubydong rubydong force-pushed the feature/setup-mcp-with-ai branch from 880ed5b to c7874e3 Compare March 4, 2026 20:44
@rubydong rubydong changed the title Setting MCP up with AI Tooling feat: Setting MCP up with AI Tooling Mar 4, 2026
@rubydong rubydong changed the title feat: Setting MCP up with AI Tooling feat: Setting MCP up with AI Tooling CLOUDP-384442 Mar 4, 2026
@rubydong rubydong marked this pull request as ready for review March 4, 2026 21:11
@rubydong rubydong requested a review from a team as a code owner March 4, 2026 21:11
Copy link
Collaborator

@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.

Did a first pass - looks solid overall, though I flagged some opportunities to clean up the architecture.

src/index.ts Outdated
Comment on lines +88 to +90
if (config.previewFeatures.includes("setup") && isSetupRequested) {
await handleSetupRequest();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

On a second thought, we probably want to handle the case when the preview feature isn't enabled, otherwise we're silently ignoring the first argument (I know this is super nitty as we'll remove the FF quite soon). Something like:

if (isSetupRequested) {
  if (config.previewFeatures.includes("setup")) {
    await handleSetupRequest();
  } else {
    console.error("Automated MCP setup is in preview. If you want to run the setup flow, enable the 'setup' preview feature");
    process.exit(1);
  }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is the plan to remove the feature flag right before it releases to the public? just wondering about the timeline for my own knowledge

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's what I was thinking - if you want to keep it for a while and circulate the release internally for testing, that's also fine. We can remove the FF in a follow-up release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that works! https://jira.mongodb.org/browse/CLOUDP-386891 i have this ticket to remove it later

@coveralls
Copy link
Collaborator

coveralls commented Mar 6, 2026

Pull Request Test Coverage Report for Build 23072518523

Details

  • 4 of 557 (0.72%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-3.6%) to 78.416%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/setup/setupAiToolsUtils.ts 0 14 0.0%
src/index.ts 0 20 0.0%
src/setup/setupMcpServer.ts 0 208 0.0%
src/setup/aiTool.ts 0 311 0.0%
Totals Coverage Status
Change from base Build 23071006273: -3.6%
Covered Lines: 8166
Relevant Lines: 10408

💛 - Coveralls

@rubydong rubydong requested review from gagik and nirinchev March 6, 2026 20:49
@rubydong rubydong force-pushed the feature/setup-mcp-with-ai branch from f069493 to c6e4132 Compare March 6, 2026 20:59
if (!fs.existsSync(configDir)) {
fs.mkdirSync(configDir, { recursive: true });
}
fs.writeFileSync(configPath, JSON.stringify(opencodeConfig, null, 2));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is problematic - many editors allow comments their configs, even though technically, that's not part of the json spec. By deserializing and serializing, we would be deleting those, which is not acceptable. I know it's quite a bit more involved, but we should look into adding a helper that inserts the additional config without overwriting the entire file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to be sure, you're not talking about comments within this kind of block but for the rest of the file?

{
  "mcpServers": {
    "mongodb-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "mongodb-mcp-server@latest"
      ],
      "env": {
        "MDB_MCP_CONNECTION_STRING": ""
      }
    }
  }
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Including this kind of block - e.g. I can add a comment above the connection string env variable that it's for a staging cluster. Essentially, we should not assume that it's safe to deserialize and then serialize user-generated .json files. We can deserialize if we need to process the contents in a structured way and we can serialize our own section, but then we need to insert our changes without overwriting the rest of the file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

got it, i'll take some time to figure that portion out thanks for the feedback!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if i cannot read their existing config though can i create a new one?
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Absolutely - if there's nothing, we should create a new one. It's just the case where there's an existing config, we shouldn't assume we can overwrite its entire content.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hey Nikola, could you chime in with your thoughts regarding openex here https://mongodb.slack.com/archives/C0AGKDAGVG8/p1773200931654289

is it worthwhile to keep it in and have a not very clean solution to preserve the comments?

@rubydong rubydong force-pushed the feature/setup-mcp-with-ai branch from c8890e2 to a9beca2 Compare March 10, 2026 15:52
@rubydong rubydong force-pushed the feature/setup-mcp-with-ai branch from 6c25676 to 4d8f6f1 Compare March 12, 2026 14:57
@rubydong rubydong requested review from gagik and nirinchev March 12, 2026 14:57
@rubydong rubydong force-pushed the feature/setup-mcp-with-ai branch 2 times, most recently from 2a6f754 to 5710a8c Compare March 13, 2026 18:26
@rubydong rubydong force-pushed the feature/setup-mcp-with-ai branch from 5710a8c to 6ad27ce Compare March 13, 2026 18:27
Copy link
Collaborator

@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.

I think we're close to done here - needs a merge with main to resolve conflicts and testing on all the platforms, but otherwise, let's merge it.

: `xdg-open "${configPath}"`;

// Windows: open path in default app (for tools without a dedicated editor)
const getOpenCommandWindowsDefault = (configPath: string): string => `start "" "${configPath}"`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just tested this out in parallels windows and seems to work for me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's so odd 😭 i commented out the logic for now because it just won't work on my windows but will swing back


export const runSetup = async (config: UserConfig): Promise<void> => {
try {
console.log(chalk.hex("#00ED64")(banner) + "\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

[not blocking] Consider splitting this function into steps so it's easier to follow what's going on. Could look something like

printLogo();
validateNodeVersion();
const platform = validatePlatform();
printInstructions();
const tool = promptForAITool();
const readOnly = promptForReadonly();
const connectionString = promptForConnectionString();
// ...

That way, it'd be easier to follow the flow without the noise of the console.logs and prompting. And the functions themselves can be self-contained in terms of input, output, and error handling, so the main function is just moving from one step to the next.

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.

4 participants