Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getConversationTree

Analyze and map the full structure of Twitter conversations, including replies and quotes, starting from a root tweet ID, with customizable depth and quote inclusion settings.

Instructions

Map complete conversation structure including replies and quotes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeQuotesNoInclude quote tweets in analysis (default: true)
maxDepthNoMaximum conversation depth to analyze (default: 3)
tweetIdYesThe root tweet ID to map conversation for

Implementation Reference

  • The core implementation of the getConversationTree tool handler. Fetches direct replies and optional quote tweets using SocialData client, builds a structured conversation tree with engagement metrics, and formats the response.
    export const handleGetConversationTree: SocialDataHandler<ConversationTreeArgs> = async ( _client: any, { tweetId, maxDepth = 3, includeQuotes = true }: ConversationTreeArgs ) => { try { const socialClient = getSocialDataClient(); if (!socialClient) { return createMissingApiKeyResponse('Conversation Tree Analysis'); } // Get direct replies const repliesQuery = `to:* ${tweetId}`; const repliesResult = await socialClient.searchTweets({ query: repliesQuery, maxResults: 50 }); // Get quote tweets if requested let quoteTweets: any[] = []; if (includeQuotes) { const quotesQuery = `url:${tweetId} OR ${tweetId}`; const quotesResult = await socialClient.searchTweets({ query: quotesQuery, maxResults: 25 }); quoteTweets = quotesResult.data || []; } const conversationTree = { root_tweet_id: tweetId, max_depth_analyzed: maxDepth, direct_replies: { count: repliesResult.data?.length || 0, tweets: repliesResult.data?.map((tweet: any) => ({ id: tweet.id_str, text: tweet.text?.substring(0, 280), author: tweet.user?.screen_name, created_at: tweet.tweet_created_at, metrics: { likes: tweet.favorite_count || 0, retweets: tweet.retweet_count || 0 } })) || [] }, quote_tweets: { count: quoteTweets.length, tweets: quoteTweets.map((tweet: any) => ({ id: tweet.id_str, text: tweet.text?.substring(0, 280), author: tweet.user?.screen_name, created_at: tweet.tweet_created_at })) }, engagement_summary: { total_interactions: (repliesResult.data?.length || 0) + quoteTweets.length, reply_rate: repliesResult.data?.length || 0, quote_rate: quoteTweets.length } }; return createSocialDataResponse( formatAnalytics(conversationTree, `Conversation Tree for ${tweetId}`) ); } catch (error) { throw new Error(formatSocialDataError(error as Error, 'conversation tree analysis')); } };
  • Input schema and description definition for the getConversationTree tool, specifying parameters: tweetId (required), maxDepth (1-5), includeQuotes (boolean).
    getConversationTree: { description: 'Map complete conversation structure including replies and quotes', inputSchema: { type: 'object', properties: { tweetId: { type: 'string', description: 'The root tweet ID to map conversation for' }, maxDepth: { type: 'number', description: 'Maximum conversation depth to analyze (default: 3)', minimum: 1, maximum: 5 }, includeQuotes: { type: 'boolean', description: 'Include quote tweets in analysis (default: true)' } }, required: ['tweetId'] } },
  • src/tools.ts:736-738 (registration)
    Tool registration: spreads all SOCIALDATA_TOOLS (including getConversationTree schema) into the main TOOLS object exported for MCP ListTools handler.
    // SocialData.tools enhanced research and analytics ...SOCIALDATA_TOOLS };
  • src/index.ts:462-465 (registration)
    Runtime dispatch registration in MCP CallToolRequestHandler: maps 'getConversationTree' tool calls to the handleGetConversationTree function.
    case 'getConversationTree': { const args = request.params.arguments as any; response = await handleGetConversationTree(client, args); break;

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