Skip to main content
Glama

research_topic

Research topics using Brave Search and Perplexity to gather information, facts, trends, news, and hashtags for social media content creation.

Instructions

Research a topic using Brave Search and Perplexity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYesTopic to research
includeHashtagsNoWhether to include relevant hashtags
includeFactsNoWhether to include facts about the topic
includeTrendsNoWhether to include trending information
includeNewsNoWhether to include news articles

Implementation Reference

  • The primary handler function for the 'research_topic' MCP tool. It processes input arguments, calls the research aggregator, formats the response, and handles errors.
    private async handleResearchTopic(args: any) { logger.info('Researching topic', { topic: args.topic }); try { const topic = args.topic; const options = { includeHashtags: args.includeHashtags || false, includeFacts: args.includeFacts || false, includeTrends: args.includeTrends || false, includeNews: args.includeNews || false, }; const researchData = await researchAggregator.researchTopic(topic, options); return { content: [ { type: 'text', text: JSON.stringify({ topic, options, researchData, status: 'success', }, null, 2), }, ], }; } catch (error) { logger.error('Error researching topic', { topic: args.topic, error: error instanceof Error ? error.message : String(error) }); throw error; } }
  • Tool definition including name, description, and input schema for 'research_topic' used in tool listing.
    { name: 'research_topic', description: 'Research a topic using Brave Search and Perplexity', inputSchema: { type: 'object', properties: { topic: { type: 'string', description: 'Topic to research', }, includeHashtags: { type: 'boolean', description: 'Whether to include relevant hashtags', }, includeFacts: { type: 'boolean', description: 'Whether to include facts about the topic', }, includeTrends: { type: 'boolean', description: 'Whether to include trending information', }, includeNews: { type: 'boolean', description: 'Whether to include news articles', }, }, required: ['topic'], }, },
  • src/index.ts:181-187 (registration)
    Tool dispatch registration in the CallToolRequestSchema handler, routing 'research_topic' to its handler function.
    switch (request.params.name) { case 'create_post': return await this.handleCreatePost(request.params.arguments); case 'get_trending_topics': return await this.handleGetTrendingTopics(request.params.arguments); case 'research_topic': return await this.handleResearchTopic(request.params.arguments);
  • Core research logic implementing topic research using Brave Search and Perplexity clients, extracting hashtags, facts, news, and trends. Called by the tool handler.
    async researchTopic( topic: string, options: { includeHashtags?: boolean; includeFacts?: boolean; includeTrends?: boolean; includeNews?: boolean; } = {} ): Promise<ResearchData> { logger.info('Researching topic', { topic, options }); const researchData: ResearchData = { sources: [], }; try { // Get search results from Brave Search const searchResults = await braveClient.search(topic, 10); // Add Brave Search as a source researchData.sources.push(searchResults.source); // Extract hashtags if requested if (options.includeHashtags) { researchData.hashtags = await braveClient.extractHashtags(topic, 5); } // Extract facts if requested if (options.includeFacts) { try { // Get in-depth research from Perplexity const perplexityResults = await perplexityClient.research(topic, { depth: 'detailed' }); // Add Perplexity as a source researchData.sources.push(perplexityResults.source); // Use Perplexity facts if available, otherwise extract from search results if (perplexityResults.facts && perplexityResults.facts.length > 0) { researchData.facts = perplexityResults.facts; logger.info('Using Perplexity facts', { count: perplexityResults.facts.length }); } else { researchData.facts = this.extractFacts(searchResults); logger.info('Using extracted facts from search results', { count: researchData.facts.length }); } } catch (error) { logger.warn('Error getting Perplexity research, falling back to extracted facts', { error: error instanceof Error ? error.message : String(error) }); // Fall back to extracting facts from search results researchData.facts = this.extractFacts(searchResults); } } // Extract news if requested if (options.includeNews) { researchData.news = this.extractNews(searchResults); } // Get trends if requested // Note: In a complete implementation, this would use the Twitter and Mastodon clients if (options.includeTrends) { researchData.trends = this.generatePlaceholderTrends(topic); } logger.info('Research completed successfully', { topic, hashtagCount: researchData.hashtags?.length || 0, factCount: researchData.facts?.length || 0, newsCount: researchData.news?.length || 0, trendCount: researchData.trends?.length || 0, }); return researchData; } catch (error) { logger.error('Error researching topic', { topic, error: error instanceof Error ? error.message : String(error) }); throw error; } }
Install Server

Other Tools

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/tayler-id/social-media-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server