mongodb_delete_collection
Delete a MongoDB collection from a specified database using the MCP Mac Apps Server. Remove unwanted data collections to manage storage and organize your database structure.
Instructions
Удаляет коллекцию из базы данных
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| databaseName | Yes | Имя базы данных | |
| collectionName | Yes | Имя коллекции для удаления |
Implementation Reference
- src/index.ts:724-747 (handler)The main handler function that executes the deletion of a MongoDB collection using the MongoClient.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(); } }
- src/index.ts:211-228 (schema)Input schema definition for the mongodb_delete_collection tool in the list of tools.{ name: "mongodb_delete_collection", description: "Удаляет коллекцию из базы данных", inputSchema: { type: "object", properties: { databaseName: { type: "string", description: "Имя базы данных", }, collectionName: { type: "string", description: "Имя коллекции для удаления", }, }, required: ["databaseName", "collectionName"], }, },
- src/index.ts:353-357 (registration)Registration of the tool handler in the CallToolRequest switch statement.case "mongodb_delete_collection": return await this.mongodbDeleteCollection( args?.databaseName as string, args?.collectionName as string );
- src/server.py:483-496 (handler)Python handler function for deleting a MongoDB collection (note: registration is commented out).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()
- src/server.py:198-215 (schema)Input schema definition for the mongodb_delete_collection tool in Python version.{ "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"], }, },