Skip to main content
Glama
EnesCinr

Twitter MCP Server

post_tweet

Publish a tweet on Twitter, with an optional reply to an existing tweet.

Instructions

Post a new tweet to Twitter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe content of your tweet
reply_to_tweet_idNoOptional: ID of the tweet to reply to

Implementation Reference

  • The main handler function for the 'post_tweet' tool. It validates args using PostTweetSchema, calls the Twitter client, and returns a success response with the tweet URL.
    private async handlePostTweet(args: unknown) {
      const result = PostTweetSchema.safeParse(args);
      if (!result.success) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Invalid parameters: ${result.error.message}`
        );
      }
    
      const tweet = await this.client.postTweet(result.data.text, result.data.reply_to_tweet_id);
      return {
        content: [{
          type: 'text',
          text: `Tweet posted successfully!\nURL: https://twitter.com/status/${tweet.id}`
        }] as TextContent[]
      };
    }
  • The underlying Twitter API client method that actually posts the tweet via the twitter-api-v2 library. Handles rate limiting, optional reply-to, and returns the posted tweet's id and text.
    async postTweet(text: string, replyToTweetId?: string): Promise<PostedTweet> {
      try {
        const endpoint = 'tweets/create';
        await this.checkRateLimit(endpoint);
    
        const tweetOptions: any = { text };
        if (replyToTweetId) {
          tweetOptions.reply = { in_reply_to_tweet_id: replyToTweetId };
        }
    
        const response = await this.client.v2.tweet(tweetOptions);
        
        console.error(`Tweet posted successfully with ID: ${response.data.id}${replyToTweetId ? ` (reply to ${replyToTweetId})` : ''}`);
        
        return {
          id: response.data.id,
          text: response.data.text
        };
      } catch (error) {
        this.handleApiError(error);
      }
    }
  • Zod schema defining input validation for post_tweet: requires 'text' (1-280 chars) and optional 'reply_to_tweet_id' string.
    export const PostTweetSchema = z.object({
        text: z.string()
            .min(1, 'Tweet text cannot be empty')
            .max(280, 'Tweet cannot exceed 280 characters'),
        reply_to_tweet_id: z.string().optional()
    });
  • src/index.ts:67-84 (registration)
    Registration of the 'post_tweet' tool in the ListToolsRequestSchema handler, defining its name, description, and inputSchema for MCP discovery.
      name: 'post_tweet',
      description: 'Post a new tweet to Twitter',
      inputSchema: {
        type: 'object',
        properties: {
          text: {
            type: 'string',
            description: 'The content of your tweet',
            maxLength: 280
          },
          reply_to_tweet_id: {
            type: 'string',
            description: 'Optional: ID of the tweet to reply to'
          }
        },
        required: ['text']
      }
    } as Tool,
  • src/index.ts:115-116 (registration)
    Dispatch routing for the 'post_tweet' tool name in the CallToolRequestSchema handler, directing to handlePostTweet.
    case 'post_tweet':
      return await this.handlePostTweet(args);
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 disclosure. However, it only states the action without detailing any behavioral traits (e.g., authentication requirements, potential errors, rate limits, or that tweets are public). For a mutation tool, this is insufficient.

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 a single sentence, with no superfluous words. It directly communicates the tool's purpose without any waste.

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 the tool's simplicity (2 parameters, no output schema), the description is minimally adequate but lacks details such as expected return value (e.g., tweet ID) or any error conditions. It covers the basic action but leaves gaps for practical use.

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 input schema has 100% description coverage, so the schema already details both parameters. The description adds no extra meaning beyond what the schema provides, so it meets the baseline of 3.

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

Purpose5/5

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

The description clearly states 'Post a new tweet to Twitter', which is a specific verb ('post') and resource ('tweet'). It distinguishes itself from the sibling tool 'search_tweets' by focusing on creation rather than retrieval.

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 usage guidance is provided. The description does not specify when to use this tool versus the sibling 'search_tweets', nor does it mention any prerequisites, limitations, or contextual conditions for posting a tweet.

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/EnesCinr/twitter-mcp'

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