bulk_delete_notes
Remove multiple notes from Flint Note that match specified filters such as type, tags, or content pattern, with optional confirmation for bulk deletion.
Instructions
Delete multiple notes matching criteria
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| confirm | No | Explicit confirmation required for bulk deletion | |
| pattern | No | Regex pattern to match note content or title | |
| tags | No | Filter by tags (all tags must match) | |
| type | No | Filter by note type |
Input Schema (JSON Schema)
{
"properties": {
"confirm": {
"default": false,
"description": "Explicit confirmation required for bulk deletion",
"type": "boolean"
},
"pattern": {
"description": "Regex pattern to match note content or title",
"type": "string"
},
"tags": {
"description": "Filter by tags (all tags must match)",
"items": {
"type": "string"
},
"type": "array"
},
"type": {
"description": "Filter by note type",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/server/note-handlers.ts:393-452 (handler)MCP tool handler for bulk_delete_notes. Validates args, constructs criteria, calls noteManager.bulkDeleteNotes, and formats response with success/failure counts.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 implementation in NoteManager that finds notes matching criteria (type/tags/pattern), checks limits/confirmation, and deletes each note individually.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 (registration)MCP tool registration with name, description, and input schema definition.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 the bulk_delete_notes tool.export interface BulkDeleteNotesArgs { type?: string; tags?: string[]; pattern?: string; confirm?: boolean; vault_id?: string; }
- src/server/validation.ts:1190-1200 (helper)Validation function ensuring at least one deletion criteria (type/tags/pattern) is provided.function validateBulkDeleteNotesArgs(args: any): void { const hasType = args.type && typeof args.type === 'string'; const hasTags = args.tags && Array.isArray(args.tags) && args.tags.length > 0; const hasPattern = args.pattern && typeof args.pattern === 'string'; if (!hasType && !hasTags && !hasPattern) { throw createValidationError('bulk_delete_notes', [ 'At least one filter must be provided: type, tags, or pattern' ]); } }