Skip to main content
Glama
rafaljanicki

X (Twitter) MCP server

by rafaljanicki

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
NameRequiredDescriptionDefault
countNo
cursorNo
user_idYes

Implementation Reference

  • 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]
  • 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")
  • 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]:

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/rafaljanicki/x-twitter-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server