From 9976243a86c7a9bbdc44b7ae6d1aaf583adbacc0 Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke Date: Tue, 7 Oct 2025 11:56:49 +0100 Subject: [PATCH 1/8] bumped @mongodb-js-preview/atlas-local version --- package-lock.json | 48 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 747320d19..19cde142b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,7 +75,7 @@ "node": "^20.19.0 || ^22.12.0 || >= 23.0.0" }, "optionalDependencies": { - "@mongodb-js-preview/atlas-local": "^0.0.0-preview.6", + "@mongodb-js-preview/atlas-local": "^0.0.0-preview.7", "kerberos": "^2.2.2" } }, @@ -2050,26 +2050,26 @@ } }, "node_modules/@mongodb-js-preview/atlas-local": { - "version": "0.0.0-preview.6", - "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local/-/atlas-local-0.0.0-preview.6.tgz", - "integrity": "sha512-UoLhTzyrL+99hGwcQyjjtOuWC66zQHgWhRXEj+tQVfDP97v0aKWctRigGVSmMPWnc2r5JdAlfR2M+sULfl7eCg==", + "version": "0.0.0-preview.7", + "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local/-/atlas-local-0.0.0-preview.7.tgz", + "integrity": "sha512-4ceLPuBYFWkJWEZqQ/MyUqKQkM6klrloRPkJexNzT4A4vIBYFPPPQLyVcFjfXc/n+PwNuacYthCY83a5dRoo5w==", "license": "Apache-2.0", "optional": true, "engines": { "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0" }, "optionalDependencies": { - "@mongodb-js-preview/atlas-local-darwin-arm64": "0.0.0-preview.6", - "@mongodb-js-preview/atlas-local-darwin-x64": "0.0.0-preview.6", - "@mongodb-js-preview/atlas-local-linux-arm64-gnu": "0.0.0-preview.6", - "@mongodb-js-preview/atlas-local-linux-x64-gnu": "0.0.0-preview.6", - "@mongodb-js-preview/atlas-local-win32-x64-msvc": "0.0.0-preview.6" + "@mongodb-js-preview/atlas-local-darwin-arm64": "0.0.0-preview.7", + "@mongodb-js-preview/atlas-local-darwin-x64": "0.0.0-preview.7", + "@mongodb-js-preview/atlas-local-linux-arm64-gnu": "0.0.0-preview.7", + "@mongodb-js-preview/atlas-local-linux-x64-gnu": "0.0.0-preview.7", + "@mongodb-js-preview/atlas-local-win32-x64-msvc": "0.0.0-preview.7" } }, "node_modules/@mongodb-js-preview/atlas-local-darwin-arm64": { - "version": "0.0.0-preview.6", - "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-darwin-arm64/-/atlas-local-darwin-arm64-0.0.0-preview.6.tgz", - "integrity": "sha512-xB2h87mdq0W1tq7wZmpUIzS/wmUOrEKRqUYKNbv1g6M8pY/1ln2OCPi1OGj1LUnT8dC/jvklh92Ittj6eb5leg==", + "version": "0.0.0-preview.7", + "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-darwin-arm64/-/atlas-local-darwin-arm64-0.0.0-preview.7.tgz", + "integrity": "sha512-fuL2ALZzh63kRHYe/hnrUNMyNqqH1BwYUtfa8mxFuJLaArAWaQ5iXysCCUWHQQpwUmB7pm4Y/NtPO6wzdXvKKA==", "cpu": [ "arm64" ], @@ -2083,9 +2083,9 @@ } }, "node_modules/@mongodb-js-preview/atlas-local-darwin-x64": { - "version": "0.0.0-preview.6", - "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-darwin-x64/-/atlas-local-darwin-x64-0.0.0-preview.6.tgz", - "integrity": "sha512-5o4fXyXm6lOB1vCOIxRiF2p4NpChFZtjLSvsal+nxHBHJb/tevl7k8kE+dt7a5guO7CW1TCfy71E58NQxxaxkQ==", + "version": "0.0.0-preview.7", + "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-darwin-x64/-/atlas-local-darwin-x64-0.0.0-preview.7.tgz", + "integrity": "sha512-gh/CU/TnaTWfIzyYORzADgp+IlBw9ctEmartMF/uaH+gDWaX8nacQGXSZxR6p2nJuDN9SX1O84/rVuKJZkDlKw==", "cpu": [ "x64" ], @@ -2099,9 +2099,9 @@ } }, "node_modules/@mongodb-js-preview/atlas-local-linux-arm64-gnu": { - "version": "0.0.0-preview.6", - "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-linux-arm64-gnu/-/atlas-local-linux-arm64-gnu-0.0.0-preview.6.tgz", - "integrity": "sha512-ul8odgYVF5jpW56u2WHMs82Pmaf/6giIjQxHbMMafcHUPC87R08+Y0qIp8iY0vl4lTE5CBPXNzIICyPp+Snw9Q==", + "version": "0.0.0-preview.7", + "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-linux-arm64-gnu/-/atlas-local-linux-arm64-gnu-0.0.0-preview.7.tgz", + "integrity": "sha512-hyA4g2YczV9Nmx5pevvHTcBdemdwG91Oll/5sxBFGIeEUv2ySV4fvX835IMsOYemQ0ci1o8VMYeHYVUsUO15aw==", "cpu": [ "arm64" ], @@ -2115,9 +2115,9 @@ } }, "node_modules/@mongodb-js-preview/atlas-local-linux-x64-gnu": { - "version": "0.0.0-preview.6", - "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-linux-x64-gnu/-/atlas-local-linux-x64-gnu-0.0.0-preview.6.tgz", - "integrity": "sha512-90t5SynjHFvhEgh6xXEr86tN5VnKHDK6LrOb9Yuf/IlMHNmFm85Cr/OD/B5jREGxlLl+rWWZE7f+EZn/5pWVgw==", + "version": "0.0.0-preview.7", + "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-linux-x64-gnu/-/atlas-local-linux-x64-gnu-0.0.0-preview.7.tgz", + "integrity": "sha512-vcw+OR3t1erGAe8nb6GXY3u8wVT3fG9sceV2+LVPxC/uq5RKt7JPfs97ftPnSpdiEe+/NgAG/Au2gfB0McfD/Q==", "cpu": [ "x64" ], @@ -2131,9 +2131,9 @@ } }, "node_modules/@mongodb-js-preview/atlas-local-win32-x64-msvc": { - "version": "0.0.0-preview.6", - "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-win32-x64-msvc/-/atlas-local-win32-x64-msvc-0.0.0-preview.6.tgz", - "integrity": "sha512-sxwT5NMMffrHNuPbaywuuu91OZC0CTSJaTQpjdjYWQgdeQDMDyWFNWS6k6irgxbgEMwacv6HUKPuOE/fC+/uNA==", + "version": "0.0.0-preview.7", + "resolved": "https://registry.npmjs.org/@mongodb-js-preview/atlas-local-win32-x64-msvc/-/atlas-local-win32-x64-msvc-0.0.0-preview.7.tgz", + "integrity": "sha512-fclSsGcwIOMudQY3wPAE9/xU5sw+LKQmPt9n+f3t7R4AObDOVzmIK78XzBYRDrvWv3aVBxAxqiIC4TH7oZB3yw==", "cpu": [ "x64" ], diff --git a/package.json b/package.json index 4a685ad13..70ecaf4e3 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "node": "^20.19.0 || ^22.12.0 || >= 23.0.0" }, "optionalDependencies": { - "@mongodb-js-preview/atlas-local": "^0.0.0-preview.6", + "@mongodb-js-preview/atlas-local": "^0.0.0-preview.7", "kerberos": "^2.2.2" } } From 7a5ca8823b2fa7c8c7c4f215ad8e7fe1c88d1382 Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke Date: Thu, 9 Oct 2025 08:25:00 +0100 Subject: [PATCH 2/8] add deploymentid to telemetry data for create and delete local atlas tool --- src/telemetry/types.ts | 1 + src/tools/atlasLocal/atlasLocalTool.ts | 20 +++++++++++++------ .../atlasLocal/create/createDeployment.ts | 3 +++ .../atlasLocal/delete/deleteDeployment.ts | 3 +++ src/tools/tool.ts | 5 +++++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/telemetry/types.ts b/src/telemetry/types.ts index f0392344e..a0f371aeb 100644 --- a/src/telemetry/types.ts +++ b/src/telemetry/types.ts @@ -32,6 +32,7 @@ export type ToolEventProperties = { org_id?: string; cluster_name?: string; is_atlas?: boolean; + atlas_local_deployment_id?: string; }; export type ToolEvent = TelemetryEvent; diff --git a/src/tools/atlasLocal/atlasLocalTool.ts b/src/tools/atlasLocal/atlasLocalTool.ts index 4c97f3e70..df5bd64e5 100644 --- a/src/tools/atlasLocal/atlasLocalTool.ts +++ b/src/tools/atlasLocal/atlasLocalTool.ts @@ -6,6 +6,7 @@ import type { Client } from "@mongodb-js-preview/atlas-local"; export abstract class AtlasLocalToolBase extends ToolBase { public category: ToolCategory = "atlas-local"; + protected deploymentId?: string; protected verifyAllowed(): boolean { return this.session.atlasLocalClient !== undefined && super.verifyAllowed(); @@ -38,6 +39,15 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue return this.executeWithAtlasLocalClient(client, ...args); } + protected async lookupDeploymentIdAndAddToTelemetryMetadata( + client: Client, + containerId: string, + + ): Promise { + const deploymentId = await client.getDeploymentId(containerId); + this.deploymentId = deploymentId; + } + protected abstract executeWithAtlasLocalClient( client: Client, ...args: Parameters> @@ -67,11 +77,9 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue return super.handleError(error, args); } - protected resolveTelemetryMetadata( - ...args: Parameters> - ): TelemetryToolMetadata { - // TODO: include deployment id in the metadata where possible - void args; // this shuts up the eslint rule until we implement the TODO above - return {}; + protected resolveTelemetryMetadata(): TelemetryToolMetadata { + return { + atlasLocaldeploymentId: this.deploymentId, + }; } } diff --git a/src/tools/atlasLocal/create/createDeployment.ts b/src/tools/atlasLocal/create/createDeployment.ts index 17cf26dab..0a5257fe0 100644 --- a/src/tools/atlasLocal/create/createDeployment.ts +++ b/src/tools/atlasLocal/create/createDeployment.ts @@ -26,6 +26,9 @@ export class CreateDeploymentTool extends AtlasLocalToolBase { // Create the deployment const deployment = await client.createDeployment(deploymentOptions); + // Lookup the deployment id and add it to the telemetry metadata + await this.lookupDeploymentIdAndAddToTelemetryMetadata(client, deployment.containerId); + return { content: [ { diff --git a/src/tools/atlasLocal/delete/deleteDeployment.ts b/src/tools/atlasLocal/delete/deleteDeployment.ts index 6d0d6616a..cf490e8f0 100644 --- a/src/tools/atlasLocal/delete/deleteDeployment.ts +++ b/src/tools/atlasLocal/delete/deleteDeployment.ts @@ -16,6 +16,9 @@ export class DeleteDeploymentTool extends AtlasLocalToolBase { client: Client, { deploymentName }: ToolArgs ): Promise { + // Lookup the deployment id and add it to the telemetry metadata + await this.lookupDeploymentIdAndAddToTelemetryMetadata(client, deploymentName); + // Delete the deployment await client.deleteDeployment(deploymentName); diff --git a/src/tools/tool.ts b/src/tools/tool.ts index 85f166b3a..85220079e 100644 --- a/src/tools/tool.ts +++ b/src/tools/tool.ts @@ -16,6 +16,7 @@ export type ToolCategory = "mongodb" | "atlas" | "atlas-local"; export type TelemetryToolMetadata = { projectId?: string; orgId?: string; + atlasLocaldeploymentId?: string; }; export type ToolConstructor = new (session: Session, config: UserConfig, telemetry: Telemetry) => ToolBase; @@ -232,6 +233,10 @@ export abstract class ToolBase { event.properties.project_id = metadata.projectId; } + if (metadata?.atlasLocaldeploymentId) { + event.properties.atlas_local_deployment_id = metadata.atlasLocaldeploymentId; + } + await this.telemetry.emitEvents([event]); } } From 5693c22ccca66c5737ba1439c12922f722d6823c Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke Date: Thu, 9 Oct 2025 08:32:09 +0100 Subject: [PATCH 3/8] add deploymentid to telemetry data for the connect to local atlas tool --- src/tools/atlasLocal/connect/connectDeployment.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tools/atlasLocal/connect/connectDeployment.ts b/src/tools/atlasLocal/connect/connectDeployment.ts index e2420aef2..cafb56bdf 100644 --- a/src/tools/atlasLocal/connect/connectDeployment.ts +++ b/src/tools/atlasLocal/connect/connectDeployment.ts @@ -22,6 +22,9 @@ export class ConnectDeploymentTool extends AtlasLocalToolBase { // Connect to the deployment await this.session.connectToMongoDB({ connectionString }); + // Lookup the deployment id and add it to the telemetry metadata + await this.lookupDeploymentIdAndAddToTelemetryMetadata(client, deploymentName); + return { content: [ { From 26cc9fab4692487ccc5423b12c779cc7780e0319 Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke Date: Thu, 9 Oct 2025 08:39:22 +0100 Subject: [PATCH 4/8] don't lookup deployment id when telemetry is disabled --- src/tools/atlasLocal/atlasLocalTool.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tools/atlasLocal/atlasLocalTool.ts b/src/tools/atlasLocal/atlasLocalTool.ts index df5bd64e5..f9ac6df59 100644 --- a/src/tools/atlasLocal/atlasLocalTool.ts +++ b/src/tools/atlasLocal/atlasLocalTool.ts @@ -44,6 +44,12 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue containerId: string, ): Promise { + // Don't run if telemetry is disabled + if (this.config.telemetry === "disabled") { + return; + } + + // Lookup the deployment id and add it to the telemetry metadata const deploymentId = await client.getDeploymentId(containerId); this.deploymentId = deploymentId; } From e2cc80c5332a32c013d81d5dd428f2bc419bd29f Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke Date: Thu, 9 Oct 2025 08:40:12 +0100 Subject: [PATCH 5/8] ran 'npm run fix' --- src/tools/atlasLocal/atlasLocalTool.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/tools/atlasLocal/atlasLocalTool.ts b/src/tools/atlasLocal/atlasLocalTool.ts index f9ac6df59..5c4f5a9cf 100644 --- a/src/tools/atlasLocal/atlasLocalTool.ts +++ b/src/tools/atlasLocal/atlasLocalTool.ts @@ -39,11 +39,7 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue return this.executeWithAtlasLocalClient(client, ...args); } - protected async lookupDeploymentIdAndAddToTelemetryMetadata( - client: Client, - containerId: string, - - ): Promise { + protected async lookupDeploymentIdAndAddToTelemetryMetadata(client: Client, containerId: string): Promise { // Don't run if telemetry is disabled if (this.config.telemetry === "disabled") { return; From 61ae9cfb6ebb8d8b53ced2077ab121e192ea08e7 Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke Date: Thu, 9 Oct 2025 08:42:42 +0100 Subject: [PATCH 6/8] Improved comment in atlasLocalTools.ts --- src/tools/atlasLocal/atlasLocalTool.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/atlasLocal/atlasLocalTool.ts b/src/tools/atlasLocal/atlasLocalTool.ts index 5c4f5a9cf..b10cb9d23 100644 --- a/src/tools/atlasLocal/atlasLocalTool.ts +++ b/src/tools/atlasLocal/atlasLocalTool.ts @@ -45,7 +45,8 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue return; } - // Lookup the deployment id and add it to the telemetry metadata + // Lookup the deployment id and save it to the deploymentId property. + // This property will be added to the telemetry metadata when resolveTelemetryMetadata is called. const deploymentId = await client.getDeploymentId(containerId); this.deploymentId = deploymentId; } From 91ce76d2837dbe31ad65831356c0b646df56abf3 Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke Date: Thu, 9 Oct 2025 09:25:20 +0100 Subject: [PATCH 7/8] use this.telemetry.isTelemetryEnabled() instead of this.config.telemetry === 'disabled' --- src/tools/atlasLocal/atlasLocalTool.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/atlasLocal/atlasLocalTool.ts b/src/tools/atlasLocal/atlasLocalTool.ts index b10cb9d23..ecd17aabf 100644 --- a/src/tools/atlasLocal/atlasLocalTool.ts +++ b/src/tools/atlasLocal/atlasLocalTool.ts @@ -41,7 +41,7 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue protected async lookupDeploymentIdAndAddToTelemetryMetadata(client: Client, containerId: string): Promise { // Don't run if telemetry is disabled - if (this.config.telemetry === "disabled") { + if (this.telemetry.isTelemetryEnabled()) { return; } From 0b1881c44334d186b3e50dc3f8340007d82bfe2c Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke Date: Thu, 9 Oct 2025 09:31:32 +0100 Subject: [PATCH 8/8] renamed lookupDeploymentIdAndAddToTelemetryMetadata to lookupDeploymentId --- src/tools/atlasLocal/atlasLocalTool.ts | 2 +- src/tools/atlasLocal/connect/connectDeployment.ts | 2 +- src/tools/atlasLocal/create/createDeployment.ts | 2 +- src/tools/atlasLocal/delete/deleteDeployment.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/atlasLocal/atlasLocalTool.ts b/src/tools/atlasLocal/atlasLocalTool.ts index ecd17aabf..b305b196e 100644 --- a/src/tools/atlasLocal/atlasLocalTool.ts +++ b/src/tools/atlasLocal/atlasLocalTool.ts @@ -39,7 +39,7 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue return this.executeWithAtlasLocalClient(client, ...args); } - protected async lookupDeploymentIdAndAddToTelemetryMetadata(client: Client, containerId: string): Promise { + protected async lookupDeploymentId(client: Client, containerId: string): Promise { // Don't run if telemetry is disabled if (this.telemetry.isTelemetryEnabled()) { return; diff --git a/src/tools/atlasLocal/connect/connectDeployment.ts b/src/tools/atlasLocal/connect/connectDeployment.ts index cafb56bdf..1936f1939 100644 --- a/src/tools/atlasLocal/connect/connectDeployment.ts +++ b/src/tools/atlasLocal/connect/connectDeployment.ts @@ -23,7 +23,7 @@ export class ConnectDeploymentTool extends AtlasLocalToolBase { await this.session.connectToMongoDB({ connectionString }); // Lookup the deployment id and add it to the telemetry metadata - await this.lookupDeploymentIdAndAddToTelemetryMetadata(client, deploymentName); + await this.lookupDeploymentId(client, deploymentName); return { content: [ diff --git a/src/tools/atlasLocal/create/createDeployment.ts b/src/tools/atlasLocal/create/createDeployment.ts index 0a5257fe0..1ee76a44f 100644 --- a/src/tools/atlasLocal/create/createDeployment.ts +++ b/src/tools/atlasLocal/create/createDeployment.ts @@ -27,7 +27,7 @@ export class CreateDeploymentTool extends AtlasLocalToolBase { const deployment = await client.createDeployment(deploymentOptions); // Lookup the deployment id and add it to the telemetry metadata - await this.lookupDeploymentIdAndAddToTelemetryMetadata(client, deployment.containerId); + await this.lookupDeploymentId(client, deployment.containerId); return { content: [ diff --git a/src/tools/atlasLocal/delete/deleteDeployment.ts b/src/tools/atlasLocal/delete/deleteDeployment.ts index cf490e8f0..bf6c890f7 100644 --- a/src/tools/atlasLocal/delete/deleteDeployment.ts +++ b/src/tools/atlasLocal/delete/deleteDeployment.ts @@ -17,7 +17,7 @@ export class DeleteDeploymentTool extends AtlasLocalToolBase { { deploymentName }: ToolArgs ): Promise { // Lookup the deployment id and add it to the telemetry metadata - await this.lookupDeploymentIdAndAddToTelemetryMetadata(client, deploymentName); + await this.lookupDeploymentId(client, deploymentName); // Delete the deployment await client.deleteDeployment(deploymentName);