Skip to main content
Glama
rafaljanicki

X (Twitter) MCP server

by rafaljanicki

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

Implementation Reference

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

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