Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getTweetsByIds

Retrieve multiple tweets by specifying their unique IDs, including optional fields like author details and engagement metrics, through the Twitter MCP Server.

Instructions

Get multiple tweets by their IDs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tweetFieldsNoAdditional tweet fields to include in the response
tweetIdsYesArray of tweet IDs to fetch

Implementation Reference

  • src/tools.ts:186-208 (registration)
    Tool registration and input schema definition for getTweetsByIds, used by MCP server for listing available tools.
    getTweetsByIds: { description: 'Get multiple tweets by their IDs', inputSchema: { type: 'object', properties: { tweetIds: { type: 'array', items: { type: 'string' }, description: 'Array of tweet IDs to fetch', maxItems: 100 }, tweetFields: { type: 'array', items: { type: 'string', enum: ['created_at', 'author_id', 'conversation_id', 'public_metrics', 'entities', 'context_annotations'] }, description: 'Additional tweet fields to include in the response' }, }, required: ['tweetIds'], }, },
  • TypeScript interface defining the input arguments for the getTweetsByIds tool.
    export interface GetTweetsByIdsArgs { tweetIds: string[]; tweetFields?: string[]; }
  • Runtime validation helper function for getTweetsByIds input arguments.
    export function assertGetTweetsByIdsArgs(args: unknown): asserts args is GetTweetsByIdsArgs { if (typeof args !== 'object' || args === null) { throw new Error('Invalid arguments: expected object'); } if (!('tweetIds' in args) || !Array.isArray((args as any).tweetIds)) { throw new Error('Invalid arguments: expected tweetIds array'); } if ((args as any).tweetIds.length === 0) { throw new Error('Invalid arguments: tweetIds array cannot be empty'); } if ((args as any).tweetIds.length > 100) { throw new Error('Invalid arguments: cannot fetch more than 100 tweets at once'); } for (const id of (args as any).tweetIds) { if (typeof id !== 'string') { throw new Error('Invalid arguments: expected tweetIds to be an array of strings'); } } if ('tweetFields' in args) { if (!Array.isArray((args as any).tweetFields)) { throw new Error('Invalid arguments: expected tweetFields to be an array'); } for (const field of (args as any).tweetFields) { if (typeof field !== 'string') { throw new Error('Invalid arguments: expected tweetFields to be an array of strings'); } } } }
  • src/index.ts:104-109 (registration)
    MCP server registration for listing tools, which includes getTweetsByIds from the imported TOOLS object.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.entries(TOOLS).map(([name, tool]) => ({ name, ...tool })) }));

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