Skip to content

Commit 55cb171

Browse files
committed
update connection tools
1 parent 9a28985 commit 55cb171

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

src/tools/atlas/connect/connectCluster.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { ensureCurrentIpInAccessList } from "../../../common/atlas/accessListUti
88
import type { AtlasClusterConnectionInfo } from "../../../common/connectionManager.js";
99
import { getDefaultRoleFromConfig } from "../../../common/atlas/roles.js";
1010
import { AtlasArgs } from "../../args.js";
11-
import { ConnectionMetadata } from "../../../telemetry/types.js";
11+
import type { ConnectionMetadata } from "../../../telemetry/types.js";
12+
import type { ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
1213

1314
const addedIpAccessListMessage =
1415
"Note: Your current IP address has been added to the Atlas project's IP access list to enable secure connection.";
@@ -305,18 +306,13 @@ export class ConnectClusterTool extends AtlasToolBase {
305306
return { content };
306307
}
307308

308-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
309-
protected override resolveTelemetryMetadata(_args: ToolArgs<typeof this.argsShape>): ConnectionMetadata {
310-
const metadata: ConnectionMetadata = {};
311-
const connectionStringAuthType = this.session.connectionManager.currentConnectionState.connectionStringAuthType;
312-
if (connectionStringAuthType) {
313-
metadata.connection_auth_type = connectionStringAuthType;
314-
}
315-
316-
if (this.session.connectedAtlasCluster?.projectId) {
317-
metadata.project_id = this.session.connectedAtlasCluster.projectId;
318-
}
319-
320-
return metadata;
309+
protected override resolveTelemetryMetadata(
310+
result: CallToolResult,
311+
args: Parameters<ToolCallback<typeof this.argsShape>>
312+
): ConnectionMetadata {
313+
return {
314+
...super.resolveTelemetryMetadata(result, ...args),
315+
...this.getConnectionInfoMetadata(),
316+
};
321317
}
322318
}

src/tools/atlasLocal/connect/connectDeployment.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AtlasLocalToolBase } from "../atlasLocalTool.js";
33
import type { OperationType, ToolArgs } from "../../tool.js";
44
import type { Client } from "@mongodb-js/atlas-local";
55
import { CommonArgs } from "../../args.js";
6+
import type { ConnectionMetadata } from "../../../telemetry/types.js";
67

78
export class ConnectDeploymentTool extends AtlasLocalToolBase {
89
public name = "atlas-local-connect-deployment";
@@ -34,4 +35,11 @@ export class ConnectDeploymentTool extends AtlasLocalToolBase {
3435
},
3536
};
3637
}
38+
39+
protected override resolveTelemetryMetadata(result: CallToolResult): ConnectionMetadata {
40+
return {
41+
...super.resolveTelemetryMetadata(result),
42+
...this.getConnectionInfoMetadata(),
43+
};
44+
}
3745
}

src/tools/mongodb/connect/connect.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { ToolArgs, OperationType, ToolConstructorParams } from "../../tool.
55
import assert from "assert";
66
import type { Server } from "../../../server.js";
77
import { LogId } from "../../../common/logger.js";
8-
import { ConnectionMetadata } from "../../../telemetry/types.js";
98

109
const disconnectedSchema = z
1110
.object({

0 commit comments

Comments
 (0)