drop-database
Deletes a specified MongoDB database along with its associated data files. Use this tool to remove unwanted databases from your MongoDB Atlas environment efficiently.
Instructions
Removes the specified database, deleting the associated data files
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | Database name |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"database": {
"description": "Database name",
"type": "string"
}
},
"required": [
"database"
],
"type": "object"
}
Implementation Reference
- The DropDatabaseTool class defines the "drop-database" tool, including its name, description, input schema (argsShape), and the execute method that connects to MongoDB and drops the specified database, returning success or failure message. Also includes a confirmation message.export class DropDatabaseTool extends MongoDBToolBase { public name = "drop-database"; protected description = "Removes the specified database, deleting the associated data files"; protected argsShape = { database: DbOperationArgs.database, }; static 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", }, ], }; } protected getConfirmationMessage({ database }: ToolArgs<typeof this.argsShape>): string { return ( `You are about to drop the \`${database}\` database:\n\n` + "This operation will permanently remove the database and ALL its collections, documents, and indexes.\n\n" + "**Do you confirm the execution of the action?**" ); } }
- Defines the Zod schema for database and collection arguments used by the drop-database tool (via DbOperationArgs.database).export const DbOperationArgs = { database: z.string().describe("Database name"), collection: z.string().describe("Collection name"), };
- src/tools/mongodb/tools.ts:16-16 (registration)Exports DropDatabaseTool from its implementation file, making it available as part of the MongoDB tools module.export { DropDatabaseTool } from "./delete/dropDatabase.js";
- src/tools/index.ts:7-11 (registration)Collects all tools including MongoDB tools (which include drop-database via export) into AllTools array, used for registering tools with the MCP server.export const AllTools: ToolClass[] = Object.values({ ...MongoDbTools, ...AtlasTools, ...AtlasLocalTools, });
- Lists "drop-database" in the default confirmationRequiredTools array, requiring user confirmation before execution for safety."drop-database", "drop-collection", "delete-many", "drop-index", ])