Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getLikedTweets

Retrieve tweets liked by a specific Twitter user to analyze preferences, monitor engagement, or curate content based on user interests.

Instructions

Get a list of tweets liked by a user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdYesThe ID of the user whose likes to fetch
maxResultsNoThe maximum number of results to return (default: 100, max: 100)
tweetFieldsNoAdditional tweet fields to include in the response

Implementation Reference

  • The core handler function that implements the getLikedTweets tool logic, fetching liked tweets via Twitter API v2.userLikedTweets with pagination and error handling.
    export const handleGetLikedTweets: TwitterHandler<GetLikedTweetsArgs> = async (
        client: TwitterClient | null,
        { userId, maxResults = 100, tweetFields }: GetLikedTweetsArgs
    ): Promise<HandlerResponse> => {
        if (!client) {
            return createMissingTwitterApiKeyResponse('getLikedTweets');
        }
        
        try {
            const likedTweets = await client.v2.userLikedTweets(userId, {
                max_results: maxResults,
                'tweet.fields': tweetFields?.join(',') || 'created_at,public_metrics,author_id'
            });
    
            // The paginator returns data nested: { data: [tweets], meta: {...} }
            const tweetData = likedTweets.data?.data;
            const metaData = likedTweets.data?.meta || likedTweets.meta;
    
            if (!tweetData || !Array.isArray(tweetData) || tweetData.length === 0) {
                return createResponse(`No liked tweets found for user: ${userId}`);
            }
    
            const responseData = {
                likedTweets: tweetData,
                meta: metaData
            };
    
            return createResponse(`Liked tweets: ${JSON.stringify(responseData, null, 2)}`);
        } catch (error) {
            if (error instanceof Error) {
                if (error.message.includes('400') && error.message.includes('Invalid Request')) {
                    throw new Error(`Get liked tweets functionality may require elevated permissions or Pro tier access. Current Basic tier ($200/month) has limited access to user engagement data. Consider upgrading to Pro tier ($5,000/month) at https://developer.x.com/en/portal/products/pro or use alternative methods to track user engagement.`);
                }
                throw new Error(formatTwitterError(error, 'getting liked tweets'));
            }
            throw error;
        }
    }; 
  • MCP tool schema definition including description, input schema with properties for userId, maxResults, and tweetFields.
    getLikedTweets: {
        description: 'Get a list of tweets liked by a user',
        inputSchema: {
            type: 'object',
            properties: {
                userId: { type: 'string', description: 'The ID of the user whose likes to fetch' },
                maxResults: { 
                    type: 'number', 
                    description: 'The maximum number of results to return (default: 100, max: 100)',
                    minimum: 1,
                    maximum: 100
                },
                tweetFields: { 
                    type: 'array', 
                    items: { 
                        type: 'string',
                        enum: ['created_at', 'author_id', 'conversation_id', 'public_metrics', 'entities', 'context_annotations']
                    },
                    description: 'Additional tweet fields to include in the response'
                },
            },
            required: ['userId'],
        },
    },
  • src/index.ts:207-210 (registration)
    Registration and dispatch logic in the MCP CallToolRequestSchema handler switch statement that routes getLikedTweets calls to the handleGetLikedTweets function.
    case 'getLikedTweets': {
        const { userId, maxResults } = request.params.arguments as { userId: string; maxResults?: number };
        response = await handleGetLikedTweets(client, { userId, maxResults });
        break;
  • TypeScript interface defining the input arguments for the getLikedTweets handler.
    interface GetLikedTweetsArgs {
        userId: string;
        maxResults?: number;
        tweetFields?: string[];
    }
  • src/index.ts:30-30 (registration)
    Import statement registering the handler function for use in the tool dispatch.
    handleGetLikedTweets
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool fetches liked tweets but omits critical details: whether it requires authentication, if it's read-only or has side effects, rate limits, pagination behavior, or error handling. For a tool with no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero wasted words. It's front-loaded with the core purpose and efficiently communicates the tool's function without unnecessary elaboration, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a tweet retrieval tool with no annotations, no output schema, and multiple parameters, the description is incomplete. It lacks behavioral context (e.g., authentication needs, rate limits), output format details, and usage guidelines relative to siblings, leaving the agent under-informed for proper tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all three parameters (userId, maxResults, tweetFields) with descriptions and constraints. The description adds no additional parameter semantics beyond implying a user context, which is already covered by the schema. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get a list') and resource ('tweets liked by a user'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential siblings like 'getUserTimeline' or 'searchTweets' that might also retrieve tweets, leaving room for ambiguity in a crowded toolset.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With many sibling tools for tweet retrieval (e.g., 'getUserTimeline', 'searchTweets', 'getTweetById'), there's no indication of context, prerequisites, or exclusions, leaving the agent to guess based on the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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