-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdropDatabase.ts
26 lines (23 loc) · 998 Bytes
/
dropDatabase.ts
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
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js";
import { ToolArgs, OperationType } from "../../tool.js";
export class DropDatabaseTool extends MongoDBToolBase {
protected name = "drop-database";
protected description = "Removes the specified database, deleting the associated data files";
protected argsShape = {
database: DbOperationArgs.database,
};
protected operationType: OperationType = "delete";
protected async execute({ database }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
const provider = await this.ensureConnected();
const result = await provider.dropDatabase(database);
return {
content: [
{
text: `${result.ok ? "Successfully dropped" : "Failed to drop"} database "${database}"`,
type: "text",
},
],
};
}
}