delete_note_type
Remove a specific note type in Flint Note's system, specifying actions for existing notes: prevent deletion, migrate to another type, or delete entirely. Requires confirmation for execution.
Instructions
Delete a note type and optionally handle existing notes
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to take with existing notes: error (prevent deletion), migrate (move to target type), delete (remove all notes) | |
| confirm | No | Explicit confirmation required for deletion | |
| target_type | No | Target note type for migration (required when action is migrate) | |
| type_name | Yes | Name of the note type to delete |
Input Schema (JSON Schema)
{
"properties": {
"action": {
"description": "Action to take with existing notes: error (prevent deletion), migrate (move to target type), delete (remove all notes)",
"enum": [
"error",
"migrate",
"delete"
],
"type": "string"
},
"confirm": {
"default": false,
"description": "Explicit confirmation required for deletion",
"type": "boolean"
},
"target_type": {
"description": "Target note type for migration (required when action is migrate)",
"type": "string"
},
"type_name": {
"description": "Name of the note type to delete",
"type": "string"
}
},
"required": [
"type_name",
"action"
],
"type": "object"
}
Implementation Reference
- src/server/note-type-handlers.ts:373-422 (handler)The main MCP tool handler function that validates input for 'delete_note_type' and calls the core NoteTypeManager.deleteNoteType method.handleDeleteNoteType = async (args: DeleteNoteTypeArgs) => { // Validate arguments validateToolArgs('delete_note_type', args); this.requireWorkspace(); try { const result = await this.noteTypeManager.deleteNoteType( args.type_name, args.action, args.target_type, args.confirm ); return { content: [ { type: 'text', text: JSON.stringify( { success: true, message: `Note type '${args.type_name}' 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/core/note-types.ts:449-536 (helper)Core business logic for deleting a note type, handling different actions (error, migrate, delete), backups, and filesystem operations.async deleteNoteType( typeName: string, action: DeletionAction = 'error', targetType?: string, confirm: boolean = false ): Promise<NoteTypeDeleteResult> { try { const config = this.workspace.getConfig(); // Check if note type deletion is allowed if (!config?.deletion?.allow_note_type_deletion) { throw new Error('Note type deletion is disabled in configuration'); } // Validate deletion const validation = await this.validateNoteTypeDeletion( typeName, action, targetType ); if (!validation.can_delete) { throw new Error(`Cannot delete note type: ${validation.errors.join(', ')}`); } // Check confirmation requirement if (config?.deletion?.require_confirmation && !confirm) { throw new Error( `Note type deletion requires confirmation. Set confirm=true to proceed.` ); } const typePath = this.workspace.getNoteTypePath(typeName); const notes = await this.getNotesInType(typeName); let backupPath: string | undefined; // Create backup if enabled if (config?.deletion?.create_backups && notes.length > 0) { const backup = await this.createNoteTypeBackup(typeName, notes); backupPath = backup.path; } // Execute the deletion action let migrationTarget: string | undefined; switch (action) { case 'error': if (notes.length > 0) { throw new Error( `Cannot delete note type '${typeName}': contains ${notes.length} notes` ); } break; case 'migrate': if (!targetType) { throw new Error('Migration target type is required for migrate action'); } migrationTarget = targetType; await this.migrateNotesToType(notes, targetType); break; case 'delete': // Check bulk delete limit if (notes.length > (config?.deletion?.max_bulk_delete || 10)) { throw new Error( `Cannot delete ${notes.length} notes: exceeds bulk delete limit of ${config?.deletion?.max_bulk_delete || 10}` ); } await this.deleteNotesInType(notes); break; } // Remove the directory and all its contents await fs.rm(typePath, { recursive: true, force: true }); return { name: typeName, deleted: true, timestamp: new Date().toISOString(), action, notes_affected: notes.length, backup_path: backupPath, migration_target: migrationTarget }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new Error(`Failed to delete note type '${typeName}': ${errorMessage}`); } }
- src/server.ts:1310-1312 (registration)Registration and dispatch of the 'delete_note_type' tool in the MCP server's CallToolRequestSchema handler.return await this.noteTypeHandlers.handleDeleteNoteType( args as unknown as DeleteNoteTypeArgs );
- src/server.ts:1055-1083 (schema)Tool schema definition provided in ListToolsRequestSchema response, defining input schema for 'delete_note_type'.name: 'delete_note_type', description: 'Delete a note type and optionally handle existing notes', inputSchema: { type: 'object', properties: { type_name: { type: 'string', description: 'Name of the note type to delete' }, action: { type: 'string', enum: ['error', 'migrate', 'delete'], description: 'Action to take with existing notes: error (prevent deletion), migrate (move to target type), delete (remove all notes)' }, target_type: { type: 'string', description: 'Target note type for migration (required when action is migrate)' }, confirm: { type: 'boolean', description: 'Explicit confirmation required for deletion', default: false } }, required: ['type_name', 'action'] } },
- src/server/types.ts:172-178 (schema)TypeScript interface defining the input arguments for the delete_note_type tool.export interface DeleteNoteTypeArgs { type_name: string; action: 'error' | 'migrate' | 'delete'; target_type?: string; confirm?: boolean; vault_id?: string; }