retweet
Share a tweet on Twitter by specifying its unique ID using the MCP server, enabling automated retweeting functionality for efficient content sharing.
Instructions
Retweet a tweet by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tweetId | Yes | The ID of the tweet to retweet |
Implementation Reference
- Implementation of the retweet tool handler using Twitter API v2 to retweet a tweet by IDexport const handleRetweet: TwitterHandler<TweetEngagementArgs> = async ( client: TwitterClient | null, { tweetId }: TweetEngagementArgs ): Promise<HandlerResponse> => { if (!client) { return createMissingTwitterApiKeyResponse('retweet'); } try { const userId = await client.v2.me().then((response: any) => response.data.id); await client.v2.retweet(userId, tweetId); return createResponse(`Successfully retweeted tweet: ${tweetId}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'retweeting')); } throw error; } };
- src/tools.ts:209-218 (schema)Schema definition for the 'retweet' tool, specifying input parameters and descriptionretweet: { description: 'Retweet a tweet by its ID', inputSchema: { type: 'object', properties: { tweetId: { type: 'string', description: 'The ID of the tweet to retweet' } }, required: ['tweetId'], }, },
- src/index.ts:192-195 (registration)Tool registration in the CallToolRequestSchema handler switch statement, dispatching to handleRetweetcase 'retweet': { const { tweetId } = request.params.arguments as { tweetId: string }; response = await handleRetweet(client, { tweetId }); break;