get_user_by_screen_name
Retrieve user details from the X (Twitter) MCP server by providing the user's screen name. Simplifies user data lookup for integration or analysis purposes.
Instructions
Fetches a user by screen name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| screen_name | Yes |
Implementation Reference
- src/x_twitter_mcp/server.py:105-105 (registration)Registers the 'get_user_by_screen_name' tool with the FastMCP server using the @server.tool decorator, specifying the name and description.@server.tool(name="get_user_by_screen_name", description="Fetches a user by screen name")
- src/x_twitter_mcp/server.py:106-114 (handler)The handler function that initializes the Twitter API client and calls client.get_user(username=screen_name) to fetch and return the user data as a dictionary.async def get_user_by_screen_name(screen_name: str) -> Dict: """Fetches user by screen name. Args: screen_name (str): The screen name/username of the user. """ client, _ = initialize_twitter_clients() user = client.get_user(username=screen_name, user_fields=["id", "name", "username", "profile_image_url", "description"]) return user.data