get_user_mentions
Retrieve tweets mentioning a specific user by providing their user ID, enabling targeted social media analysis and engagement tracking on the X (Twitter) platform.
Instructions
Get tweets mentioning a specific user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | ||
| cursor | No | ||
| user_id | Yes |
Implementation Reference
- src/x_twitter_mcp/server.py:424-434 (handler)The main handler function that implements the get_user_mentions tool. It initializes the Twitter client and calls get_users_mentions to fetch tweets mentioning the specified user ID, with pagination support.async def get_user_mentions(user_id: str, count: Optional[int] = 100, cursor: Optional[str] = None) -> List[Dict]: """Fetches tweets mentioning a specific user. Args: user_id (str): The ID of the user whose mentions are to be retrieved. count (Optional[int]): Number of mentions to retrieve. Default 100. Min 5, Max 100 for get_users_mentions. cursor (Optional[str]): Pagination token for fetching the next set of results. """ client, _ = initialize_twitter_clients() mentions = client.get_users_mentions(id=user_id, max_results=count, pagination_token=cursor, tweet_fields=["id", "text", "created_at"]) return [tweet.data for tweet in mentions.data]
- src/x_twitter_mcp/server.py:423-423 (registration)Registers the get_user_mentions tool with the FastMCP server using the @server.tool decorator, specifying the name and description.@server.tool(name="get_user_mentions", description="Get tweets mentioning a specific user")