Skip to main content
Glama
rafaljanicki

X (Twitter) MCP server

by rafaljanicki

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
NameRequiredDescriptionDefault
categoryNo
countNo

Implementation Reference

  • 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]
  • Registration of the 'get_trends' tool using FastMCP @server.tool decorator.
    @server.tool(name="get_trends", description="Retrieves trending topics on Twitter")
  • 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]:

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