Skip to main content
Glama
rafaljanicki

X (Twitter) MCP server

by rafaljanicki

favorite_tweet

Mark a tweet as a favorite on X (Twitter) by providing its unique tweet ID using this tool.

Instructions

Favorites a tweet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tweet_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'favorite_tweet' tool. It performs rate limiting check, initializes the Twitter API client, calls the Tweepy client's like method to favorite the specified tweet, and returns the result.
    @server.tool(name="favorite_tweet", description="Favorites a tweet")
    async def favorite_tweet(tweet_id: str) -> Dict:
        """Favorites a tweet.
    
        Args:
            tweet_id (str): The ID of the tweet to favorite (like).
        """
        if not check_rate_limit("like_actions"):
            raise Exception("Like action rate limit exceeded")
        client, _ = initialize_twitter_clients()
        result = client.like(tweet_id=tweet_id)
        return {"tweet_id": tweet_id, "liked": result.data["liked"]}
  • The @server.tool decorator registers the 'favorite_tweet' function as an MCP tool.
    @server.tool(name="favorite_tweet", description="Favorites a tweet")
  • Helper function to lazily initialize the Tweepy Twitter API v2 Client and v1.1 API, used by favorite_tweet.
    def initialize_twitter_clients() -> tuple[tweepy.Client, tweepy.API]:
        """Initialize Twitter API clients on-demand."""
        global _twitter_client, _twitter_v1_api
    
        if _twitter_client is not None and _twitter_v1_api is not None:
            return _twitter_client, _twitter_v1_api
    
        # Verify required environment variables
        required_env_vars = [
            "TWITTER_API_KEY",
            "TWITTER_API_SECRET",
            "TWITTER_ACCESS_TOKEN",
            "TWITTER_ACCESS_TOKEN_SECRET",
            "TWITTER_BEARER_TOKEN",
        ]
        for var in required_env_vars:
            if not os.getenv(var):
                raise EnvironmentError(f"Missing required environment variable: {var}")
    
        # Initialize v2 API client
        _twitter_client = tweepy.Client(
            consumer_key=os.getenv("TWITTER_API_KEY"),
            consumer_secret=os.getenv("TWITTER_API_SECRET"),
            access_token=os.getenv("TWITTER_ACCESS_TOKEN"),
            access_token_secret=os.getenv("TWITTER_ACCESS_TOKEN_SECRET"),
            bearer_token=os.getenv("TWITTER_BEARER_TOKEN")
        )
    
        # Initialize v1.1 API for media uploads and other unsupported v2 endpoints
        auth = tweepy.OAuth1UserHandler(
            consumer_key=os.getenv("TWITTER_API_KEY"),
            consumer_secret=os.getenv("TWITTER_API_SECRET"),
            access_token=os.getenv("TWITTER_ACCESS_TOKEN"),
            access_token_secret=os.getenv("TWITTER_ACCESS_TOKEN_SECRET")
        )
        _twitter_v1_api = tweepy.API(auth)
    
        return _twitter_client, _twitter_v1_api
  • Helper function for rate limiting checks, specifically used for 'like_actions' in favorite_tweet.
    def check_rate_limit(action_type: str) -> bool:
        """Check if the action is within rate limits."""
        config = RATE_LIMITS.get(action_type)
        if not config:
            return True  # No limit defined
        counter = rate_limit_counters[action_type]
        now = datetime.now()
        if now >= counter["reset_time"]:
            counter["count"] = 0
            counter["reset_time"] = now + config["window"]
        if counter["count"] >= config["limit"]:
            return False
        counter["count"] += 1
        return True
  • Input schema defined by function signature (tweet_id: str) and docstring, output Dict.
    async def favorite_tweet(tweet_id: str) -> Dict:
        """Favorites a tweet.
    
        Args:
            tweet_id (str): The ID of the tweet to favorite (like).
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Favorites a tweet' implies a write/mutation operation, but it doesn't disclose any behavioral traits such as authentication requirements, rate limits, side effects, error conditions, or what happens if the tweet is already favorited. This leaves critical behavioral aspects undocumented.

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

Conciseness4/5

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

The description is extremely concise at just two words, which is appropriate for a simple action. It's front-loaded with the core purpose, though it could benefit from additional context. There's no wasted verbiage, but it may be overly terse given the lack of other documentation.

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

Completeness2/5

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

Given that this is a mutation tool with no annotations, 0% schema description coverage, and only basic output schema (implied by 'has_output_schema: true'), the description is incomplete. It doesn't address behavioral aspects, parameter meaning, or usage context, making it inadequate for safe and effective tool invocation despite the output schema potentially covering return values.

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

Parameters2/5

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

The description provides no information about the 'tweet_id' parameter beyond what's in the schema (which has 0% description coverage). It doesn't explain what a tweet ID is, where to find it, its format, or any constraints. With low schema coverage, the description fails to compensate, leaving parameter meaning unclear.

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

Purpose2/5

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

The description 'Favorites a tweet' is a tautology that essentially restates the tool name with minimal additional information. It specifies the verb ('favorites') and resource ('a tweet'), but doesn't distinguish it from sibling tools like 'bookmark_tweet' or 'unfavorite_tweet' beyond the basic action implied by the name itself.

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

Usage Guidelines1/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. It doesn't mention when to use 'favorite_tweet' instead of 'bookmark_tweet', when to use it versus 'unfavorite_tweet', or any prerequisites or context for its use. The agent must infer usage entirely from the tool name and sibling list.

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