Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getFollowers

Retrieve a Twitter user's follower list to analyze audience connections, track engagement metrics, or identify community members. Specify username and customize data fields for targeted insights.

Instructions

Get followers of a user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the account
maxResultsNoMaximum number of followers to return
userFieldsNoFields to include in the user objects

Implementation Reference

  • Core implementation of the getFollowers tool handler. Fetches the user by username, then retrieves their followers using Twitter API v2.followers endpoint, handles errors including permission requirements.
    export const handleGetFollowers: TwitterHandler<GetFollowersArgs> = async (
        client: TwitterClient | null,
        { username, maxResults, userFields }: GetFollowersArgs
    ): Promise<HandlerResponse> => {
        if (!client) {
            return createMissingTwitterApiKeyResponse('getFollowers');
        }
    
        try {
            const user = await client.v2.userByUsername(username);
            if (!user.data) {
                throw new Error(`User not found: ${username}`);
            }
    
            const followers = await client.v2.followers(user.data.id, {
                max_results: maxResults,
                'user.fields': userFields?.join(',') || 'description,public_metrics'
            });
    
            if (!followers.data || !Array.isArray(followers.data) || followers.data.length === 0) {
                return createResponse(`No followers found for user: ${username}`);
            }
    
            const responseData = {
                followers: followers.data,
                meta: followers.meta
            };
    
            return createResponse(`Followers for ${username}: ${JSON.stringify(responseData, null, 2)}`);
        } catch (error) {
            if (error instanceof Error) {
                if (error.message.includes('403')) {
                    throw new Error(`Get followers functionality requires elevated permissions. This endpoint may require Pro tier access ($5,000/month) or special permission approval from X. Current Basic tier ($200/month) has limited access to follower data for privacy reasons. Contact X Developer Support or consider upgrading at https://developer.x.com/en/portal/products/pro`);
                }
                throw new Error(formatTwitterError(error, 'getting followers'));
            }
            throw error;
        }
    };
  • MCP tool registration and input schema definition for getFollowers, including parameters for username, maxResults, and userFields.
    getFollowers: {
        description: 'Get followers of a user',
        inputSchema: {
            type: 'object',
            properties: {
                username: {
                    type: 'string',
                    description: 'The username of the account'
                },
                maxResults: {
                    type: 'number',
                    description: 'Maximum number of followers to return'
                },
                userFields: {
                    type: 'array',
                    items: {
                        type: 'string'
                    },
                    description: 'Fields to include in the user objects'
                }
            },
            required: ['username']
        }
    },
  • src/index.ts:270-273 (registration)
    MCP server tool dispatch logic that routes 'getFollowers' calls to the handleGetFollowers function.
    case 'getFollowers': {
        const { username, maxResults } = request.params.arguments as { username: string; maxResults?: number };
        response = await handleGetFollowers(client, { username, maxResults });
        break;
  • TypeScript interface defining the input arguments for getFollowers.
    export interface GetFollowersArgs {
        username: string;
        maxResults?: number;
        userFields?: string[];
    }
  • Runtime assertion function for validating getFollowers input arguments.
    export function assertGetFollowersArgs(args: unknown): asserts args is GetFollowersArgs {
        if (typeof args !== 'object' || args === null) {
            throw new Error('Invalid arguments: expected object');
        }
        if (!('username' in args) || typeof (args as any).username !== 'string') {
            throw new Error('Invalid arguments: expected username string');
        }
        if ('maxResults' in args) {
            const maxResults = (args as any).maxResults;
            if (typeof maxResults !== 'number' || maxResults < 1 || maxResults > 1000) {
                throw new Error('Invalid arguments: maxResults must be a number between 1 and 1000');
            }
        }
        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 full burden. It mentions a read operation ('Get') but does not disclose behavioral traits such as rate limits, authentication needs, pagination, or what happens if the username is invalid. This leaves significant gaps for a tool with parameters.

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

Conciseness4/5

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

The description is a single, efficient sentence with no wasted words. It is front-loaded and appropriately sized for a simple tool, though it could be more informative without losing conciseness.

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 no annotations, no output schema, and a tool with 3 parameters, the description is incomplete. It does not explain return values, error handling, or behavioral context, making it inadequate for effective 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 parameters like 'username', 'maxResults', and 'userFields'. The description adds no meaning beyond the schema, as it does not explain parameter interactions or usage examples. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose3/5

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

The description 'Get followers of a user' states a clear verb ('Get') and resource ('followers of a user'), but it is vague about scope and does not differentiate from sibling tools like 'getFollowing' or 'getUserInfo'. It lacks specificity such as whether it returns a list, count, or detailed profiles.

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?

No guidance is provided on when to use this tool versus alternatives like 'getFollowing' (for users followed by a user) or 'getUserInfo' (for user details). The description does not mention prerequisites, context, or exclusions, leaving usage unclear.

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