trendingTopicsSearch
Discover trending topics and popular content on Twitter for analysis by specifying location, timeframe, and quantity to monitor social media conversations.
Instructions
Get trending topics and popular content for analysis
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | No | Location for trending topics (default: "worldwide") | |
| timeframe | No | Timeframe for trending analysis (default: "hourly") | |
| count | No | Number of trending topics to return (default: 10, max: 50) |
Implementation Reference
- The core handler function that implements the trendingTopicsSearch tool logic by querying recent popular tweets based on location, timeframe, and count parameters.export const handleTrendingTopicsSearch: SocialDataHandler<TrendingTopicsArgs> = async ( _client: any, { location = 'worldwide', timeframe = 'hourly', count = 10 }: TrendingTopicsArgs ) => { try { const socialClient = getSocialDataClient(); if (!socialClient) { return createMissingApiKeyResponse('Trending Topics Search'); } // For trending topics, we'll search for popular recent content const query = `filter:popular -filter:replies`; const now = new Date(); const timeOffset = timeframe === 'hourly' ? 1 : timeframe === 'daily' ? 24 : 168; // hours const startTime = new Date(now.getTime() - timeOffset * 60 * 60 * 1000).toISOString(); const result = await socialClient.searchTweets({ query, maxResults: count, startTime, endTime: now.toISOString() }); if (!result.data || result.data.length === 0) { return createSocialDataResponse(`No trending topics found for ${location} (${timeframe})`); } return createSocialDataResponse( formatTweetList(result.data, `Trending Topics - ${location} (${timeframe})`) ); } catch (error) { throw new Error(formatSocialDataError(error as Error, 'trending topics search')); } };
- src/socialdata-tools.ts:76-99 (schema)JSON schema definition for the trendingTopicsSearch tool input parameters, used for MCP tool registration.trendingTopicsSearch: { description: 'Get trending topics and popular content for analysis', inputSchema: { type: 'object', properties: { location: { type: 'string', description: 'Location for trending topics (default: "worldwide")' }, timeframe: { type: 'string', enum: ['hourly', 'daily', 'weekly'], description: 'Timeframe for trending analysis (default: "hourly")' }, count: { type: 'number', description: 'Number of trending topics to return (default: 10, max: 50)', minimum: 1, maximum: 50 } }, required: [] } },
- src/index.ts:436-439 (registration)Registration and dispatch of the trendingTopicsSearch tool in the main CallToolRequestSchema switch statement.case 'trendingTopicsSearch': { const args = request.params.arguments as any; response = await handleTrendingTopicsSearch(client, args); break;
- src/types/socialdata.ts:33-37 (schema)TypeScript type definition for TrendingTopicsArgs, matching the tool's input schema.export interface TrendingTopicsArgs { location?: string; timeframe?: 'hourly' | 'daily' | 'weekly'; count?: number; }