get_user_following
Retrieve a list of users followed by a specific account on X (Twitter) using the provided user ID, count, and cursor parameters for pagination.
Instructions
Retrieves users the given user is following
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | ||
| cursor | No | ||
| user_id | Yes |
Implementation Reference
- src/x_twitter_mcp/server.py:143-155 (handler)The main handler function that retrieves the list of users a given user is following using the Tweepy Twitter API v2 client.get_users_following method. Includes rate limiting check and pagination support.async def get_user_following(user_id: str, count: Optional[int] = 100, cursor: Optional[str] = None) -> List[Dict]: """Retrieves a list of users whom the given user is following. Args: user_id (str): The user ID whose following list is to be retrieved. count (Optional[int]): The number of users to retrieve per page. Default is 100. Max is 100 for V2 API. cursor (Optional[str]): A pagination token for fetching the next set of results. """ if not check_rate_limit("follow_actions"): raise Exception("Follow action rate limit exceeded") client, _ = initialize_twitter_clients() following = client.get_users_following(id=user_id, max_results=count, pagination_token=cursor, user_fields=["id", "name", "username"]) return [user.data for user in following.data]
- src/x_twitter_mcp/server.py:142-142 (registration)Registers the 'get_user_following' tool with FastMCP server using the @server.tool decorator, specifying the name and description.@server.tool(name="get_user_following", description="Retrieves users the given user is following")
- src/x_twitter_mcp/server.py:143-143 (schema)Type annotations defining the input schema (user_id: str, count: Optional[int], cursor: Optional[str]) and output (List[Dict]) for the tool.async def get_user_following(user_id: str, count: Optional[int] = 100, cursor: Optional[str] = None) -> List[Dict]: