get_news
Retrieve news articles for specific stock symbols to monitor market developments and company updates.
Instructions
Get news for a given stock symbol.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock symbol in Yahoo Finance format. |
Implementation Reference
- src/mcp_yahoo_finance/server.py:296-303 (handler)The MCP tool handler for 'get_news'. Decorated with @mcp_instance.tool() to register and execute the tool, delegating to the YahooFinance instance's get_news method.@mcp_instance.tool() def get_news(symbol: str) -> str: """Get news for a given stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. """ return yf_instance.get_news(symbol)
- Core helper method in the YahooFinance class that fetches the news for the given stock symbol using yfinance.Ticker and returns it as a JSON string.def get_news(self, symbol: str) -> str: """Get news for a given stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. """ stock = Ticker(ticker=symbol, session=self.session) return json.dumps(stock.news, indent=2)