retweet
Share an existing tweet with your followers by providing its ID, enabling content redistribution on X/Twitter through the MCP server.
Instructions
Retweet an existing tweet (simple retweet without comment)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tweet_id | Yes | The ID of the tweet to retweet |
Input Schema (JSON Schema)
{
"properties": {
"tweet_id": {
"description": "The ID of the tweet to retweet",
"type": "string"
}
},
"required": [
"tweet_id"
],
"type": "object"
}
Implementation Reference
- src/x_mcp/server.py:907-930 (handler)The main handler function for the 'retweet' tool. Validates input, calls tweepy.Client.retweet(tweet_id) using the write client, logs the action, and returns a success message or raises appropriate errors.async def handle_retweet(arguments: Any) -> Sequence[TextContent]: if not isinstance(arguments, dict) or "tweet_id" not in arguments: raise ValueError("Invalid arguments for retweet") tweet_id = arguments["tweet_id"] try: # Simple retweet without comment using the retweet method response = get_write_client().retweet(tweet_id) logger.info(f"Retweeted tweet {tweet_id}") return [ TextContent( type="text", text=f"Successfully retweeted tweet {tweet_id}", ) ] except tweepy.TweepError as e: logger.error(f"Twitter API error retweeting tweet {tweet_id}: {e}") raise RuntimeError(f"Twitter API error retweeting tweet {tweet_id}: {e}") except Exception as e: logger.error(f"Error retweeting tweet {tweet_id}: {str(e)}") raise RuntimeError(f"Error retweeting tweet {tweet_id}: {str(e)}")
- src/x_mcp/server.py:205-218 (registration)Registers the 'retweet' tool in the list_tools() function, providing name, description, and input schema requiring a 'tweet_id' string.Tool( name="retweet", description="Retweet an existing tweet (simple retweet without comment)", inputSchema={ "type": "object", "properties": { "tweet_id": { "type": "string", "description": "The ID of the tweet to retweet", }, }, "required": ["tweet_id"], }, ),
- src/x_mcp/server.py:552-553 (registration)Dispatches calls to the 'retweet' tool handler in the general call_tool function.elif name == "retweet": return await handle_retweet(arguments)