get_news
Retrieve financial news articles for specific stock symbols using Yahoo Finance data to support investment research and market analysis.
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:190-198 (handler)The core implementation of the 'get_news' tool handler in the YahooFinance class. It creates a yfinance Ticker for the symbol and returns the news as formatted JSON.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)
- src/mcp_yahoo_finance/server.py:204-218 (registration)Registration of the 'get_news' tool (line with generate_tool(yf.get_news)) in the MCP Server's list_tools method. The generate_tool utility auto-generates the tool schema from the function's signature and docstring.@server.list_tools() async def list_tools() -> list[Tool]: return [ generate_tool(yf.cmd_run), generate_tool(yf.get_recommendations), generate_tool(yf.get_news), generate_tool(yf.get_current_stock_price), generate_tool(yf.get_stock_price_by_date), generate_tool(yf.get_stock_price_date_range), generate_tool(yf.get_historical_stock_prices), generate_tool(yf.get_dividends), generate_tool(yf.get_income_statement), generate_tool(yf.get_cashflow), generate_tool(yf.get_earning_dates), ]
- src/mcp_yahoo_finance/server.py:247-249 (handler)Dispatch handler in the MCP Server's call_tool method that executes the get_news tool by calling yf.get_news with arguments and wrapping the result in TextContent.case "get_news": price = yf.get_news(**args) return [TextContent(type="text", text=price)]