Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getListMembers

Retrieve members from a Twitter list by specifying the list ID, with options to limit results and include additional user details.

Instructions

Get members of a Twitter list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
listIdYesThe ID of the list
maxResultsNoThe maximum number of results to return (default: 100, max: 100)
userFieldsNoAdditional user fields to include in the response

Implementation Reference

  • The main handler function that executes the getListMembers tool logic: validates client, prepares options, calls TwitterClient.getListMembers, formats and returns the response.
    export async function handleGetListMembers(
        client: TwitterClient | null,
        args: GetListMembersArgs
    ): Promise<HandlerResponse> {
        if (!client) {
            return createMissingTwitterApiKeyResponse('getListMembers');
        }
        try {
            const options = {
                max_results: args.maxResults,
                pageLimit: args.pageLimit,
                'user.fields': args.userFields
            };
    
            const members = await client.getListMembers(args.listId, options);
    
            if (!members.data || !Array.isArray(members.data) || members.data.length === 0) {
                return createResponse(`No members found for list ${args.listId}`);
            }
    
            const memberCount = members.meta?.result_count || members.data.length;
            let responseText = `Found ${memberCount} members in list ${args.listId}:\n\n`;
    
            members.data.forEach((member) => {
                responseText += `- ${member.name} (@${member.username})\n`;
            });
    
            if (members.meta?.total_retrieved === args.maxResults) {
                responseText += '\nNote: Maximum requested results reached. There might be more members available.';
            }
    
            return createResponse(responseText);
        } catch (error) {
            if (error instanceof Error) {
                throw new Error(formatTwitterError(error, 'getting list members'));
            }
            throw new Error('Failed to get list members: Unknown error occurred');
        }
    } 
  • src/index.ts:299-306 (registration)
    Registration and dispatch of the getListMembers tool in the MCP server's CallToolRequestSchema handler.
    case 'getListMembers': {
        const { listId, maxResults, userFields } = request.params.arguments as {
            listId: string;
            maxResults?: number;
            userFields?: string[];
        };
        response = await handleGetListMembers(client, { listId, maxResults, userFields });
        break;
  • MCP tool schema definition for getListMembers, including description and inputSchema.
    getListMembers: {
        description: 'Get members of a Twitter list',
        inputSchema: {
            type: 'object',
            properties: {
                listId: { type: 'string', description: 'The ID of the list' },
                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', 'location', 'url']
                    },
                    description: 'Additional user fields to include in the response'
                },
            },
            required: ['listId'],
        },
    },
  • TwitterClient helper method that implements paginated fetching of list members using twitter-api-v2.
    async getListMembers(listId: string, options: any): Promise<PaginatedResponse<UserV2>> {
        const paginationOptions: PaginationOptions = {
            maxResults: options.max_results,
            pageLimit: options.pageLimit
        };
    
        const allMembers: UserV2[] = [];
        const iterator = this.paginateResults<UserV2, UserListMembersV2Paginator>(
            'getListMembers',
            () => this.v2.listMembers(listId, {
                ...options,
                max_results: Math.min(options.max_results || MAX_RESULTS_PER_PAGE, MAX_RESULTS_PER_PAGE)
            }),
            paginationOptions
        );
    
        for await (const members of iterator) {
            allMembers.push(...members);
            if (paginationOptions.maxResults && allMembers.length >= paginationOptions.maxResults) {
                allMembers.length = paginationOptions.maxResults;
                break;
            }
        }
    
        return {
            data: allMembers,
            meta: {
                result_count: allMembers.length,
                total_retrieved: allMembers.length
            }
        };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without behavioral details. It doesn't disclose rate limits, authentication requirements, pagination behavior, error conditions, or what the response contains (e.g., user objects with fields). This leaves significant gaps for safe and effective use.

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, efficient sentence with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a straightforward retrieval tool, 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?

For a tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It lacks behavioral context (rate limits, auth), output format details, and differentiation from siblings. Given the complexity and missing structured data, it should provide more completeness to guide the agent effectively.

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. The description adds no additional meaning about parameters beyond what's in the schema (e.g., format of listId, default behavior of maxResults). 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.

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 'members of a Twitter list', making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'getFollowers' or 'getFollowing' that also retrieve user collections, missing explicit distinction.

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 about when to use this tool versus alternatives like 'getFollowers' or 'getFollowing'. The description lacks context about prerequisites (e.g., needing list ownership/access) or exclusions, offering minimal usage direction.

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