Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

followUser

Follow Twitter users by their username to stay updated with their content and interactions.

Instructions

Follow a user by their username

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the user to follow

Implementation Reference

  • The core handler function that implements the followUser tool logic. It retrieves the authenticated user's ID, looks up the target user by username, and calls the Twitter API v2 follow endpoint.
    export const handleFollowUser: TwitterHandler<UserHandlerArgs> = async (
        client: TwitterClient | null,
        { username }: UserHandlerArgs
    ): Promise<HandlerResponse> => {
        if (!client) {
            return createMissingTwitterApiKeyResponse('followUser');
        }
    
        try {
            const userId = await client.v2.me().then((response: any) => response.data.id);
            const targetUser = await client.v2.userByUsername(username);
            
            if (!targetUser.data) {
                throw new Error(`User not found: ${username}`);
            }
            
            await client.v2.follow(userId, targetUser.data.id);
            return createResponse(`Successfully followed user: ${username}`);
        } catch (error) {
            if (error instanceof Error) {
                throw new Error(formatTwitterError(error, 'following user'));
            }
            throw error;
        }
    };
  • src/tools.ts:253-262 (registration)
    The tool registration definition in the TOOLS object, including description and input schema for the MCP server.
    followUser: {
        description: 'Follow a user by their username',
        inputSchema: {
            type: 'object',
            properties: {
                username: { type: 'string', description: 'The username of the user to follow' }
            },
            required: ['username'],
        },
    },
  • TypeScript interface defining the input arguments for the followUser tool.
    export interface FollowUserArgs {
        username: string;
    }
  • Runtime validation function that asserts the arguments match FollowUserArgs interface.
    export function assertFollowUserArgs(args: unknown): asserts args is FollowUserArgs {
        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');
        }
    }
  • src/index.ts:260-263 (registration)
    The switch case in the main CallToolRequestSchema handler that routes 'followUser' calls to the handleFollowUser function.
    case 'followUser': {
        const { username } = request.params.arguments as { username: string };
        response = await handleFollowUser(client, { username });
        break;
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 disclosing behavioral traits. It doesn't mention whether this requires authentication, has rate limits, affects user relationships, or what the expected outcome is (e.g., success confirmation or error handling). This is inadequate for a mutation tool with zero annotation coverage.

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, front-loading the core action. It's appropriately sized for a simple 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?

Given the tool's complexity (a mutation with no annotations or output schema), the description is incomplete. It doesn't cover behavioral aspects like authentication needs, rate limits, or what happens upon execution, leaving significant gaps for an AI agent to operate 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?

The description implies the 'username' parameter but doesn't add meaning beyond the schema's 100% coverage, which already documents it as 'The username of the user to follow'. With high schema coverage, the baseline is 3, and the description doesn't compensate with extra details like format examples or constraints.

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 ('Follow') and target resource ('a user by their username'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'addUserToList' or 'muteUser' which also involve user interactions, so it misses the highest score.

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 like 'addUserToList' or 'followUser' versus 'unfollowUser'. It lacks context about prerequisites (e.g., authentication needs) or exclusions, leaving the agent with 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