Skip to main content
Glama

post_tweet

Post tweets to X (Twitter) with text content and optional replies using the X MCP Server's API integration.

Instructions

Post a tweet to X (Twitter)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text content of the tweet (max 280 characters)
reply_to_tweet_idNoOptional: ID of the tweet to reply to

Implementation Reference

  • The handler function that implements the post_tweet tool logic. It validates the input arguments, ensures the Twitter client is initialized, posts the tweet using TwitterApi.v2.tweet(), handles replies, and returns a success message with the tweet ID or throws an error.
    private async postTweet(args: any) {
      if (!this.twitterClient) {
        throw new Error("Twitter client not initialized");
      }
    
      const { text, reply_to_tweet_id } = args;
    
      if (!text || typeof text !== "string") {
        throw new Error("Text is required and must be a string");
      }
    
      if (text.length > 280) {
        throw new Error("Tweet text cannot exceed 280 characters");
      }
    
      try {
        const tweetOptions: any = { text };
    
        if (reply_to_tweet_id) {
          tweetOptions.reply = { in_reply_to_tweet_id: reply_to_tweet_id };
        }
    
        const tweet = await this.twitterClient.v2.tweet(tweetOptions);
    
        return {
          content: [
            {
              type: "text",
              text: `Tweet posted successfully! Tweet ID: ${tweet.data.id}`,
            },
          ],
        };
      } catch (error) {
        // Provide more detailed error information
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to post tweet: ${errorMessage}`);
      }
    }
  • The tool specification for post_tweet, including its name, description, and input schema defining required 'text' field and optional 'reply_to_tweet_id'.
    {
      name: "post_tweet",
      description: "Post a tweet to X (Twitter)",
      inputSchema: {
        type: "object",
        properties: {
          text: {
            type: "string",
            description: "The text content of the tweet (max 280 characters)",
          },
          reply_to_tweet_id: {
            type: "string",
            description: "Optional: ID of the tweet to reply to",
          },
        },
        required: ["text"],
      },
    },
  • src/index.ts:109-110 (registration)
    The dispatch case in the CallToolRequestSchema handler that registers and routes calls to the post_tweet tool to its handler method.
    case "post_tweet":
      return await this.postTweet(args);
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions posting to X (Twitter) but doesn't disclose critical traits like authentication requirements, rate limits, whether it's a destructive write operation, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

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 a single, efficient sentence that states the core functionality without unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse quickly.

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 the tool's complexity (a write operation to a social media platform), lack of annotations, and absence of an output schema, the description is insufficient. It doesn't cover behavioral aspects, error conditions, or return values, leaving significant gaps for the agent to navigate.

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?

Schema description coverage is 100%, so the input schema already documents both parameters ('text' and 'reply_to_tweet_id') with their types and constraints. The description adds no parameter-specific information beyond what's in the schema, resulting in a baseline score of 3.

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 action ('Post') and target resource ('a tweet to X (Twitter)'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_user_timeline' or 'search_tweets' beyond the obvious action difference, missing explicit sibling comparison.

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?

No guidance is provided on when to use this tool versus alternatives. The description lacks context about prerequisites (e.g., authentication), use cases (e.g., broadcasting vs. replying), or exclusions, leaving the agent to infer usage from the tool name alone.

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

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/krishna-paulraj/x-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server