deleteTweet
Remove a tweet from Twitter using its unique ID to manage content or correct errors.
Instructions
Delete a tweet by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tweetId | Yes | The ID of the tweet to delete |
Implementation Reference
- src/handlers/tweet.handlers.ts:102-119 (handler)The main handler function that executes the deleteTweet tool logic. It validates the Twitter client, calls the Twitter API v2 deleteTweet method, and handles errors with formatted responses.export async function handleDeleteTweet( client: TwitterClient | null, { tweetId }: { tweetId: string } ): Promise<HandlerResponse> { if (!client) { return createMissingTwitterApiKeyResponse('Delete Tweet'); } try { await client.v2.deleteTweet(tweetId); return createResponse(`Successfully deleted tweet: ${tweetId}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'deleting tweet')); } throw new Error('Failed to delete tweet: Unknown error occurred'); } }
- src/tools.ts:424-436 (schema)The tool schema definition including description and input validation schema for the deleteTweet tool, used for MCP tool listing and validation.deleteTweet: { description: 'Delete a tweet by its ID', inputSchema: { type: 'object', properties: { tweetId: { type: 'string', description: 'The ID of the tweet to delete' } }, required: ['tweetId'] } },
- src/index.ts:177-180 (registration)The switch case in the main tool call handler that routes 'deleteTweet' calls to the handleDeleteTweet function.case 'deleteTweet': { const { tweetId } = request.params.arguments as { tweetId: string }; response = await handleDeleteTweet(client, { tweetId }); break;
- src/index.ts:17-21 (registration)Import statement that brings the handleDeleteTweet handler into the main index file for use in tool dispatching.handlePostTweet, handlePostTweetWithMedia, handleGetTweetById, handleReplyToTweet, handleDeleteTweet,