Skip to main content
Glama
marckwei

MCP Yahoo Finance

by marckwei

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
NameRequiredDescriptionDefault
symbolYesStock symbol in Yahoo Finance format.

Implementation Reference

  • 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)
  • 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),
        ]
  • 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)]

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/marckwei/no-use-tools'

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