Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

drop-collection

Remove a MongoDB collection or view and its associated indexes from a specified database using the MCP Server, streamlining database management tasks.

Instructions

Removes a collection or view from the database. The method also removes any indexes associated with the dropped collection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
databaseYesDatabase name

Implementation Reference

  • The main handler function that executes the drop-collection tool by calling the provider's dropCollection method and returning a success or failure message.
    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", }, ], }; }
  • Zod schema defining the input arguments (database and collection) used by the drop-collection tool and other MongoDB operation tools.
    export const DbOperationArgs = { database: z.string().describe("Database name"), collection: z.string().describe("Collection name"), };
  • Tool-specific input schema definition, which inherits from the shared DbOperationArgs.
    protected argsShape = { ...DbOperationArgs, };
  • Registration of the DropCollectionTool by exporting it from the MongoDB tools module.
    export { DropCollectionTool } from "./delete/dropCollection.js";
  • Includes the MongoDB tools module (containing drop-collection) in the central AllTools array for server registration.
    export const AllTools: ToolClass[] = Object.values({ ...MongoDbTools, ...AtlasTools, ...AtlasLocalTools, });

Latest Blog Posts

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