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
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Project path to clear vectors from (defaults to current directory) |
Implementation Reference
- src/handlers/vector.ts:151-163 (handler)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)}`); } }
- src/vector/db.ts:76-88 (helper)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)}`); } }
- src/handlers/vector.ts:27-30 (schema)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 } ] }; });