Skip to main content
Glama
rafaljanicki

X (Twitter) MCP server

by rafaljanicki

get_user_subscriptions

Retrieve a list of users a specific account is following on X (Twitter) by providing the user ID, count, and cursor for pagination.

Instructions

Retrieves a list of users to which the specified user is subscribed (uses following as proxy)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNo
cursorNo
user_idYes

Implementation Reference

  • The main handler function for the 'get_user_subscriptions' tool. It checks rate limits, initializes the Twitter client, fetches the user's following list (used as proxy for subscriptions), and returns the list of user dicts.
    async def get_user_subscriptions(user_id: str, count: Optional[int] = 100, cursor: Optional[str] = None) -> List[Dict]: """Retrieves a list of subscribed users. (Uses 'following' as a proxy as Twitter API v2 doesn't have a direct 'subscriptions' endpoint). Args: user_id (str): The user ID whose subscriptions (following list) are to be retrieved. count (Optional[int]): The number of users to retrieve per page. Default is 100. 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() # Use following as proxy for subscriptions subscriptions = client.get_users_following(id=user_id, max_results=count, pagination_token=cursor, user_fields=["id", "name", "username"]) return [user.data for user in subscriptions.data]
  • Registers the 'get_user_subscriptions' tool with FastMCP server using the @server.tool decorator, specifying the name and description.
    @server.tool(name="get_user_subscriptions", description="Retrieves a list of users to which the specified user is subscribed (uses following as proxy)")
  • Input schema defined by function parameters: user_id (str), count (Optional[int]=100), cursor (Optional[str]=None). Output: List[Dict].
    async def get_user_subscriptions(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