deleteTweet
Remove a specific tweet from Twitter by providing its unique ID using the Twitter MCP Server. Streamline content management and maintain control over your social media presence.
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 core handler function that executes the deleteTweet tool logic. It checks for a valid TwitterClient, calls client.v2.deleteTweet(tweetId), 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)Defines the tool schema including description and input validation schema for deleteTweet, specifying that tweetId is required.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)Registers and dispatches the deleteTweet tool in the MCP server's CallToolRequestHandler switch statement by extracting tweetId from arguments and calling the handleDeleteTweet function.case 'deleteTweet': { const { tweetId } = request.params.arguments as { tweetId: string }; response = await handleDeleteTweet(client, { tweetId }); break;