get_user_by_id
Retrieve user details from the X (Twitter) MCP server using a unique user ID, enabling quick access to specific user information.
Instructions
Fetches a user by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes |
Implementation Reference
- src/x_twitter_mcp/server.py:117-125 (handler)The main handler function for the 'get_user_by_id' tool. It initializes the Twitter client and calls client.get_user to fetch user details by ID, returning the user data.async def get_user_by_id(user_id: str) -> Dict: """Fetches user by ID. Args: user_id (str): The ID of the user to look up. """ client, _ = initialize_twitter_clients() user = client.get_user(id=user_id, user_fields=["id", "name", "username", "profile_image_url", "description"]) return user.data
- src/x_twitter_mcp/server.py:116-116 (registration)The FastMCP decorator that registers the 'get_user_by_id' tool with its name and description.@server.tool(name="get_user_by_id", description="Fetches a user by ID")