Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getConversationTree

Map complete Twitter conversation structures by analyzing replies and quotes to visualize discussion threads and relationships between tweets.

Instructions

Map complete conversation structure including replies and quotes

Input Schema

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

Implementation Reference

  • Main handler function executing the getConversationTree tool: fetches replies and quotes using SocialData client, builds conversation tree with metrics, formats and returns 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 definition for the getConversationTree tool, specifying parameters tweetId (required), maxDepth, includeQuotes.
    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']
        }
    },
  • TypeScript interface defining the input arguments for getConversationTree handler.
    export interface ConversationTreeArgs {
        tweetId: string;
        maxDepth?: number;
        includeQuotes?: boolean;
    }
  • src/tools.ts:737-737 (registration)
    Registration of getConversationTree tool schema by spreading SOCIALDATA_TOOLS into the main TOOLS export used by MCP ListTools.
    ...SOCIALDATA_TOOLS
  • src/index.ts:462-465 (registration)
    Dispatch/registration in MCP CallToolRequestHandler switch case, calling the handler for getConversationTree.
    case 'getConversationTree': {
        const args = request.params.arguments as any;
        response = await handleGetConversationTree(client, args);
        break;
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions mapping 'complete conversation structure' but does not disclose behavioral traits such as rate limits, authentication needs, data format returned, or potential limitations (e.g., depth constraints implied by maxDepth). This leaves gaps for a tool with 3 parameters and no output schema.

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 with zero waste. It is front-loaded with the core purpose and includes key details ('replies and quotes') without unnecessary elaboration, making it easy to parse.

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 3 parameters, 100% schema coverage, and no output schema, the description is minimally adequate. It states what the tool does but lacks details on behavioral aspects (e.g., return format, error handling) and usage context, which are important for a mapping tool with no annotations or output schema.

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 schema already documents all parameters (tweetId, maxDepth, includeQuotes). The description adds no additional meaning beyond the schema, such as explaining how 'maxDepth' affects mapping or what 'complete conversation structure' entails. Baseline 3 is appropriate as the schema does the heavy lifting.

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 tool's purpose with a specific verb ('Map') and resource ('complete conversation structure'), including what it maps ('replies and quotes'). It distinguishes from sibling tools like 'getConversation' (likely simpler) and 'getFullThread' (different scope), though not explicitly named.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for mapping conversation structures, but does not explicitly state when to use this tool versus alternatives like 'getConversation' or 'getFullThread'. It provides some context (e.g., 'including replies and quotes') but lacks clear exclusions or prerequisites.

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

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