Skip to main content
Glama

MongoDB MCP Server

Official
by mongodb-js
dropCollection.ts1.53 kB
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js"; import type { ToolArgs, OperationType } from "../../tool.js"; export class DropCollectionTool extends MongoDBToolBase { public name = "drop-collection"; protected description = "Removes a collection or view from the database. The method also removes any indexes associated with the dropped collection."; protected argsShape = { ...DbOperationArgs, }; public operationType: OperationType = "delete"; protected async execute({ database, collection }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> { const provider = await this.ensureConnected(); const result = await provider.dropCollection(database, collection); return { content: [ { text: `${result ? "Successfully dropped" : "Failed to drop"} collection "${collection}" from database "${database}"`, type: "text", }, ], }; } protected getConfirmationMessage({ database, collection }: ToolArgs<typeof this.argsShape>): string { return ( `You are about to drop the \`${collection}\` collection from the \`${database}\` database:\n\n` + "This operation will permanently remove the collection and all its data, including indexes.\n\n" + "**Do you confirm the execution of the action?**" ); } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mongodb-js/mongodb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server