Skip to main content
Glama
vidhupv

X(Twitter) MCP Server

by vidhupv

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
NameRequiredDescriptionDefault
draft_idYesID of the draft to delete

Implementation Reference

  • 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)}")
  • 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"],
    },
  • 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"],
        },
    ),
  • 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)

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/vidhupv/x-mcp'

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