Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getConversation

Retrieve complete conversation history from Twitter by providing a conversation ID, enabling analysis of message exchanges and context.

Instructions

Get full conversation history for a specific conversation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversationIdYesThe ID of the conversation to retrieve
maxResultsNoMaximum number of messages to return (default: 100, max: 100)
paginationTokenNoPagination token for retrieving next page of results
dmEventFieldsNoFields to include in the DM event objects

Implementation Reference

  • The handler function that implements the getConversation tool logic. It uses the Twitter v2 API to list DM events, filters by conversationId, and returns the conversation history.
    export const handleGetConversation: TwitterHandler<GetConversationArgs> = async (
        client: TwitterClient | null,
        { conversationId, maxResults = 100, paginationToken, dmEventFields }: GetConversationArgs
    ): Promise<HandlerResponse> => {
        if (!client) {
            return createMissingTwitterApiKeyResponse('getConversation');
        }
        try {
            const options: any = {
                max_results: Math.min(maxResults, 100)
            };
    
            if (paginationToken) {
                options.pagination_token = paginationToken;
            }
    
            if (dmEventFields && dmEventFields.length > 0) {
                options['dm_event.fields'] = dmEventFields.join(',');
            } else {
                options['dm_event.fields'] = 'id,text,created_at,sender_id,dm_conversation_id,referenced_tweet,attachments';
            }
    
            // Get conversation messages using the conversation ID endpoint
            // Note: This would typically use a specific conversation endpoint
            // For now, we'll use the general listDmEvents and filter by conversation ID
            const conversation = await client.v2.listDmEvents({
                ...options,
                // Note: The actual API might have a different method for getting conversation-specific events
            });
    
            if (!conversation.data || !Array.isArray(conversation.data) || conversation.data.length === 0) {
                return createResponse(`No messages found in conversation ${conversationId}.`);
            }
    
            // Filter by conversation ID if needed (depending on API implementation)
            const filteredMessages = conversation.data.filter((event: any) => 
                event.dm_conversation_id === conversationId
            );
    
            const responseData = {
                conversationId,
                messages: filteredMessages.length > 0 ? filteredMessages : conversation.data,
                meta: conversation.meta
            };
    
            return createResponse(`Retrieved ${responseData.messages.length} messages from conversation ${conversationId}: ${JSON.stringify(responseData, null, 2)}`);
        } catch (error) {
            if (error instanceof Error) {
                if (error.message.includes('404')) {
                    throw new Error(`Failed to get conversation: Conversation ${conversationId} not found.`);
                }
                throw new Error(formatTwitterError(error, 'getting conversation'));
            }
            throw error;
        }
    };
  • The tool schema defining the description and input parameters for getConversation, used for MCP tool registration.
    getConversation: {
        description: 'Get full conversation history for a specific conversation',
        inputSchema: {
            type: 'object',
            properties: {
                conversationId: { 
                    type: 'string', 
                    description: 'The ID of the conversation to retrieve' 
                },
                maxResults: { 
                    type: 'number', 
                    description: 'Maximum number of messages to return (default: 100, max: 100)',
                    minimum: 1,
                    maximum: 100
                },
                paginationToken: { 
                    type: 'string', 
                    description: 'Pagination token for retrieving next page of results' 
                },
                dmEventFields: { 
                    type: 'array', 
                    items: { 
                        type: 'string',
                        enum: ['id', 'text', 'created_at', 'sender_id', 'dm_conversation_id', 'referenced_tweet', 'attachments']
                    },
                    description: 'Fields to include in the DM event objects' 
                }
            },
            required: ['conversationId']
        }
    },
  • src/index.ts:358-366 (registration)
    The dispatch case in the MCP server's CallToolRequest handler that routes 'getConversation' calls to the handleGetConversation function.
    case 'getConversation': {
        const { conversationId, maxResults, paginationToken, dmEventFields } = request.params.arguments as {
            conversationId: string;
            maxResults?: number;
            paginationToken?: string;
            dmEventFields?: string[];
        };
        response = await handleGetConversation(client, { conversationId, maxResults, paginationToken, dmEventFields });
        break;
  • TypeScript interface defining the input arguments for the getConversation handler.
    export interface GetConversationArgs {
        conversationId: string;
        maxResults?: number;
        paginationToken?: string;
        dmEventFields?: string[];
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions retrieving 'full conversation history' but doesn't clarify what 'full' means, whether there are rate limits, authentication requirements, or how pagination works. The description lacks important behavioral context that would help an agent use this tool effectively.

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, clear sentence that communicates the core purpose efficiently. It's front-loaded with the essential information and contains no unnecessary words or redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what constitutes 'full conversation history,' how pagination works with maxResults and paginationToken, or what the return format looks like. The description leaves too many operational questions unanswered.

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 thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema - it doesn't explain relationships between parameters or provide usage examples. Baseline 3 is appropriate when 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 action ('Get full conversation history') and resource ('for a specific conversation'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like getConversationTree or getDirectMessageEvents, but the specificity of 'full conversation history' provides reasonable distinction.

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?

The description provides no guidance on when to use this tool versus alternatives like getConversationTree, getDirectMessageEvents, or getFullThread. It simply states what the tool does without context about appropriate use cases or comparisons to sibling tools.

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