Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

trendingTopicsSearch

Discover trending topics and popular content on Twitter by specifying location, timeframe, and the number of topics to retrieve for analysis.

Instructions

Get trending topics and popular content for analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of trending topics to return (default: 10, max: 50)
locationNoLocation for trending topics (default: "worldwide")
timeframeNoTimeframe for trending analysis (default: "hourly")

Implementation Reference

  • Main handler function that implements the core logic of the trendingTopicsSearch tool. It uses the SocialData client to search for recent popular tweets (filter:popular -filter:replies) within the specified timeframe as a proxy for trending topics.
    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')); } };
  • Defines the input schema, parameters, and description for the trendingTopicsSearch tool used in MCP tool listing.
    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: [] } },
  • TypeScript interface defining the input arguments for the trendingTopicsSearch handler.
    export interface TrendingTopicsArgs { location?: string; timeframe?: 'hourly' | 'daily' | 'weekly'; count?: number; }
  • src/tools.ts:736-738 (registration)
    Registers the trendingTopicsSearch tool by spreading SOCIALDATA_TOOLS into the main TOOLS export, which is used by the MCP server for listing available tools.
    // SocialData.tools enhanced research and analytics ...SOCIALDATA_TOOLS };
  • src/index.ts:436-439 (registration)
    Registers the tool handler in the main MCP request dispatcher switch statement, routing tool calls to handleTrendingTopicsSearch.
    case 'trendingTopicsSearch': { const args = request.params.arguments as any; response = await handleTrendingTopicsSearch(client, args); break;

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