Skip to main content
Glama

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
NameRequiredDescriptionDefault
databaseNameYesИмя базы данных
collectionNameYesИмя коллекции для удаления

Implementation Reference

  • 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(); } }
  • 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 );
  • 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()
  • 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"], }, },

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