Skip to main content
Glama

delete_note

Remove a note from the Obsidian vault by specifying its path, enabling direct management of notes through the MCP server for efficient knowledge base organization.

Instructions

Delete a note from the Obsidian vault

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the note within the vault

Implementation Reference

  • src/index.ts:1117-1130 (registration)
    Registration of the 'delete_note' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.
    { 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'], }, },
  • The main handler function for the 'delete_note' tool that validates the input arguments and delegates to the deleteNote method.
    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}`, }, ], }; }
  • Core implementation of note deletion using Obsidian API with filesystem fallback, including cleanup of empty parent directories.
    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); } } } }
  • Input schema definition for the 'delete_note' tool specifying the required 'path' parameter.
    type: 'object', properties: { path: { type: 'string', description: 'Path to the note within the vault', }, }, required: ['path'], },

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/newtype-01/obsidian-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server