delete_note
Remove notes from your Obsidian vault to declutter your knowledge base and maintain organized documentation.
Instructions
Delete a note from the Obsidian vault
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the note within the vault |
Implementation Reference
- src/index.ts:1118-1130 (registration)Tool registration in the ListToolsRequestSchema handler, including name, description, and input schema.name: 'delete_note', description: 'Delete a note from the Obsidian vault', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the note within the vault', }, }, required: ['path'], }, },
- src/index.ts:1494-1509 (handler)MCP tool handler that validates input and calls the deleteNote implementation.private async handleDeleteNote(args: any) { if (!args?.path) { throw new Error('Path is required'); } await this.deleteNote(args.path); return { content: [ { type: 'text', text: `Note deleted successfully: ${args.path}`, }, ], }; }
- src/index.ts:2322-2347 (handler)Core implementation that deletes the note file using Obsidian REST API or direct filesystem unlink with directory cleanup.private async deleteNote(notePath: string): Promise<void> { try { // First try using the Obsidian API await this.api.delete(`/vault/${encodeURIComponent(notePath)}`); } catch (error) { console.warn('API request failed, falling back to file system:', error); // Fallback to file system if API fails const fullPath = path.join(VAULT_PATH, notePath); if (!fs.existsSync(fullPath)) { throw new Error(`Note not found: ${notePath}`); } fs.unlinkSync(fullPath); // Check if parent directory is empty and remove it if it is const dir = path.dirname(fullPath); if (dir !== VAULT_PATH) { const items = fs.readdirSync(dir); if (items.length === 0) { fs.rmdirSync(dir); } } } }
- src/index.ts:1396-1397 (registration)Dispatch registration in the CallToolRequestSchema switch statement.case 'delete_note': return await this.handleDeleteNote(request.params.arguments);
- src/index.ts:1121-1129 (schema)Input schema definition requiring a 'path' parameter.type: 'object', properties: { path: { type: 'string', description: 'Path to the note within the vault', }, }, required: ['path'], },