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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the Tavily API but doesn't describe key behaviors such as rate limits, authentication needs, error handling, or what the search results include (e.g., headlines, summaries, sources). For a search tool with external API dependencies, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and includes the API name for context. Every word earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a search tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., list of articles with fields), how results are ordered, or any behavioral traits like pagination or API constraints. For a tool with rich input schema but missing output and behavioral context, it should do more.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., no examples of how parameters interact or typical values). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Search') and resource ('stock-related news'), and specifies the API used ('Tavily API'). It distinguishes from the sibling 'general-search' by focusing on stock-related content, though it doesn't explicitly mention this differentiation. The purpose is specific and actionable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'general-search', nor does it mention any prerequisites, exclusions, or contextual triggers. It simply states what the tool does without indicating appropriate scenarios or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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