Skip to main content
Glama

zk_delete_note

Remove specific notes from the Zettelkasten knowledge management system using the note ID, ensuring efficient organization and maintenance of atomic notes.

Instructions

Delete a note. Args: note_id: The ID of the note to delete

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
note_idYes

Implementation Reference

  • MCP tool handler implementing zk_delete_note: validates note existence and delegates deletion to ZettelService.
    def zk_delete_note(note_id: str) -> str:
        """Permanently delete a note and all its associated links from the Zettelkasten.
    
        Args:
            note_id: The unique ID of the note to permanently delete
        """
        try:
            # Check if note exists
            note = self.zettel_service.get_note(note_id)
            if not note:
                return f"Note not found: {note_id}"
    
            # Delete the note
            self.zettel_service.delete_note(str(note_id))
            return f"Note deleted successfully: {note_id}"
        except Exception as e:
            return self.format_error_response(e)
  • Registration of the zk_delete_note tool in the MCP server.
        name="zk_delete_note",
        description="Permanently delete a note and all its associated links from the Zettelkasten.",
        annotations={
            "readOnlyHint": False,
            "destructiveHint": True,
            "idempotentHint": True,
        },
    )
  • ZettelService.delete_note delegates deletion to NoteRepository.
    def delete_note(self, note_id: str) -> None:
        """Delete a note."""
        self.repository.delete(note_id)
  • Core deletion logic in NoteRepository: removes MD file and purges DB records for links, tags, and note.
    def delete(self, id: str) -> None:
        """Delete a note by ID."""
        # Check if note exists
        file_path = self.notes_dir / f"{id}.md"
        if not file_path.exists():
            raise ValueError(f"Note with ID {id} does not exist")
        
        # Delete from file system
        try:
            with self.file_lock:
                os.remove(file_path)
        except IOError as e:
            raise IOError(f"Failed to delete note {id}: {e}")
        
        # Delete from database
        with self.session_factory() as session:
            # Delete note and its relationships
            session.execute(text(f"DELETE FROM links WHERE source_id = '{id}' OR target_id = '{id}'"))
            session.execute(text(f"DELETE FROM note_tags WHERE note_id = '{id}'"))
            session.execute(text(f"DELETE FROM notes WHERE id = '{id}'"))
            session.commit()

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/Liam-Deacon/zettelkasten-mcp'

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