delete_note
Remove a note from your knowledge base by specifying its category path and title to maintain organized information.
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 tool handler that extracts arguments and delegates to storage.delete_note, returning 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)Tool registration 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"], }, ),
- Core storage method that locates the note file, creates a backup, deletes the file, and returns confirmation 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'}/"