Skip to main content
Glama

mongodb_delete_collection

Delete a MongoDB collection from a specified database to remove unwanted data or clean up storage space.

Instructions

Удаляет коллекцию из базы данных

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNameYesИмя базы данных
collectionNameYesИмя коллекции для удаления

Implementation Reference

  • TypeScript handler function that connects to MongoDB, drops the specified collection, and returns a success or error message.
    private async mongodbDeleteCollection( databaseName: string, collectionName: string ) { const client = await this.getMongoClient(); try { const db = client.db(databaseName); await db.collection(collectionName).drop(); return { content: [ { type: "text", text: `Коллекция "${collectionName}" успешно удалена из базы данных "${databaseName}"`, }, ], }; } catch (error) { throw new Error( `Ошибка удаления коллекции: ${error instanceof Error ? error.message : String(error)}` ); } finally { await client.close(); } }
  • Python handler function that connects to MongoDB using PyMongo, drops the specified collection, and returns a success or error message.
    def mongodb_delete_collection(database_name: str, collection_name: str) -> str: """Deletes collection""" client = MongoClient(MONGODB_URI) try: db = client[database_name] db[collection_name].drop() return ( f'Collection "{collection_name}" successfully deleted ' f'from database "{database_name}"' ) except Exception as e: raise Exception(f"Error deleting collection: {str(e)}") finally: client.close()
  • Input schema definition for the mongodb_delete_collection tool in the TypeScript MCP server.
    name: "mongodb_delete_collection", description: "Удаляет коллекцию из базы данных", inputSchema: { type: "object", properties: { databaseName: { type: "string", description: "Имя базы данных", }, collectionName: { type: "string", description: "Имя коллекции для удаления", }, }, required: ["databaseName", "collectionName"], },
  • Input schema definition for the mongodb_delete_collection tool in the Python MCP server.
    "name": "mongodb_delete_collection", "description": "Deletes collection from database", "inputSchema": { "type": "object", "properties": { "databaseName": { "type": "string", "description": "Database name", }, "collectionName": { "type": "string", "description": "Collection name to delete", }, }, "required": ["databaseName", "collectionName"], },
  • src/index.ts:353-357 (registration)
    Dispatch/registration case in the TypeScript tools/call handler that invokes the mongodbDeleteCollection method.
    case "mongodb_delete_collection": return await this.mongodbDeleteCollection( args?.databaseName as string, args?.collectionName as string );

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/TrueOleg/MCP-expirements'

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