Skip to content

Commit 5bd4705

Browse files
Add deleteDeployment tool
1 parent 8a2db27 commit 5bd4705

File tree

5 files changed

+8218
-5
lines changed

5 files changed

+8218
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
"node": "^20.19.0 || ^22.12.0 || >= 23.0.0"
122122
},
123123
"optionalDependencies": {
124-
"@mongodb-js-preview/atlas-local": "^0.0.0-preview.1",
124+
"@mongodb-js-preview/atlas-local": "^0.0.0-preview.2",
125125
"kerberos": "^2.2.2"
126126
}
127127
}

src/tools/atlasLocal/atlasLocalTool.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export abstract class AtlasLocalToolBase extends ToolBase {
1111
return this.session.atlasLocalClient !== undefined && super.verifyAllowed();
1212
}
1313

14-
protected async execute(): Promise<CallToolResult> {
14+
protected async execute(...args: Parameters<ToolCallback<typeof this.argsShape>>): Promise<CallToolResult> {
1515
// Get the client
1616
const client = this.session.atlasLocalClient;
1717

@@ -35,10 +35,13 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue
3535
};
3636
}
3737

38-
return this.executeWithAtlasLocalClient(client);
38+
return this.executeWithAtlasLocalClient(client, ...args);
3939
}
4040

41-
protected abstract executeWithAtlasLocalClient(client: Client): Promise<CallToolResult>;
41+
protected abstract executeWithAtlasLocalClient(
42+
client: Client,
43+
...args: Parameters<ToolCallback<typeof this.argsShape>>
44+
): Promise<CallToolResult>;
4245

4346
protected handleError(
4447
error: unknown,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { z } from "zod";
2+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3+
import { AtlasLocalToolBase } from "../atlasLocalTool.js";
4+
import type { OperationType, ToolArgs } from "../../tool.js";
5+
import type { Client } from "@mongodb-js-preview/atlas-local";
6+
7+
export class DeleteDeploymentTool extends AtlasLocalToolBase {
8+
public name = "atlas-local-delete-deployment";
9+
protected description = "Delete a MongoDB Atlas local deployment";
10+
public operationType: OperationType = "delete";
11+
protected argsShape = {
12+
deploymentName: z.string().describe("Name of the deployment to delete"),
13+
};
14+
15+
protected async executeWithAtlasLocalClient(
16+
client: Client,
17+
{ deploymentName }: ToolArgs<typeof this.argsShape>
18+
): Promise<CallToolResult> {
19+
// Delete the deployment
20+
await client.deleteDeployment(deploymentName);
21+
22+
return {
23+
content: [{ type: "text", text: `Deployment "${deploymentName}" deleted successfully.` }],
24+
};
25+
}
26+
}

src/tools/atlasLocal/tools.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DeleteDeploymentTool } from "./delete/deleteDeployment.js";
12
import { ListDeploymentsTool } from "./read/listDeployments.js";
23

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

0 commit comments

Comments
 (0)