list_drafts
Retrieve and view all saved draft tweets and threads stored in the X(Twitter) MCP Server for review and management before publishing.
Instructions
List all draft tweets and threads
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/x_mcp/server.py:640-657 (handler)The handler function for the 'list_drafts' tool. It lists all JSON files in the 'drafts' directory, loads their contents, and returns a JSON-formatted list of draft objects including ID and content.async def handle_list_drafts(arguments: Any) -> Sequence[TextContent]: try: drafts = [] if os.path.exists("drafts"): for filename in os.listdir("drafts"): filepath = os.path.join("drafts", filename) with open(filepath, "r") as f: draft = json.load(f) drafts.append({"id": filename, "draft": draft}) return [ TextContent( type="text", text=json.dumps(drafts, indent=2), ) ] except Exception as e: logger.error(f"Error listing drafts: {str(e)}") raise RuntimeError(f"Error listing drafts: {str(e)}")
- src/x_mcp/server.py:132-140 (registration)Registration of the 'list_drafts' tool within the @server.list_tools() function, including its name, description, and empty input schema (no parameters required).Tool( name="list_drafts", description="List all draft tweets and threads", inputSchema={ "type": "object", "properties": {}, "required": [], }, ),
- src/x_mcp/server.py:135-140 (schema)Input schema for the 'list_drafts' tool, which is an empty object (no input parameters required).inputSchema={ "type": "object", "properties": {}, "required": [], }, ),
- src/x_mcp/server.py:542-543 (registration)Dispatch/registration of the 'list_drafts' handler within the general @server.call_tool() function.elif name == "list_drafts": return await handle_list_drafts(arguments)