Skip to main content
Glama
vidhupv

X(Twitter) MCP Server

by vidhupv

create_draft_thread

Create draft tweet threads for X/Twitter by providing multiple tweet contents as an array, preparing content for review before publishing.

Instructions

Create a draft tweet thread

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentsYesAn array of tweet contents for the thread

Implementation Reference

  • The main handler function that executes the create_draft_thread tool. It validates the input arguments, creates a JSON file for the draft thread in the 'drafts' directory, and returns a TextContent response with the draft ID.
    async def handle_create_draft_thread(arguments: Any) -> Sequence[TextContent]: if not isinstance(arguments, dict) or "contents" not in arguments: raise ValueError("Invalid arguments for create_draft_thread") contents = arguments["contents"] if not isinstance(contents, list) or not all(isinstance(item, str) for item in contents): raise ValueError("Invalid contents for create_draft_thread") try: draft = {"contents": contents, "timestamp": datetime.now().isoformat()} # Ensure drafts directory exists os.makedirs("drafts", exist_ok=True) # Save the draft to a file draft_id = f"thread_draft_{int(datetime.now().timestamp())}.json" with open(os.path.join("drafts", draft_id), "w") as f: json.dump(draft, f, indent=2) logger.info(f"Draft thread created: {draft_id}") return [ TextContent( type="text", text=f"Draft thread created with ID {draft_id}", ) ] except Exception as e: logger.error(f"Error creating draft thread: {str(e)}") raise RuntimeError(f"Error creating draft thread: {str(e)}")
  • Tool registration in the list_tools() function, defining the name, description, and input schema for create_draft_thread.
    Tool( name="create_draft_thread", description="Create a draft tweet thread", inputSchema={ "type": "object", "properties": { "contents": { "type": "array", "items": {"type": "string"}, "description": "An array of tweet contents for the thread", }, }, "required": ["contents"], }, ),
  • Input schema definition for the create_draft_thread tool, specifying an object with a required 'contents' array of strings.
    "type": "object", "properties": { "contents": { "type": "array", "items": {"type": "string"}, "description": "An array of tweet contents for the thread", }, }, "required": ["contents"], },

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