@@ -6,7 +6,8 @@ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
66import { ErrorCodes , MongoDBError } from "../../common/errors.js" ;
77import { LogId } from "../../common/logger.js" ;
88import type { Server } from "../../server.js" ;
9- import type { AtlasMetadata } from "../../telemetry/types.js" ;
9+ import type { ConnectionMetadata } from "../../telemetry/types.js" ;
10+ import type { ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js" ;
1011
1112export const DbOperationArgs = {
1213 database : z . string ( ) . describe ( "Database name" ) ,
@@ -111,19 +112,21 @@ export abstract class MongoDBToolBase extends ToolBase {
111112 return this . session . connectToMongoDB ( { connectionString } ) ;
112113 }
113114
115+ /**
116+ * Resolves the tool metadata from the arguments passed to the mongoDB tools.
117+ *
118+ * Since MongoDB tools are executed against a MongoDB instance, the tool calls will always have the connection information.
119+ *
120+ * @param result - The result of the tool call.
121+ * @param args - The arguments passed to the tool
122+ * @returns The tool metadata
123+ */
114124 protected resolveTelemetryMetadata (
115125 // eslint-disable-next-line @typescript-eslint/no-unused-vars
116- result : CallToolResult ,
126+ _result : CallToolResult ,
117127 // eslint-disable-next-line @typescript-eslint/no-unused-vars
118- args : ToolArgs < typeof this . argsShape >
119- ) : AtlasMetadata {
120- const metadata : AtlasMetadata = { } ;
121-
122- // Add projectId to the metadata if running a MongoDB operation to an Atlas cluster
123- if ( this . session . connectedAtlasCluster ?. projectId ) {
124- metadata . project_id = this . session . connectedAtlasCluster . projectId ;
125- }
126-
127- return metadata ;
128+ _args : Parameters < ToolCallback < typeof this . argsShape > >
129+ ) : ConnectionMetadata {
130+ return this . getConnectionInfoMetadata ( ) ;
128131 }
129132}
0 commit comments