delete_element
Remove specific blocks from Markdown documents using hierarchical paths to delete elements like sections, paragraphs, or lists without manual text editing.
Instructions
Removes a block from the document.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| path | Yes |
Implementation Reference
- The async handler function for the 'delete_element' tool that delegates execution to the EditTool instance's delete method.async def delete_element(file_path: str, path: str): return await _instance.delete(file_path, path)
- Core logic in EditTool class for deleting an element by path, updating the document, and persisting changes to file.async def delete(self, file_path: str, path: str) -> Dict[str, Any]: doc = self.get_doc(file_path) result = doc.delete(path) if "success" in result: with open(file_path, 'w', encoding='utf-8') as f: f.write(doc.get_content()) return result
- src/markdown_editor/server.py:315-340 (registration)Registration of the 'delete_element' tool in the list_tools() handler, including metadata, input schema, and output schema.Tool( name="delete_element", title="Delete Block", description="Removes a block from the document.", inputSchema={ "type": "object", "properties": { "file_path": { "type": "string", "examples": ["./document.md"] }, "path": { "type": "string", "examples": ["Introduction > paragraph 3", "Old Section", "Deprecated > list 1"] } }, "required": ["file_path", "path"], "additionalProperties": False }, outputSchema={ "type": "object", "properties": { "success": {"type": "boolean"} } } ),
- src/markdown_editor/server.py:574-576 (registration)Dispatch logic in call_tool() that invokes the delete_element handler when the tool is called.elif name == "delete_element": res = await delete_element(file_path, arguments["path"]) return {"content": [TextContent(type="text", text="Element deleted")], "structuredContent": res, "isError": "error" in res}