Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getTweetsByIds

Fetch multiple tweets using their unique IDs to retrieve specific content, supporting up to 100 IDs per request with optional additional fields.

Instructions

Get multiple tweets by their IDs

Input Schema

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

Implementation Reference

  • src/tools.ts:186-208 (registration)
    Registration of the 'getTweetsByIds' tool including description and input schema definition, used by the MCP server for tool listing.
    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 function for GetTweetsByIdsArgs input parameters, ensuring tweetIds is a non-empty array of up to 100 strings and tweetFields is optional array of strings.
    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 of all tools from TOOLS object, including getTweetsByIds, for the ListTools request.
    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