@@ -6,6 +6,7 @@ import type { Client } from "@mongodb-js-preview/atlas-local";
66
77export abstract class AtlasLocalToolBase extends ToolBase {
88 public category : ToolCategory = "atlas-local" ;
9+ protected deploymentId ?: string ;
910
1011 protected verifyAllowed ( ) : boolean {
1112 return this . session . atlasLocalClient !== undefined && super . verifyAllowed ( ) ;
@@ -38,6 +39,18 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue
3839 return this . executeWithAtlasLocalClient ( client , ...args ) ;
3940 }
4041
42+ protected async lookupDeploymentId ( client : Client , containerId : string ) : Promise < void > {
43+ // Don't run if telemetry is disabled
44+ if ( this . telemetry . isTelemetryEnabled ( ) ) {
45+ return ;
46+ }
47+
48+ // Lookup the deployment id and save it to the deploymentId property.
49+ // This property will be added to the telemetry metadata when resolveTelemetryMetadata is called.
50+ const deploymentId = await client . getDeploymentId ( containerId ) ;
51+ this . deploymentId = deploymentId ;
52+ }
53+
4154 protected abstract executeWithAtlasLocalClient (
4255 client : Client ,
4356 ...args : Parameters < ToolCallback < typeof this . argsShape > >
@@ -67,11 +80,9 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue
6780 return super . handleError ( error , args ) ;
6881 }
6982
70- protected resolveTelemetryMetadata (
71- ...args : Parameters < ToolCallback < typeof this . argsShape > >
72- ) : TelemetryToolMetadata {
73- // TODO: include deployment id in the metadata where possible
74- void args ; // this shuts up the eslint rule until we implement the TODO above
75- return { } ;
83+ protected resolveTelemetryMetadata ( ) : TelemetryToolMetadata {
84+ return {
85+ atlasLocaldeploymentId : this . deploymentId ,
86+ } ;
7687 }
7788}
0 commit comments