Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_news_sentiment

Analyze sentiment of news articles for a specific stock ticker to gain insights into market perception and trends. Retrieve relevant news data from Yahoo Finance to inform investment decisions.

Instructions

获取指定股票的相关新闻列表。

参数说明: ticker: str 股票代码,例如 "AAPL"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYes

Implementation Reference

  • Handler function that fetches recent news articles for the given stock ticker using the Financial Modeling Prep API (v4/general_news endpoint), extracts title, text summary, and URL for each article, and formats them into a string response.
    async def get_news_sentiment(ticker: str) -> str:
        """Get news for a given ticker symbol"""
    
        api_key = os.environ.get("FMP_API_KEY")
        if not api_key:
            return "Error: FMP_API_KEY environment variable not set."
    
        url = "https://financialmodelingprep.com/api/v4/general_news"
        try:
            resp = requests.get(
                url, params={"tickers": ticker, "page": 0, "size": 50, "apikey": api_key}, timeout=10
            )
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: getting news for {ticker}: {e}"
    
        news_list = []
        for item in data:
            title = item.get("title", "")
            summary = item.get("text", "")
            link = item.get("url", "")
            news_list.append(f"Title: {title}\nSummary: {summary}\nURL: {link}")
    
        if not news_list:
            return f"No news found for {ticker}"
    
        return "\n\n".join(news_list)
  • server.py:151-159 (registration)
    Tool registration using the @fmp_server.tool decorator, specifying the name and Chinese description with parameter details.
    @fmp_server.tool(
        name="get_news_sentiment",
        description="""获取指定股票的相关新闻列表。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
    """,
    )
  • Mention of the tool in the server instructions string listing available tools.
    - get_news_sentiment:获取股票相关新闻。
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. While it states the tool retrieves news, it doesn't describe what kind of news (financial, general, sentiment-labeled), how many items are returned, whether there's pagination, time recency, data sources, rate limits, or authentication requirements. For a news retrieval tool with zero annotation coverage, this leaves significant behavioral gaps.

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

Conciseness3/5

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

The description is appropriately concise with two sentences, but the structure could be improved. The purpose statement is clear, but the parameter explanation is separated into a '参数说明' section rather than integrated naturally. While not wasteful, it lacks the polished flow of front-loading all critical information in a single coherent paragraph.

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 news retrieval (which involves multiple behavioral aspects like filtering, formatting, and limitations) with no annotations and no output schema, the description is incomplete. It doesn't explain what the news list contains (headlines, summaries, dates, sources, sentiment scores despite the tool name), how results are ordered, or what format they're returned in. For a tool with 'sentiment' in its name but no output schema, this is particularly inadequate.

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

Parameters4/5

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

The description provides meaningful parameter semantics beyond the schema. The input schema has 0% description coverage (just 'ticker' with title 'Ticker'), but the description explains that 'ticker' is a stock code with an example ('AAPL'). This adds crucial context about format and expected values, though it doesn't specify allowed ticker formats or validation rules.

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 tool's purpose: '获取指定股票的相关新闻列表' (Get news list for specified stock). It uses a specific verb ('获取' - get) and resource ('新闻列表' - news list) with a clear scope ('指定股票' - specified stock). However, it doesn't distinguish from sibling tools like 'get_stock_grade_latest_news' or 'get_crypto_news', which appear to serve similar functions for different asset classes.

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. With multiple news-related sibling tools (get_crypto_news, get_stock_grade_latest_news, get_stock_grade_news), there's no indication of how this tool differs in scope, recency, or content. It doesn't mention prerequisites, exclusions, or comparative use cases.

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/16Coffee/finance-mcp'

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