Skip to main content
Glama
Cognitive-Stack

Search Stock News MCP Server

search-stock-news

Retrieve filtered stock-related news by specifying a stock symbol, company name, and criteria like max results, search depth, and relevance score. Access tailored financial updates quickly.

Instructions

Search for stock-related news using Tavily API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
companyNameYesCompany name (e.g., Apple Inc.)
maxResultsNoMaximum number of results to return
minScoreNoMinimum relevance score threshold
searchDepthNoSearch depth level
symbolYesStock symbol (e.g., AAPL)

Implementation Reference

  • Core handler function that performs multi-template Tavily searches for stock news, filters and sorts results by score, and returns grouped results.
    export default async ( symbol: string, companyName: string, days: number, minScore: number ): Promise<Array<{ searchQuery: string; results: StockNewsResult[]; }>> => { const config = getConfig(); const { apiKey, maxResults, searchDepth, queryTemplates, includeDomains, excludeDomains } = config; // Initialize Tavily client const tvly = tavily({ apiKey }); const allResults = []; // Process each template for (const template of queryTemplates) { const searchQuery = template .replace('{symbol}', symbol) .replace('{company_name}', companyName); try { const response = await tvly.search(searchQuery, { searchDepth, topics: ['news'], timeRange: "d", days, 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); allResults.push({ searchQuery, results: filteredResults }); } catch (error) { console.error(`Error searching with template: ${template}`, error); // Continue with other templates even if one fails continue; } } return allResults; };
  • Registers the tool in the tools array with name, description, Zod input parameters schema, and execute wrapper that calls the imported handler.
    { name: "search-stock-news", description: "Search for stock-related news using Tavily API", parameters: z.object({ symbol: z.string().describe("Stock symbol (e.g., AAPL)"), companyName: z.string().describe("Company name (e.g., Apple Inc.)"), maxResults: z.number().optional().describe("Maximum number of results to return"), searchDepth: z.enum(["basic", "advanced"]).optional().describe("Search depth level"), minScore: z.number().optional().describe("Minimum relevance score threshold") }), execute: async (args) => { const results = await searchStockNews( args.symbol, args.companyName, args.maxResults || 10, args.minScore || 0.4 ); return JSON.stringify(results, null, 2); } },
  • TypeScript interface defining the structure of individual stock news search results used in the handler's output.
    export interface StockNewsResult { title: string; url: string; content: string; publishedDate: string; score: number; }

Other Tools

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

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