Skip to main content
Glama
cjkcr

X(Twitter) MCP Server

by cjkcr

create_draft_reply

Compose a draft response to an existing X/Twitter post for review and publishing later. Specify the tweet ID to reply to and your reply content.

Instructions

Create a draft reply to an existing tweet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe content of the reply tweet
reply_to_tweet_idYesThe ID of the tweet to reply to

Implementation Reference

  • The handler function that executes the 'create_draft_reply' tool. It validates input arguments, creates a JSON draft file containing the reply content, target tweet ID, timestamp, and type='reply', saves it in the 'drafts' directory with a unique ID, logs the action, and returns a success message with the draft ID.
    async def handle_create_draft_reply(arguments: Any) -> Sequence[TextContent]: if not isinstance(arguments, dict) or "content" not in arguments or "reply_to_tweet_id" not in arguments: raise ValueError("Invalid arguments for create_draft_reply") content = arguments["content"] reply_to_tweet_id = arguments["reply_to_tweet_id"] try: # Create a draft reply with the tweet ID to reply to draft = { "content": content, "reply_to_tweet_id": reply_to_tweet_id, "timestamp": datetime.now().isoformat(), "type": "reply" } # Ensure drafts directory exists os.makedirs("drafts", exist_ok=True) # Save the draft to a file draft_id = f"reply_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 reply created: {draft_id}") return [ TextContent( type="text", text=f"Draft reply created with ID {draft_id} (replying to tweet {reply_to_tweet_id})", ) ] except Exception as e: logger.error(f"Error creating draft reply: {str(e)}") raise RuntimeError(f"Error creating draft reply: {str(e)}")
  • Tool call dispatcher in the main @server.call_tool() function that routes 'create_draft_reply' calls to the specific handler function.
    elif name == "create_draft_reply": return await handle_create_draft_reply(arguments)
  • Registers the 'create_draft_reply' tool in @server.list_tools() with its name, description, and input schema defining required 'content' (string) and 'reply_to_tweet_id' (string) parameters.
    name="create_draft_reply", description="Create a draft reply to an existing tweet", inputSchema={ "type": "object", "properties": { "content": { "type": "string", "description": "The content of the reply tweet", }, "reply_to_tweet_id": { "type": "string", "description": "The ID of the tweet to reply to", }, }, "required": ["content", "reply_to_tweet_id"], }, ),
  • Defines the input schema for the 'create_draft_reply' tool within its Tool registration, specifying an object with required string properties 'content' and 'reply_to_tweet_id'.
    name="create_draft_reply", description="Create a draft reply to an existing tweet", inputSchema={ "type": "object", "properties": { "content": { "type": "string", "description": "The content of the reply tweet", }, "reply_to_tweet_id": { "type": "string", "description": "The ID of the tweet to reply to", }, }, "required": ["content", "reply_to_tweet_id"], }, ),

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