Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getFollowing

Retrieve a list of users that a specific Twitter account follows, with options to control result count and include additional user information.

Instructions

Get a list of users that a user is following

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the user whose following list to fetch
maxResultsNoThe maximum number of results to return (default: 100, max: 1000)
userFieldsNoAdditional user fields to include in the response

Implementation Reference

  • Core handler function that executes the tool logic: fetches the user by username, then retrieves the list of users they are following using Twitter API v2 'following' endpoint, handles errors including permissions.
    export const handleGetFollowing: TwitterHandler<GetFollowingArgs> = async (
        client: TwitterClient | null,
        { username, maxResults, userFields }: GetFollowingArgs
    ): Promise<HandlerResponse> => {
        if (!client) {
            return createMissingTwitterApiKeyResponse('getFollowing');
        }
    
        try {
            const user = await client.v2.userByUsername(username);
            if (!user.data) {
                throw new Error(`User not found: ${username}`);
            }
    
            const following = await client.v2.following(user.data.id, {
                max_results: maxResults,
                'user.fields': userFields?.join(',') || 'description,profile_image_url,public_metrics,verified'
            });
    
            if (!following.data || !Array.isArray(following.data) || following.data.length === 0) {
                return createResponse(`User ${username} is not following anyone`);
            }
    
            const responseData = {
                following: following.data,
                meta: following.meta
            };
    
            return createResponse(`Users followed by ${username}: ${JSON.stringify(responseData, null, 2)}`);
        } catch (error) {
            if (error instanceof Error) {
                if (error.message.includes('403')) {
                    throw new Error(`Get following 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 following 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 following'));
            }
            throw error;
        }
    };
  • MCP tool schema definition: specifies description and inputSchema for getFollowing tool with parameters username (required), maxResults, userFields.
    getFollowing: {
        description: 'Get a list of users that a user is following',
        inputSchema: {
            type: 'object',
            properties: {
                username: { type: 'string', description: 'The username of the user whose following list to fetch' },
                maxResults: { 
                    type: 'number', 
                    description: 'The maximum number of results to return (default: 100, max: 1000)',
                    minimum: 1,
                    maximum: 1000
                },
                userFields: { 
                    type: 'array', 
                    items: { 
                        type: 'string',
                        enum: ['description', 'profile_image_url', 'public_metrics', 'verified', 'location', 'url']
                    },
                    description: 'Additional user fields to include in the response'
                },
            },
            required: ['username'],
        },
    },
  • src/index.ts:275-278 (registration)
    Tool call dispatch/registration in the MCP CallToolRequestHandler switch statement: extracts arguments and invokes the handleGetFollowing function.
    case 'getFollowing': {
        const { username, maxResults } = request.params.arguments as { username: string; maxResults?: number };
        response = await handleGetFollowing(client, { username, maxResults });
        break;
  • TypeScript interface defining input arguments for the getFollowing handler.
    export interface GetFollowingArgs {
        username: string;
        maxResults?: number;
        userFields?: string[];
    }
  • Runtime type assertion helper function to validate getFollowing arguments.
    export function assertGetFollowingArgs(args: unknown): asserts args is GetFollowingArgs {
        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 the full burden of behavioral disclosure. It states the tool fetches a list but omits critical details: whether it's paginated, rate-limited, requires authentication, returns partial data on errors, or has side effects. For a read operation with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves in practice.

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, front-loaded sentence that directly states the tool's purpose without unnecessary words. It avoids redundancy with the tool name ('getFollowing') and efficiently communicates the core functionality. Every part of the sentence earns its place, making it easy 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 lack of annotations and output schema, the description is incomplete for a tool with three parameters and no structured output documentation. It doesn't describe the return format (e.g., list structure, field mappings), error conditions, or authentication requirements. For a read operation in a social media context, this leaves the agent with insufficient information to use the tool effectively without trial and error.

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%, with clear documentation for all three parameters (username, maxResults, userFields). The description adds no additional parameter semantics beyond what the schema provides—it doesn't explain parameter interactions, default behaviors, or usage examples. With high schema coverage, the baseline score of 3 is appropriate, as the schema does the heavy lifting.

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 ('users that a user is following'), making the purpose immediately understandable. It distinguishes itself from sibling tools like 'getFollowers' (which fetches followers rather than following) by specifying the direction of the relationship. However, it doesn't explicitly mention the platform context (e.g., Twitter/X), which could slightly limit clarity for agents unfamiliar with the domain.

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. It doesn't mention prerequisites (e.g., authentication needs), compare to similar tools like 'getFollowers' or 'findMutualConnections', or specify use cases (e.g., social network analysis). Without such context, an agent must infer usage from the tool name and parameters 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