Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

replyToTweet

Post a reply to a specific tweet on Twitter by providing the tweet ID and your response text using this Model Context Protocol tool.

Instructions

Reply to a tweet

Input Schema

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

Implementation Reference

  • Core handler function implementing replyToTweet tool logic: checks for Twitter client, calls Twitter API v2.reply(text, tweetId), handles success/error responses.
    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 definition and input schema for replyToTweet, used by the server to expose the tool with description and validation schema.
    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 registration in MCP server's CallToolRequestSchema handler: matches tool name and dispatches to handleReplyToTweet function.
    case 'replyToTweet': { const { tweetId, text } = request.params.arguments as { tweetId: string; text: string }; response = await handleReplyToTweet(client, { tweetId, text }); break;
  • TypeScript interface defining input arguments for replyToTweet handler.
    export interface ReplyToTweetArgs { tweetId: string; text: string; }
  • Runtime type assertion/validator for ReplyToTweetArgs ensuring tweetId and text are strings.
    export function assertReplyToTweetArgs(args: unknown): asserts args is ReplyToTweetArgs { if (typeof args !== 'object' || args === null) { throw new Error('Invalid arguments: expected object'); } if (!('tweetId' in args) || typeof (args as any).tweetId !== 'string') { throw new Error('Invalid arguments: expected tweetId string'); } if (!('text' in args) || typeof (args as any).text !== 'string') { throw new Error('Invalid arguments: expected 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