delete_item
Remove specified items from Markdown documents using hierarchical paths to manage document structure and content.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- Core implementation of the delete_item tool: deletes file or directory (recursively if dir) within the base path, returns success or error dict.async def delete_item(self, path: str) -> Dict[str, Any]: """Delete file or directory""" try: abs_path = self._get_abs_path(path) if not os.path.exists(abs_path): return {"error": "Item not found"} if os.path.isdir(abs_path): shutil.rmtree(abs_path) else: os.remove(abs_path) return {"success": True, "path": path} except Exception as e: return {"error": str(e)}
- Input/output schema definition for the delete_item tool, registered with MCP server.Tool( name="delete_item", title="Delete File/Folder", inputSchema={ "type": "object", "properties": { "path": { "type": "string", "examples": ["./old_file.md", "./temp_folder"] } }, "required": ["path"], "additionalProperties": False }, outputSchema={ "type": "object", "properties": { "success": {"type": "boolean"}, "path": {"type": "string"} } } )
- src/markdown_editor/server.py:537-539 (registration)Dispatcher in call_tool handler that invokes the delete_item function and formats the MCP response.elif name == "delete_item": res = await delete_item(arguments["path"]) return {"content": [TextContent(type="text", text="Item deleted")], "structuredContent": res, "isError": "error" in res}
- Top-level wrapper function for delete_item that delegates to the singleton FileOperationsTool instance.async def delete_item(path: str): return await _instance.delete_item(path)