Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

followUser

Follow a Twitter user by their username using this tool, enabling direct interactions within the Twitter MCP Server for enhanced social engagement.

Instructions

Follow a user by their username

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the user to follow

Implementation Reference

  • Core implementation of the followUser tool. Retrieves the authenticated user's ID, looks up the target user by username, and uses the Twitter API v2 follow method to establish the follow relationship.
    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; } };
  • MCP tool schema definition including description and input validation schema requiring a 'username' string parameter.
    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'], }, },
  • src/index.ts:260-263 (registration)
    Registration and dispatch logic in the main MCP server request handler that routes 'followUser' tool calls to the specific handleFollowUser function.
    case 'followUser': { const { username } = request.params.arguments as { username: string }; response = await handleFollowUser(client, { username }); break;
  • TypeScript interface defining the expected arguments for the followUser handler (username: string).
    export interface FollowUserArgs { username: string; }
  • src/index.ts:33-39 (registration)
    Import statement registering the handleFollowUser function for use in the MCP tool dispatch switch.
    handleGetUserInfo, handleFollowUser, handleUnfollowUser, handleGetFollowers, handleGetFollowing, handleGetAuthenticatedUser } from './handlers/user.handlers.js';

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