Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

replyToTweet

Post a response to a specific tweet on Twitter using the tweet ID and reply text.

Instructions

Reply to a tweet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tweetIdYesThe ID of the tweet to reply to
textYesThe text of the reply

Implementation Reference

  • Core handler function that executes the replyToTweet tool by calling Twitter API v2.reply with the provided tweetId and text.
    export async function handleReplyToTweet(
        client: TwitterClient | null,
        { tweetId, text }: { tweetId: string; text: string }
    ): Promise<HandlerResponse> {
        if (!client) {
            return createMissingTwitterApiKeyResponse('Reply to Tweet');
        }
    
        try {
            const tweet = await client.v2.reply(text, tweetId);
            return createResponse(`Successfully replied to tweet: ${tweet.data.id}`);
        } catch (error) {
            if (error instanceof Error) {
                throw new Error(formatTwitterError(error, 'replying to tweet'));
            }
            throw new Error('Failed to reply to tweet: Unknown error occurred');
        }
    }
  • MCP tool schema definition for replyToTweet, specifying input parameters tweetId and text.
    replyToTweet: {
        description: 'Reply to a tweet',
        inputSchema: {
            type: 'object',
            properties: {
                tweetId: {
                    type: 'string',
                    description: 'The ID of the tweet to reply to'
                },
                text: {
                    type: 'string',
                    description: 'The text of the reply'
                }
            },
            required: ['tweetId', 'text']
        }
    },
  • src/index.ts:172-175 (registration)
    Tool call registration and dispatch in the MCP server's CallToolRequestHandler switch case.
    case 'replyToTweet': {
        const { tweetId, text } = request.params.arguments as { tweetId: string; text: string };
        response = await handleReplyToTweet(client, { tweetId, text });
        break;
  • TypeScript interface defining the input arguments for replyToTweet.
    export interface ReplyToTweetArgs {
        tweetId: string;
        text: string;
    }

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

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