bulk_delete_notes
Remove multiple notes from Flint Note by filtering with criteria like note type, tags, or content patterns. Use this tool to clean up your note vault efficiently.
Instructions
Delete multiple notes matching criteria
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | Filter by note type | |
| tags | No | Filter by tags (all tags must match) | |
| pattern | No | Regex pattern to match note content or title | |
| confirm | No | Explicit confirmation required for bulk deletion |
Implementation Reference
- src/server/note-handlers.ts:393-452 (handler)MCP tool handler for 'bulk_delete_notes'. Validates input, constructs deletion criteria from args, calls noteManager.bulkDeleteNotes, formats and returns results with success/failure summary.handleBulkDeleteNotes = async (args: BulkDeleteNotesArgs) => { // Validate arguments validateToolArgs('bulk_delete_notes', args); this.requireWorkspace(); try { const criteria = { type: args.type, tags: args.tags, pattern: args.pattern }; const results = await this.noteManager.bulkDeleteNotes(criteria, args.confirm); const resultsArray = results as Array<{ deleted: boolean }>; const successCount = resultsArray.filter(r => r.deleted).length; const failureCount = resultsArray.length - successCount; return { content: [ { type: 'text', text: JSON.stringify( { success: true, message: `Bulk delete completed: ${successCount} deleted, ${failureCount} failed`, results, summary: { total: resultsArray.length, successful: successCount, failed: failureCount } }, null, 2 ) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text', text: JSON.stringify( { success: false, error: errorMessage }, null, 2 ) } ], isError: true }; } };
- src/core/notes.ts:894-948 (helper)Core NoteManager.bulkDeleteNotes method implementing the bulk deletion logic: finds matching notes via criteria, enforces config limits and confirmation, deletes each via deleteNote, returns array of DeleteNoteResult.async bulkDeleteNotes( criteria: { type?: string; tags?: string[]; pattern?: string }, confirm: boolean = false ): Promise<DeleteNoteResult[]> { try { const config = this.#workspace.getConfig(); // Find notes matching criteria const matchingNotes = await this.findNotesMatchingCriteria(criteria); if (matchingNotes.length === 0) { return []; } // Check bulk delete limit if (matchingNotes.length > (config?.deletion?.max_bulk_delete || 10)) { throw new Error( `Bulk delete limit exceeded: attempting to delete ${matchingNotes.length} notes, ` + `maximum allowed is ${config?.deletion?.max_bulk_delete || 10}` ); } // Check confirmation requirement if (config?.deletion?.require_confirmation && !confirm) { throw new Error( `Bulk deletion of ${matchingNotes.length} notes requires confirmation. Set confirm=true to proceed.` ); } // Delete each note const results: DeleteNoteResult[] = []; for (const noteIdentifier of matchingNotes) { try { const result = await this.deleteNote(noteIdentifier, true); // Already confirmed at bulk level results.push(result); } catch (error) { // Continue with other deletions, but record the error results.push({ id: noteIdentifier, deleted: false, timestamp: new Date().toISOString(), warnings: [ `Failed to delete: ${error instanceof Error ? error.message : 'Unknown error'}` ] }); } } return results; } catch (error) { throw new Error( `Bulk delete failed: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/server/tool-schemas.ts:768-814 (schema)JSON schema definition for the 'bulk_delete_notes' tool, defining input parameters including type, tags, pattern, confirm, and vault_id.name: 'bulk_delete_notes', description: 'Delete multiple notes based on criteria', inputSchema: { type: 'object', properties: { type: { type: 'string', description: 'Delete all notes of this type' }, older_than_days: { type: 'number', description: 'Delete notes older than this many days' }, metadata_filter: { type: 'object', properties: { key: { type: 'string', description: 'Metadata key to filter on' }, value: { type: 'string', description: 'Value to match' }, operator: { type: 'string', enum: ['=', '!=', '>', '<', '>=', '<=', 'LIKE'], description: 'Comparison operator', default: '=' } }, required: ['key', 'value'] }, confirm: { type: 'boolean', description: 'Confirmation flag to prevent accidental deletion', default: false }, vault_id: { type: 'string', description: 'Optional vault ID to operate on. If not provided, uses the current active vault.' } }, required: ['confirm'] } },
- src/server/types.ts:180-186 (schema)TypeScript interface defining the input arguments for bulk_delete_notes tool.export interface BulkDeleteNotesArgs { type?: string; tags?: string[]; pattern?: string; confirm?: boolean; vault_id?: string; }