Skip to content

Commit 2ad8fce

Browse files
Add createDeployment Tool
1 parent 6938a8f commit 2ad8fce

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2+
import { AtlasLocalToolBase } from "../atlasLocalTool.js";
3+
import type { OperationType, ToolArgs } from "../../tool.js";
4+
import type { Client } from "@mongodb-js-preview/atlas-local";
5+
import type { CreateDeploymentOptions, CreationSourceType } from "@mongodb-js-preview/atlas-local";
6+
import z from "zod";
7+
8+
export class CreateDeploymentTool extends AtlasLocalToolBase {
9+
public name = "atlas-local-create-deployment";
10+
protected description = "Create a MongoDB Atlas local deployment";
11+
public operationType: OperationType = "create";
12+
protected argsShape = {
13+
deploymentName: z.string().describe("Name of the deployment to create"),
14+
};
15+
16+
protected async executeWithAtlasLocalClient(
17+
client: Client,
18+
{ deploymentName }: ToolArgs<typeof this.argsShape>
19+
): Promise<CallToolResult> {
20+
const deploymentOptions: CreateDeploymentOptions = {
21+
name: deploymentName,
22+
creationSource: "MCPServer",
23+
};
24+
// Create the deployment
25+
await client.createDeployment(deploymentOptions);
26+
27+
return {
28+
content: [{ type: "text", text: `Deployment ${deploymentName} created.` }],
29+
};
30+
}
31+
}

src/tools/atlasLocal/tools.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DeleteDeploymentTool } from "./delete/deleteDeployment.js";
22
import { ListDeploymentsTool } from "./read/listDeployments.js";
3+
import { CreateDeploymentTool } from "./create/createDeployment.js";
34

4-
export const AtlasLocalTools = [ListDeploymentsTool, DeleteDeploymentTool];
5+
export const AtlasLocalTools = [ListDeploymentsTool, DeleteDeploymentTool, CreateDeploymentTool];

0 commit comments

Comments
 (0)