Skip to main content
Glama
officialpraise

MongoDB MCP Server

drop-collection

Remove a MongoDB collection or view from a database, including all associated indexes, to clean up unused data structures.

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
databaseYesDatabase name
collectionYesCollection name

Implementation Reference

  • The execute method that performs the drop collection operation using the MongoDB service provider and returns a textual result indicating success or failure.
    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 required 'database' and 'collection' string parameters used by the drop-collection tool via argsShape spread.
    export const DbOperationArgs = { database: z.string().describe("Database name"), collection: z.string().describe("Collection name"), };
  • The MongoDbTools array includes DropCollectionTool (imported at line 17), which is iterated over in src/server.ts to instantiate and register each tool with the MCP server.
    export const MongoDbTools = [ ConnectTool, ListCollectionsTool, ListDatabasesTool, CollectionIndexesTool, CreateIndexTool, CollectionSchemaTool, FindTool, InsertManyTool, DeleteManyTool, CollectionStorageSizeTool, CountTool, DbStatsTool, AggregateTool, UpdateManyTool, RenameCollectionTool, DropDatabaseTool, DropCollectionTool, ExplainTool, CreateCollectionTool, LogsTool, ];
  • Tool metadata: name, description, input argsShape (spreading DbOperationArgs schema), and operation type, defining the tool's interface.
    protected 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, }; protected operationType: OperationType = "delete";

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/officialpraise/mcp'

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