Skip to main content
Glama

clear-vectors

Remove all indexed vectors from a project to reset vector storage and manage memory usage.

Instructions

Clear all indexed vectors for a project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoProject path to clear vectors from (defaults to current directory)

Implementation Reference

  • The handler function that implements the core logic of the 'clear-vectors' tool by clearing the vector database for the specified project path.
    export async function handleClearVectors(args: ClearVectorsInput): Promise<string> {
      logger.log('Clearing vector database...');
    
      try {
        const countBefore = await getVectorCount(args.path);
        await clearVectorDB(args.path);
        
        return `Vector database cleared. Removed ${countBefore} vectors.`;
      } catch (error) {
        logger.error('Failed to clear vectors:', error);
        throw new Error(`Clear failed: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Core utility function that performs the actual deletion of all vector chunks from the SQLite database.
    export async function clearVectorDB(projectPath: string): Promise<void> {
      const { client } = await getVectorDB(projectPath);
      
      try {
        await client.execute({
          sql: 'DELETE FROM vector_chunks',
          args: []
        });
        logger.log('Vector database cleared');
      } catch (error) {
        throw new Error(`Failed to clear vector database: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Zod schema defining the input parameters for the 'clear-vectors' tool (optional path to project).
    // Input schema for clear-vectors tool
    export const ClearVectorsSchema = z.object({
      path: z.string().default(process.cwd()),
    });
  • src/server.ts:491-508 (registration)
    Registers the 'clear-vectors' tool with MCP server, specifying title, description, input schema, and linking to the handler implementation.
    server.registerTool("clear-vectors", {
      title: "Clear Vectors",
      description: "Clear all indexed vectors for a project",
      inputSchema: ClearVectorsSchema.shape,
    }, async (args) => {
      const { handleClearVectors } = await import("./handlers/vector");
      const result = await handleClearVectors({
        path: args.path || process.cwd(),
      });
      return {
        content: [
          {
            type: "text",
            text: result
          }
        ]
      };
    });

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/RealMikeChong/ultra-mcp'

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