Skip to content

Conversation

Luke-Sanderson
Copy link
Collaborator

@Luke-Sanderson Luke-Sanderson commented Oct 9, 2025

Proposed changes

Jira: MCP-40

Checklist

@Luke-Sanderson Luke-Sanderson marked this pull request as ready for review October 10, 2025 08:06
@Luke-Sanderson Luke-Sanderson requested a review from a team as a code owner October 10, 2025 08:06
@Luke-Sanderson
Copy link
Collaborator Author

Luke-Sanderson commented Oct 10, 2025

@nirinchev @kmruiz @himanshusinghs All PRs to the feature branch has been reviewed but we would like someone from DevTools to review before merging to main please :)

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've gone through the code, but not through the tests yet. There are a couple of suggested changes that will impact the test structure, so I'll hold off on reviewing the tests until those are applied.

Comment on lines +13 to +15
if (process.env.SKIP_ATLAS_LOCAL_TESTS === "true") {
vitestDefaultExcludes.push("**/atlas-local/**");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] Can we apply the same exclusion mechanism for the atlas tests. I know that those are magically excluded by virtue of not providing the API keys, but it's kind of annoying we have several different ways of doing things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense to be explicit, added

Comment on lines 104 to 106
setAtlasLocalClient(atlasLocalClient: Client): void {
this.atlasLocalClient = atlasLocalClient;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

atlasLocalClient is already a public field - this method seems redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed the method

Comment on lines 25 to 26
// Lookup the deployment id and add it to the telemetry metadata
await this.lookupDeploymentId(client, deploymentName);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels a bit awkward and error-prone. Can we move this to resolveTelemetryMetadata similarly to what we do in the atlas tools?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

refactored to be more similar to atlas tools


export abstract class AtlasLocalToolBase extends ToolBase {
public category: ToolCategory = "atlas-local";
protected deploymentId?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't be storing state from previous invocations - it's very flimsy and a potential footgun.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed. Only the create tool now stores the deploymentId so we can associate the tool call with the created deployment in the telemetry

const deploymentOptions: CreateDeploymentOptions = {
name: deploymentName,
creationSource: {
type: "MCPServer" as CreationSourceType,
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
type: "MCPServer" as CreationSourceType,
type: CreationSourceType.MCPServer,

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 was suggested here too. iirc this could not be done because of the way the napi creates a typescript binding from a rust enum.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This suggestion is different from the original one though. Here I'm suggesting using the enum as an enum as opposed to a string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah right, yes in that case the issue is that the atlas-local dependency is optional so you can only import it as a type rather than directly

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, this is super awkward and we should do something to resolve this. If importing the package directly is not allowed, we should ensure we have a lint rule for that to avoid accidental imports. Additionally, we should probably convert these enums into union types so that we don't need to import the package to use them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yes string union type that is the name. We looked into using them since that is the ideal type but napi-rs doesn't support them from what we found

src/server.ts Outdated
Comment on lines 232 to 239
const { Client: AtlasLocalClient } = await import("@mongodb-js-preview/atlas-local");

// Connect to Atlas Local client
// This will fail if docker is not running
const client = AtlasLocalClient.connect();

// Set Atlas Local client
this.session.setAtlasLocalClient(client);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably do this in TransportRunnerBase and cache the client rather than re-do it for every connection. Then we could pass down the client to the server at initialization time and register the tools all the same time.

Comment on lines 254 to 258
console.warn(
"Failed to initialize Atlas Local client, atlas-local tools will be disabled (error: ",
error,
")"
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably handle the two expected errors - failure to import due to unsupported platform and docker not being available and emit more meaningful logs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Split the errors and added more meaningful logging

error: unknown,
args: ToolArgs<typeof this.argsShape>
): Promise<CallToolResult> | CallToolResult {
// Error Handling for expected Atlas Local errors go here
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also handle the case the docker daemon is not running. This can happen if I started the MCP server and at a later point, shut down docker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

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