Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getUserLists

Retrieve Twitter lists created by a specific user to organize accounts they follow, including details like member counts and privacy settings.

Instructions

Get lists owned by a user

Input Schema

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

Implementation Reference

  • Core handler function that fetches and formats a user's owned Twitter lists and list memberships using the Twitter API v2.
    export async function handleGetUserLists(
        client: TwitterClient | null,
        args: GetUserListsArgs
    ): Promise<HandlerResponse> {
        if (!client) {
            return createMissingTwitterApiKeyResponse('getUserLists');
        }
        try {
            const user = await client.getUserByUsername(args.username);
            if (!user.data) {
                throw new Error('User not found');
            }
    
            const options = {
                'list.fields': ['created_at', 'follower_count', 'member_count', 'private', 'description'],
                expansions: ['owner_id'],
                'user.fields': ['username', 'name', 'verified'],
                max_results: args.maxResults,
                pageLimit: args.pageLimit
            };
    
            const [ownedLists, memberLists] = await Promise.all([
                client.getOwnedLists(user.data.id, options),
                client.getListMemberships(user.data.id, options)
            ]);
    
            const ownedListsCount = ownedLists.meta.result_count || 0;
            const memberListsCount = memberLists.meta.result_count || 0;
    
            let responseText = `Found ${ownedListsCount} owned lists and ${memberListsCount} list memberships.\n\n`;
    
            if (ownedLists.data && ownedLists.data.length > 0) {
                responseText += 'Owned Lists:\n';
                ownedLists.data.forEach((list) => {
                    responseText += formatListInfo(list);
                });
                responseText += '\n';
            }
    
            if (memberLists.data && memberLists.data.length > 0) {
                responseText += 'Member of Lists:\n';
                memberLists.data.forEach((list) => {
                    responseText += formatListInfo(list);
                });
            }
    
            const totalRetrieved = (ownedLists.meta.total_retrieved || 0) + (memberLists.meta.total_retrieved || 0);
            const totalRequested = args.maxResults ? args.maxResults * 2 : undefined;
    
            if (totalRequested && totalRetrieved >= totalRequested) {
                responseText += '\nNote: Maximum requested results reached. There might be more lists available.';
            }
    
            return createResponse(responseText);
        } catch (error) {
            if (error instanceof Error) {
                throw new Error(formatTwitterError(error, 'getting user lists'));
            }
            throw new Error('Failed to get user lists: Unknown error occurred');
        }
    }
  • MCP tool schema definition including input validation schema for getUserLists tool.
    getUserLists: {
        description: 'Get lists owned by a user',
        inputSchema: {
            type: 'object',
            properties: {
                username: { type: 'string', description: 'The username of the user whose lists to fetch' },
                maxResults: { 
                    type: 'number', 
                    description: 'The maximum number of results to return (default: 100, max: 100)',
                    minimum: 1,
                    maximum: 100
                },
                listFields: { 
                    type: 'array', 
                    items: { 
                        type: 'string',
                        enum: ['created_at', 'follower_count', 'member_count', 'private', 'description']
                    },
                    description: 'Additional list fields to include in the response'
                },
            },
            required: ['username'],
        },
    },
  • src/index.ts:308-311 (registration)
    Tool dispatch/registration in the main MCP server request handler switch statement.
    case 'getUserLists': {
        const { username, maxResults } = request.params.arguments as { username: string; maxResults?: number };
        response = await handleGetUserLists(client, { username, maxResults });
        break;
  • src/index.ts:41-45 (registration)
    Import of the handleGetUserLists handler function into the main server index.
    handleCreateList,
    handleAddUserToList,
    handleRemoveUserFromList,
    handleGetListMembers,
    handleGetUserLists
  • Helper function to format list information for the response text.
    function formatListInfo(list: ListV2): string {
        const name = list.name.length > 50 ? `${list.name.substring(0, 47)}...` : list.name;
        const description = list.description
            ? list.description.length > 100
                ? `${list.description.substring(0, 97)}...`
                : list.description
            : '';
    
        return `- ${name} (${list.member_count} members${list.private ? ', private' : ''})${
            description ? `: ${description}` : ''
        }\n`;
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions fetching lists but doesn't cover aspects like rate limits, authentication requirements, pagination behavior, or error handling. This leaves significant gaps for a tool that likely involves API calls.

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 no wasted words, making it easy to parse and front-loaded with the core purpose. It efficiently conveys the essential information without unnecessary elaboration.

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 insufficient for a tool with 3 parameters and likely complex behavior (e.g., API interactions). It doesn't address return values, error cases, or operational constraints, leaving the agent with incomplete context.

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 input schema already documents all parameters thoroughly. The description adds no additional meaning beyond implying a user context, which is redundant with 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') and resource ('lists owned by a user'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'getListMembers' or 'createList', which also involve lists, so it lacks explicit sibling 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 on when to use this tool versus alternatives such as 'getListMembers' or 'getUserInfo', nor does it mention prerequisites or context for usage. The description only states what it does without indicating appropriate scenarios.

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