unlikeTweet
Remove your like from a specific tweet on Twitter by providing the tweet ID. This tool integrates with the Twitter MCP Server to manage interactions with tweets.
Instructions
Unlike a previously liked tweet
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tweetId | Yes | The ID of the tweet to unlike |
Implementation Reference
- Core handler function that executes the unlikeTweet tool: checks for Twitter client, retrieves authenticated user ID, calls Twitter API v2 unlike endpoint, returns success message or formatted error.export const handleUnlikeTweet: TwitterHandler<TweetEngagementArgs> = async ( client: TwitterClient | null, { tweetId }: TweetEngagementArgs ): Promise<HandlerResponse> => { if (!client) { return createMissingTwitterApiKeyResponse('unlikeTweet'); } try { const userId = await client.v2.me().then((response: any) => response.data.id); await client.v2.unlike(userId, tweetId); return createResponse(`Successfully unliked tweet: ${tweetId}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'unliking tweet')); } throw error; } };
- src/tools.ts:45-54 (schema)Tool schema definition including description and input schema (requires tweetId string) used for tool listing and validation.unlikeTweet: { description: 'Unlike a previously liked tweet', inputSchema: { type: 'object', properties: { tweetId: { type: 'string', description: 'The ID of the tweet to unlike' } }, required: ['tweetId'], }, },
- src/index.ts:187-190 (registration)Tool dispatch/registration in the main CallToolRequestSchema handler switch statement, extracts tweetId from arguments and calls the handler.case 'unlikeTweet': { const { tweetId } = request.params.arguments as { tweetId: string }; response = await handleUnlikeTweet(client, { tweetId }); break;
- src/types.ts:45-47 (schema)TypeScript interface defining the input arguments for unlikeTweet (tweetId: string).export interface UnlikeTweetArgs { tweetId: string; }
- src/types.ts:257-264 (schema)Runtime assertion function to validate unlikeTweet arguments, ensuring tweetId is present and a string.export function assertUnlikeTweetArgs(args: unknown): asserts args is UnlikeTweetArgs { if (typeof args !== 'object' || args === null) { throw new Error('Invalid arguments: expected object'); } if (!('tweetId' in args) || typeof (args as any).tweetId !== 'string') { throw new Error('Invalid arguments: expected tweetId string'); } }