delete_draft
Remove unwanted draft tweets or threads from your X/Twitter account to keep your drafts organized and prevent accidental posting.
Instructions
Delete a draft tweet or thread
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| draft_id | Yes | ID of the draft to delete |
Implementation Reference
- src/x_mcp/server.py:256-278 (handler)The main handler function for the delete_draft tool. Validates the input arguments, constructs the file path for the draft, checks if the draft file exists, deletes it using os.remove, logs the action, and returns a success message or raises an error.async def handle_delete_draft(arguments: Any) -> Sequence[TextContent]: if not isinstance(arguments, dict) or "draft_id" not in arguments: raise ValueError("Invalid arguments for delete_draft") draft_id = arguments["draft_id"] filepath = os.path.join("drafts", draft_id) try: if not os.path.exists(filepath): raise ValueError(f"Draft {draft_id} does not exist") os.remove(filepath) logger.info(f"Deleted draft: {draft_id}") return [ TextContent( type="text", text=f"Successfully deleted draft {draft_id}", ) ] except Exception as e: logger.error(f"Error deleting draft {draft_id}: {str(e)}") raise RuntimeError(f"Error deleting draft {draft_id}: {str(e)}")
- src/x_mcp/server.py:104-113 (schema)Input schema definition for the delete_draft tool, specifying an object with a required 'draft_id' property of type string.inputSchema={ "type": "object", "properties": { "draft_id": { "type": "string", "description": "ID of the draft to delete", }, }, "required": ["draft_id"], },
- src/x_mcp/server.py:101-114 (registration)Registration of the delete_draft tool in the list_tools() function, including name, description, and input schema.Tool( name="delete_draft", description="Delete a draft tweet or thread", inputSchema={ "type": "object", "properties": { "draft_id": { "type": "string", "description": "ID of the draft to delete", }, }, "required": ["draft_id"], }, ),
- src/x_mcp/server.py:128-129 (registration)Dispatch logic in the call_tool() function that routes calls to 'delete_draft' to the handle_delete_draft handler.elif name == "delete_draft": return await handle_delete_draft(arguments)