historicalTweetSearch
Search historical tweets beyond standard API limitations using date ranges and queries to analyze past Twitter conversations and trends.
Instructions
Search historical tweets beyond standard API limitations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query string | |
| dateRange | Yes | Date range for historical search | |
| maxResults | No | Maximum number of results (default: 50, max: 200) |
Implementation Reference
- Core handler function executing the historical tweet search logic using socialClient.searchTweets with query, dateRange, and maxResults. Handles errors and formats response with tweet list.export const handleHistoricalTweetSearch: SocialDataHandler<HistoricalSearchArgs> = async ( _client: any, { query, dateRange, maxResults = 50 }: HistoricalSearchArgs ) => { try { const socialClient = getSocialDataClient(); if (!socialClient) { return createMissingApiKeyResponse('Historical Tweet Search'); } const result = await socialClient.searchTweets({ query, maxResults, startTime: dateRange.start, endTime: dateRange.end }); if (!result.data || result.data.length === 0) { return createSocialDataResponse( `No historical tweets found for "${query}" between ${dateRange.start} and ${dateRange.end}` ); } return createSocialDataResponse( formatTweetList( result.data, `Historical Search Results for "${query}" (${dateRange.start} to ${dateRange.end})` ) ); } catch (error) { throw new Error(formatSocialDataError(error as Error, 'historical tweet search')); } };
- src/socialdata-tools.ts:41-74 (schema)Input schema and description for the historicalTweetSearch tool, defining query, dateRange (start/end ISO strings), and optional maxResults.historicalTweetSearch: { description: 'Search historical tweets beyond standard API limitations', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query string' }, dateRange: { type: 'object', properties: { start: { type: 'string', description: 'Start date in ISO 8601 format' }, end: { type: 'string', description: 'End date in ISO 8601 format' } }, required: ['start', 'end'], description: 'Date range for historical search' }, maxResults: { type: 'number', description: 'Maximum number of results (default: 50, max: 200)', minimum: 1, maximum: 200 } }, required: ['query', 'dateRange'] } },
- src/tools.ts:736-738 (registration)Registers historicalTweetSearch (and other SocialData tools) in the main TOOLS export for MCP ListToolsRequest by spreading SOCIALDATA_TOOLS.// SocialData.tools enhanced research and analytics ...SOCIALDATA_TOOLS };
- src/index.ts:431-434 (registration)Dispatches tool calls to the handleHistoricalTweetSearch function in the MCP server's CallToolRequest handler switch statement.case 'historicalTweetSearch': { const args = request.params.arguments as any; response = await handleHistoricalTweetSearch(client, args); break;