Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYesPath 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'],
      },
    },
  • 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}`,
          },
        ],
      };
    }
  • 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);
  • Input schema definition requiring a 'path' parameter.
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'Path to the note within the vault',
        },
      },
      required: ['path'],
    },

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