undoRetweet
Remove a retweet from your Twitter timeline by providing the tweet ID. This action reverses sharing while keeping the original tweet intact.
Instructions
Undo a retweet by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tweetId | Yes | The ID of the tweet to un-retweet |
Implementation Reference
- Main handler function that performs the undoRetweet operation using Twitter API v2.unretweet after getting the authenticated user ID.
export const handleUndoRetweet: TwitterHandler<TweetEngagementArgs> = async ( client: TwitterClient | null, { tweetId }: TweetEngagementArgs ): Promise<HandlerResponse> => { if (!client) { return createMissingTwitterApiKeyResponse('undoRetweet'); } try { const userId = await client.v2.me().then((response: any) => response.data.id); await client.v2.unretweet(userId, tweetId); return createResponse(`Successfully undid retweet: ${tweetId}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'undoing retweet')); } throw error; } }; - src/tools.ts:219-228 (schema)MCP tool schema definition for undoRetweet, specifying the input schema requiring tweetId.
undoRetweet: { description: 'Undo a retweet by its ID', inputSchema: { type: 'object', properties: { tweetId: { type: 'string', description: 'The ID of the tweet to un-retweet' } }, required: ['tweetId'], }, }, - src/index.ts:197-200 (registration)Registration in the main CallToolRequestSchema handler switch statement, dispatching to handleUndoRetweet.
case 'undoRetweet': { const { tweetId } = request.params.arguments as { tweetId: string }; response = await handleUndoRetweet(client, { tweetId }); break; - src/types.ts:59-61 (schema)TypeScript interface defining the input arguments for undoRetweet.
export interface UndoRetweetArgs { tweetId: string; } - src/index.ts:104-109 (registration)Registration of all tools including undoRetweet via the TOOLS object for the ListToolsRequestSchema.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.entries(TOOLS).map(([name, tool]) => ({ name, ...tool })) }));