Skip to main content
Glama

Search Stock News MCP Server

general-search.ts1.12 kB
"use strict"; import { tavily } from '@tavily/core'; import { getConfig } from '../config/env'; import { GeneralSearchResult } from '../types/tools'; export default async ( query: string, maxResults: number = 10, searchDepth: 'basic' | 'advanced' = 'basic', minScore: number = 0.4 ): Promise<GeneralSearchResult[]> => { const config = getConfig(); const { apiKey } = config; // Initialize Tavily client const tvly = tavily({ apiKey }); try { const response = await tvly.search(query, { searchDepth, maxResults, includeDomains: [], excludeDomains: [] }); // Transform and filter the results const filteredResults = response.results .map((result) => ({ title: result.title, url: result.url, content: result.content, publishedDate: result.publishedDate, score: result.score, })) .filter(result => result.score >= minScore) .sort((a, b) => b.score - a.score); return filteredResults; } catch (error) { console.error(`Error performing general search: ${error}`); throw error; } };

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/Cognitive-Stack/search-stock-news-mcp'

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