delete_note
Remove a note from your knowledge base by specifying its category path and title. This action permanently deletes the selected note.
Instructions
Delete a note from the knowledge base
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category_path | Yes | Category path (e.g., 'work/clients/acme') | |
| title | Yes | Note title |
Implementation Reference
- src/knowledge_base_mcp/server.py:581-594 (handler)MCP handler function for delete_note tool. Extracts category_path and title from arguments, calls storage.delete_note, and returns success or error message.async def handle_delete_note(arguments: dict) -> list[TextContent]: """Handle delete_note tool call.""" try: category_path = arguments["category_path"] title = arguments["title"] # Delete note result = storage.delete_note(category_path, title) return [TextContent(type="text", text=result)] except (NoteNotFoundError, StorageError) as e: return [TextContent(type="text", text=str(e))] except Exception as e: return [TextContent(type="text", text=f"❌ Error: {str(e)}")]
- src/knowledge_base_mcp/server.py:263-280 (registration)Registration of the delete_note tool in list_tools(), including name, description, and input schema.Tool( name="delete_note", description="Delete a note from the knowledge base", inputSchema={ "type": "object", "properties": { "category_path": { "type": "string", "description": "Category path (e.g., 'work/clients/acme')", }, "title": { "type": "string", "description": "Note title", }, }, "required": ["category_path", "title"], }, ),
- Input schema definition for the delete_note tool, specifying required category_path and title parameters.inputSchema={ "type": "object", "properties": { "category_path": { "type": "string", "description": "Category path (e.g., 'work/clients/acme')", }, "title": { "type": "string", "description": "Note title", }, }, "required": ["category_path", "title"], },
- Core storage helper method that performs the actual file deletion: computes file path, creates backup, deletes the .md file, and returns success message.def delete_note(self, category_path: str, title: str) -> str: """ Delete a note. Args: category_path: Category path (e.g., "work/clients/acme") title: Note title Returns: Success message Raises: NoteNotFoundError: If note doesn't exist """ normalized = normalize_path(category_path) file_path = self._get_note_path(normalized, title) if not file_path.exists(): raise NoteNotFoundError( f"❌ Error: Note '{title}' not found in {normalized or 'root'}/\n" f"💡 Tip: Use list_notes to see available notes" ) # Create backup before deletion backup_path = file_path.with_suffix('.md.deleted') shutil.copy2(file_path, backup_path) # Delete the file file_path.unlink() return f"✓ Note '{title}' deleted from {normalized or 'root'}/"