-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathconnectDeployment.ts
More file actions
37 lines (32 loc) · 1.43 KB
/
connectDeployment.ts
File metadata and controls
37 lines (32 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { AtlasLocalToolBase } from "../atlasLocalTool.js";
import type { OperationType, ToolArgs } from "../../tool.js";
import type { Client } from "@mongodb-js-preview/atlas-local";
import { CommonArgs } from "../../args.js";
export class ConnectDeploymentTool extends AtlasLocalToolBase {
public name = "atlas-local-connect-deployment";
protected description = "Connect to a MongoDB Atlas Local deployment";
public operationType: OperationType = "connect";
protected argsShape = {
deploymentName: CommonArgs.string().describe("Name of the deployment to connect to"),
};
protected async executeWithAtlasLocalClient(
client: Client,
{ deploymentName }: ToolArgs<typeof this.argsShape>
): Promise<CallToolResult> {
// Get the connection string for the deployment
const connectionString = await client.getConnectionString(deploymentName);
// Connect to the deployment
await this.session.connectToMongoDB({ connectionString });
// Lookup the deployment id and add it to the telemetry metadata
await this.lookupDeploymentId(client, deploymentName);
return {
content: [
{
type: "text",
text: `Successfully connected to Atlas Local deployment "${deploymentName}".`,
},
],
};
}
}