Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

addUserToList

Add a Twitter user to a specific list by providing the list ID and username to organize and categorize accounts for better content management.

Instructions

Add a user to a Twitter list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
listIdYesThe ID of the list
usernameYesThe username of the user to add

Implementation Reference

  • Core handler function that executes the addUserToList tool: verifies user and list existence, adds user via Twitter API v2, handles errors including rate limits and permissions.
    export async function handleAddUserToList(
        client: TwitterClient | null,
        args: AddUserToListArgs
    ): Promise<HandlerResponse> {
        if (!client) {
            return createMissingTwitterApiKeyResponse('addUserToList');
        }
        try {
            // First, verify the user exists and get their username for the response message
            const user = await client.getUserById(args.userId);
            if (!user.data) {
                throw new Error(`User with ID ${args.userId} not found`);
            }
    
            // Then verify the list exists and get its name for the response message
            const list = await client.getList(args.listId);
            if (!list.data) {
                throw new Error(`List with ID ${args.listId} not found`);
            }
    
            // Now try to add the user to the list
            await client.addListMember(args.listId, args.userId);
    
            return createResponse(
                `Successfully added user @${user.data.username} to list "${list.data.name}"`
            );
        } catch (error) {
            if (error instanceof ApiResponseError) {
                // Handle specific Twitter API errors
                if (error.rateLimitError && error.rateLimit) {
                    const resetMinutes = Math.ceil(error.rateLimit.reset / 60);
                    throw new Error(`Rate limit exceeded. Please try again in ${resetMinutes} minutes.`);
                }
                if (error.code === 403) {
                    throw new Error('You do not have permission to add members to this list.');
                }
                if (error.code === 404) {
                    throw new Error('The specified user or list could not be found.');
                }
                throw new Error(`Twitter API Error: ${error.message}`);
            }
            if (error instanceof Error) {
                throw new Error(formatTwitterError(error, 'adding user to list'));
            }
            throw new Error('Failed to add user to list: Unknown error occurred');
        }
    }
  • Input schema definition for the addUserToList tool, specifying listId and username parameters.
    addUserToList: {
        description: 'Add a user to a Twitter list',
        inputSchema: {
            type: 'object',
            properties: {
                listId: { type: 'string', description: 'The ID of the list' },
                username: { type: 'string', description: 'The username of the user to add' }
            },
            required: ['listId', 'username'],
        },
    },
  • src/index.ts:289-292 (registration)
    Tool dispatch/registration in MCP server's CallToolRequestHandler switch statement, mapping tool call to handlerAddUserToList.
    case 'addUserToList': {
        const { listId, userId } = request.params.arguments as { listId: string; userId: string };
        response = await handleAddUserToList(client, { listId, userId });
        break;
  • src/index.ts:104-109 (registration)
    MCP tool listing registration: exposes all tools from TOOLS object (including addUserToList) via ListToolsRequestSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: Object.entries(TOOLS).map(([name, tool]) => ({
            name,
            ...tool
        }))
    }));
  • TypeScript interface defining expected arguments for the handler (note: uses userId vs schema's username).
    export interface AddUserToListArgs {
        listId: string;
        userId: string;
    }
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 states the action but doesn't cover critical aspects like required permissions (e.g., if the user must own the list), rate limits, error conditions, or what happens on success/failure. This is a significant gap for a mutation tool.

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 waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, 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 this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., permissions, side effects), return values, or error handling, which are essential for safe and effective use by an AI agent.

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 documents both parameters ('listId' and 'username') adequately. The description doesn't add any additional meaning beyond what the schema provides, such as format examples or constraints, meeting 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 ('Add a user') and the resource ('to a Twitter list'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from its sibling 'removeUserFromList' beyond the opposite action, missing full 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 like 'followUser' or 'createList', nor are prerequisites mentioned (e.g., needing list ownership or permissions). The description lacks explicit when/when-not instructions or named alternatives.

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