Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

unlikeTweet

Remove your like from a tweet on Twitter. Use this tool to undo a previous like action by providing the tweet ID.

Instructions

Unlike a previously liked tweet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tweetIdYesThe 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(userId, tweetId), and returns success/error response.
    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;
        }
    };
  • MCP tool registration with input schema definition for unlikeTweet: requires tweetId string.
    unlikeTweet: {
        description: 'Unlike a previously liked tweet',
        inputSchema: {
            type: 'object',
            properties: {
                tweetId: { type: 'string', description: 'The ID of the tweet to unlike' }
            },
            required: ['tweetId'],
        },
    },
  • TypeScript interface defining input arguments for unlikeTweet handler.
    export interface UnlikeTweetArgs {
        tweetId: string;
    }
  • src/index.ts:187-190 (registration)
    MCP server dispatch/registration: routes 'unlikeTweet' tool calls to the handleUnlikeTweet function.
    case 'unlikeTweet': {
        const { tweetId } = request.params.arguments as { tweetId: string };
        response = await handleUnlikeTweet(client, { tweetId });
        break;
  • Runtime validation function to assert and validate UnlikeTweetArgs input.
    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');
        }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/crazyrabbitLTC/mcp-twitter-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server