Skip to main content
Glama
cjkcr

X(Twitter) MCP Server

by cjkcr

delete_draft

Remove unwanted draft tweets or threads from your X/Twitter account by specifying the draft ID to free up space and maintain organized draft management.

Instructions

Delete a draft tweet or thread

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
draft_idYesID of the draft to delete

Implementation Reference

  • The main handler function that executes the delete_draft tool: validates input, constructs draft file path, checks existence, removes the file, logs the action, and returns a success message.
    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)}")
  • Registration of the 'delete_draft' tool in the MCP server's list_tools() method, 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"], }, ),
  • Input schema for the delete_draft tool, defining a required 'draft_id' string parameter.
    inputSchema={ "type": "object", "properties": { "draft_id": { "type": "string", "description": "ID of the draft to delete", }, }, "required": ["draft_id"], },
  • Dispatch in the main call_tool handler that routes 'delete_draft' calls to the specific handle_delete_draft function.
    elif name == "delete_draft": return await handle_delete_draft(arguments)
  • Supporting helper function to conditionally delete drafts on publishing failures based on AUTO_DELETE_FAILED_DRAFTS configuration.
    def delete_draft_on_failure(draft_id: str, filepath: str) -> None: """Delete draft file if auto-delete is enabled""" if AUTO_DELETE_FAILED_DRAFTS: try: os.remove(filepath) logger.info(f"Deleted draft {draft_id} due to publishing failure (auto-delete enabled)") except Exception as delete_error: logger.error(f"Failed to delete draft {draft_id} after publishing error: {delete_error}") else: logger.info(f"Draft {draft_id} preserved for retry (auto-delete disabled)")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cjkcr/x-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server