retweet
Share a tweet with your followers by specifying its ID. This tool enables you to amplify content on Twitter through the Twitter MCP Server.
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
- The `handleRetweet` function implements the core logic for the 'retweet' tool. It validates the Twitter client, retrieves the authenticated user ID, performs the retweet using Twitter API v2, and returns a success message or throws a formatted error.export 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)Input schema definition for the 'retweet' tool, specifying the required 'tweetId' parameter.retweet: { 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)Dispatch logic in the main tool request handler that routes calls to the 'retweet' tool to the `handleRetweet` function.case 'retweet': { const { tweetId } = request.params.arguments as { tweetId: string }; response = await handleRetweet(client, { tweetId }); break;
- src/index.ts:104-109 (registration)Tool listing registration that includes the 'retweet' tool from the TOOLS object when listing available tools.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.entries(TOOLS).map(([name, tool]) => ({ name, ...tool })) }));