Skip to main content
Glama
officialpraise

MongoDB MCP Server

drop-collection

Remove a MongoDB collection or view and its associated indexes from a specified database using MongoDB MCP Server.

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 core handler function that connects to MongoDB if needed, drops the specified collection, and returns 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", }, ], }; }
  • Tool input schema definition, inheriting database and collection arguments from base DbOperationArgs.
    protected argsShape = { ...DbOperationArgs, };
  • Zod schema defining required database and collection string arguments for DB operation tools.
    export const DbOperationArgs = { database: z.string().describe("Database name"), collection: z.string().describe("Collection name"), };
  • Array of all MongoDB tools including DropCollectionTool, exported for higher-level registration.
    export const MongoDbTools = [ ConnectTool, ListCollectionsTool, ListDatabasesTool, CollectionIndexesTool, CreateIndexTool, CollectionSchemaTool, FindTool, InsertManyTool, DeleteManyTool, CollectionStorageSizeTool, CountTool, DbStatsTool, AggregateTool, UpdateManyTool, RenameCollectionTool, DropDatabaseTool, DropCollectionTool, ExplainTool, CreateCollectionTool, LogsTool, ];
  • src/server.ts:142-144 (registration)
    Registers all tools from MongoDbTools (and AtlasTools) by instantiating each and calling their register method on the MCP server.
    for (const tool of [...AtlasTools, ...MongoDbTools]) { new tool(this.session, this.userConfig, this.telemetry).register(this.mcpServer); }

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