delete_docx
Remove Word documents from your system by specifying the file path and confirming deletion for safety.
Instructions
Delete a Word document.
Args: filepath: Path to the document to delete confirm: Must be True to actually delete (safety check)
Returns: Dictionary with status
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes | ||
| confirm | No |
Implementation Reference
- src/docx_mcp/server.py:258-294 (handler)The implementation of the `delete_docx` tool which deletes a Word document after confirmation.
@app.tool() def delete_docx(filepath: str, confirm: bool = False) -> dict[str, Any]: """ Delete a Word document. Args: filepath: Path to the document to delete confirm: Must be True to actually delete (safety check) Returns: Dictionary with status """ logger.info("Deleting document", extra={"tool": "delete_docx", "filepath": filepath}) try: if not confirm: return { "status": "warning", "message": "Deletion requires confirm=True", } path = validate_docx_file(filepath) path.unlink() logger.info("Document deleted successfully", extra={"filepath": filepath}) return { "status": "success", "message": f"Document deleted: {path.name}", } except DocxMcpError as e: logger.warning(e.message, extra={"tool": "delete_docx", "error_code": e.error_code}) return {"status": "error", "error": e.message, "error_code": e.error_code} except Exception as e: logger.error(f"Unexpected error deleting document: {str(e)}") return {"status": "error", "error": str(e)}