delete_note
Remove unwanted notes permanently from your Flint Note vault to maintain organized, clutter-free documentation. This tool requires explicit confirmation before deletion.
Instructions
Delete an existing note permanently
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| identifier | Yes | Note identifier (type/filename format) | |
| confirm | No | Explicit confirmation required for deletion | |
| vault_id | No | Optional vault ID to operate on. If not provided, uses the current active vault. |
Implementation Reference
- src/server/note-handlers.ts:348-391 (handler)MCP tool handler implementation for 'delete_note'. Validates arguments using validateToolArgs('delete_note', args), resolves vault context, calls noteManager.deleteNote(identifier, confirm), and returns formatted success/error response.handleDeleteNote = async (args: DeleteNoteArgs) => { try { // Validate arguments validateToolArgs('delete_note', args); const { noteManager } = await this.resolveVaultContext(args.vault_id); const result = await noteManager.deleteNote(args.identifier, args.confirm); return { content: [ { type: 'text', text: JSON.stringify( { success: true, message: `Note '${args.identifier}' deleted successfully`, result }, 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/server/tool-schemas.ts:710-731 (schema)Input schema definition for the 'delete_note' tool, specifying parameters: identifier (required string), confirm (boolean, default false), vault_id (optional string).name: 'delete_note', description: 'Delete a specific note', inputSchema: { type: 'object', properties: { identifier: { type: 'string', description: 'Note identifier in type/filename format' }, 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: ['identifier', 'confirm'] }
- src/server.ts:1306-1308 (registration)Registration of 'delete_note' tool in MCP CallToolRequestSchema handler, dispatching to noteHandlers.handleDeleteNotereturn await this.noteHandlers.handleDeleteNote( args as unknown as DeleteNoteArgs );
- src/core/notes.ts:724-773 (helper)Core NoteManager.deleteNote method implementing the file deletion logic: validates deletion safety, checks config/confirmation, creates backup if enabled, removes from search index, unlinks the file, returns DeleteNoteResult.async deleteNote( identifier: string, confirm: boolean = false ): Promise<DeleteNoteResult> { try { const config = this.#workspace.getConfig(); // Validate deletion const validation = await this.validateNoteDeletion(identifier); if (!validation.can_delete) { throw new Error(`Cannot delete note: ${validation.errors.join(', ')}`); } // Check confirmation requirement if (config?.deletion?.require_confirmation && !confirm) { throw new Error(`Deletion requires confirmation. Set confirm=true to proceed.`); } const { typeName: _typeName, filename: _filename, notePath } = this.parseNoteIdentifier(identifier); let backupPath: string | undefined; // Create backup if enabled if (config?.deletion?.create_backups) { const backup = await this.createNoteBackup(notePath); backupPath = backup.path; } // Remove from search index first await this.removeFromSearchIndex(notePath); // Delete the file await fs.unlink(notePath); return { id: identifier, deleted: true, timestamp: new Date().toISOString(), backup_path: backupPath, warnings: validation.warnings }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new Error(`Failed to delete note '${identifier}': ${errorMessage}`); } }
- src/server/types.ts:166-170 (schema)TypeScript interface DeleteNoteArgs defining the input parameters for the delete_note tool.export interface DeleteNoteArgs { identifier: string; confirm?: boolean; vault_id?: string; }