Skip to main content
Glama
wrediam

Better Qdrant MCP Server

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
NameRequiredDescriptionDefault
collectionYesName of the collection to delete

Implementation Reference

  • 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,
        };
      }
    }
  • 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'],
      },
    },
  • 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';
    }
  • 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;
      }
    }
Install Server

Other Tools

Related Tools

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/wrediam/better-qdrant-mcp-server'

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