Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getRetweets

Retrieve a list of users who retweeted a specific tweet, with options to limit results and include additional user information.

Instructions

Get a list of retweets of a tweet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tweetIdYesThe ID of the tweet to get retweets for
maxResultsNoThe maximum number of results to return (default: 100, max: 100)
userFieldsNoAdditional user fields to include in the response

Implementation Reference

  • The core handler function implementing the getRetweets tool. It uses the Twitter API v2 tweetRetweetedBy endpoint to fetch users who retweeted a given tweet ID, with optional pagination and user fields.
    export const handleGetRetweets: TwitterHandler<GetRetweetsArgs> = async (
        client: TwitterClient | null,
        { tweetId, maxResults = 100, userFields }: GetRetweetsArgs
    ): Promise<HandlerResponse> => {
        if (!client) {
            return createMissingTwitterApiKeyResponse('getRetweets');
        }
        
        try {
            const retweets = await client.v2.tweetRetweetedBy(tweetId, {
                max_results: maxResults,
                'user.fields': userFields?.join(',') || 'description,profile_image_url,public_metrics,verified'
            });
    
            if (!retweets.data || !Array.isArray(retweets.data) || retweets.data.length === 0) {
                return createResponse(`No retweets found for tweet: ${tweetId}`);
            }
    
            const responseData = {
                retweetedBy: retweets.data,
                meta: retweets.meta
            };
    
            return createResponse(`Users who retweeted: ${JSON.stringify(responseData, null, 2)}`);
        } catch (error) {
            if (error instanceof Error) {
                throw new Error(formatTwitterError(error, 'getting retweets'));
            }
            throw error;
        }
    };
  • MCP tool schema definition for getRetweets, including input validation schema with required tweetId and optional maxResults and userFields.
    getRetweets: {
        description: 'Get a list of retweets of a tweet',
        inputSchema: {
            type: 'object',
            properties: {
                tweetId: { type: 'string', description: 'The ID of the tweet to get retweets for' },
                maxResults: { 
                    type: 'number', 
                    description: 'The maximum number of results to return (default: 100, max: 100)',
                    minimum: 1,
                    maximum: 100
                },
                userFields: { 
                    type: 'array', 
                    items: { 
                        type: 'string',
                        enum: ['description', 'profile_image_url', 'public_metrics', 'verified']
                    },
                    description: 'Additional user fields to include in the response'
                },
            },
            required: ['tweetId'],
        },
    },
  • src/index.ts:202-205 (registration)
    Tool registration and dispatch in the main MCP server request handler switch statement.
    case 'getRetweets': {
        const { tweetId, maxResults } = request.params.arguments as { tweetId: string; maxResults?: number };
        response = await handleGetRetweets(client, { tweetId, maxResults });
        break;
  • TypeScript interface defining the input arguments for the getRetweets handler.
    export interface GetRetweetsArgs {
        tweetId: string;
        maxResults?: number;
        userFields?: string[];
    }
  • Runtime assertion function to validate getRetweets arguments.
    export function assertGetRetweetsArgs(args: unknown): asserts args is GetRetweetsArgs {
        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');
        }
        if ('maxResults' in args) {
            const maxResults = (args as any).maxResults;
            if (typeof maxResults !== 'number' || maxResults < 1 || maxResults > 100) {
                throw new Error('Invalid arguments: maxResults must be a number between 1 and 100');
            }
        }
        if ('userFields' in args) {
            if (!Array.isArray((args as any).userFields)) {
                throw new Error('Invalid arguments: expected userFields to be an array');
            }
            for (const field of (args as any).userFields) {
                if (typeof field !== 'string') {
                    throw new Error('Invalid arguments: expected userFields to be an array of strings');
                }
            }
        }
    }
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 what the tool does but doesn't mention rate limits, authentication requirements, pagination behavior, error conditions, or what the response format looks like. For a data retrieval tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

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 doesn't include any unnecessary information, making it highly efficient and easy to parse.

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?

For a data retrieval tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the response contains (e.g., retweet objects, user details), how results are structured, or any behavioral constraints. With rich sibling tools available, more context is needed for proper tool selection and usage.

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 already fully documents all three parameters (tweetId, maxResults, userFields). The description doesn't add any additional meaning about parameters beyond what's in the schema, such as explaining why userFields might be useful or providing examples. Baseline 3 is appropriate when the schema does all the work.

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 verb ('Get') and resource ('a list of retweets of a tweet'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential sibling tools like 'getConversation' or 'getFullThread' that might also retrieve tweet-related data, preventing a perfect score.

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 available (e.g., 'getTweetById', 'getConversation', 'getLikedTweets'), there's no indication of when retweets are the appropriate data to fetch versus other tweet-related information.

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