delete_collection
Remove a specific collection from the Qdrant vector database to manage storage and optimize semantic search operations effectively.
Instructions
Delete a Qdrant collection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | Name of the collection to delete |
Implementation Reference
- src/index.ts:382-407 (handler)The primary handler for the 'delete_collection' tool. It invokes the Qdrant service to delete the specified collection and returns a formatted success or error response.private async handleDeleteCollection(args: DeleteCollectionArgs) { try { // Delete the collection await this.qdrantService.deleteCollection(args.collection); return { content: [ { type: 'text', text: `Successfully deleted collection: ${args.collection}`, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text', text: `Error deleting collection: ${errorMessage}`, }, ], isError: true, }; } }
- src/index.ts:35-37 (schema)TypeScript interface defining the input arguments for the delete_collection tool.interface DeleteCollectionArgs { collection: string; }
- src/index.ts:175-188 (registration)Tool registration in the MCP server's list of tools, including name, description, and JSON input schema.{ name: 'delete_collection', description: 'Delete a Qdrant collection', inputSchema: { type: 'object', properties: { collection: { type: 'string', description: 'Name of the collection to delete', }, }, required: ['collection'], }, },
- src/index.ts:99-103 (schema)Runtime type guard/validator for DeleteCollectionArgs input parameters.private isDeleteCollectionArgs(args: unknown): args is DeleteCollectionArgs { if (!args || typeof args !== 'object') return false; const a = args as Record<string, unknown>; return typeof a.collection === 'string'; }
- src/services/qdrant.ts:140-172 (helper)Core implementation in QdrantService that performs the HTTP DELETE request to remove the specified collection from the Qdrant server.async deleteCollection(name: string): Promise<void> { try { console.log('Attempting to delete Qdrant collection using direct fetch...'); // Use direct fetch instead of the client const deleteUrl = `${this.url}/collections/${name}`; console.log(`Fetching from: ${deleteUrl}`); const response = await fetch(deleteUrl, { method: 'DELETE', headers: { 'Content-Type': 'application/json', ...(this.apiKey ? { 'api-key': this.apiKey } : {}) }, // @ts-ignore - node-fetch supports timeout timeout: 5000 // 5 second timeout }); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } const data = await response.json(); console.log('Successfully deleted collection:', data); } catch (error) { console.error('Error in deleteCollection:', error); if (error instanceof Error) { console.error(`${error.name}: ${error.message}`); console.error('Stack:', error.stack); } throw error; } }