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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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]:
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but provides minimal information. It states the tool retrieves trending topics but doesn't mention authentication requirements, rate limits, data freshness, whether results are personalized or global, or what format the output takes. For a tool that accesses external API data, this represents significant gaps in behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 5 words, front-loading the core purpose immediately. There's no wasted language or unnecessary elaboration. While it may be too brief for complete understanding, it achieves maximum efficiency in its current form with every word contributing to the core meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (which reduces the need to describe return values), the description provides the basic purpose but lacks important context. For a tool with no annotations, 0% schema description coverage, and multiple sibling tools, the description should explain more about what 'trending topics' means, how they're determined, and when to use this versus other retrieval tools. It's minimally adequate but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions no parameters at all, while the schema shows two parameters (category and count) with 0% schema description coverage. Since the schema provides parameter names and types but no descriptions, the description should compensate but doesn't. The baseline is 3 because schema coverage is 0%, but the description fails to add any parameter meaning beyond what's in the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Retrieves') and resource ('trending topics on Twitter'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'search_twitter' or 'get_timeline' that also retrieve Twitter content, missing the opportunity to specify this tool focuses specifically on trending topics rather than general search or timeline content.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'search_twitter' and 'get_timeline' that also retrieve Twitter data, there's no indication that this tool should be used specifically for trending topics rather than other types of content retrieval. No prerequisites, exclusions, or comparison to alternatives are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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