get_trends
Fetch trending topics on Twitter by category or count using the MCP server tool. Simplify trend analysis and stay updated with relevant social media data.
Instructions
Retrieves trending topics on Twitter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | ||
| count | No |
Implementation Reference
- src/x_twitter_mcp/server.py:393-407 (handler)Handler function for the 'get_trends' tool. Fetches worldwide Twitter trends using v1.1 API, optionally filters by category and limits count. Registered via @server.tool decorator.@server.tool(name="get_trends", description="Retrieves trending topics on Twitter") async def get_trends(category: Optional[str] = None, count: Optional[int] = 50) -> List[Dict]: """Fetches trending topics (uses Twitter API v1.1 as v2 trends require specific location WOEID). Args: category (Optional[str]): Filter trends by category (e.g., 'Sports', 'News'). Currently not directly supported by `get_place_trends` for worldwide, will filter locally if provided. count (Optional[int]): Number of trending topics to retrieve. Default 50. Max 50 (as per Twitter API v1.1 default). """ _, v1_api = initialize_twitter_clients() # Twitter API v2 trends require a location; use v1.1 for trends trends = v1_api.get_place_trends(id=1) # WOEID 1 = Worldwide trends = trends[0]["trends"] if category: trends = [t for t in trends if t.get("category") == category] return trends[:count]
- src/x_twitter_mcp/server.py:393-393 (registration)Registration of the 'get_trends' tool using FastMCP @server.tool decorator.@server.tool(name="get_trends", description="Retrieves trending topics on Twitter")
- src/x_twitter_mcp/server.py:394-394 (schema)Input schema defined by function parameters: category (Optional[str]), count (Optional[int]=50); Output: List[Dict].async def get_trends(category: Optional[str] = None, count: Optional[int] = 50) -> List[Dict]: