Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_stock_grades_historical

Retrieve historical analyst ratings for stocks using the Yahoo Finance MCP Server. Provide a ticker symbol and limit to access detailed grading data for informed investment decisions.

Instructions

获取分析师评级历史记录。

参数说明: ticker: str 股票代码,例如 "AAPL" limit: int 返回记录数量,最大 1000,默认 100

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
tickerYes

Implementation Reference

  • The handler function that implements the core logic of fetching historical analyst grades for a stock ticker from the Financial Modeling Prep API, handling API key, making HTTP request, and returning JSON data.
    async def get_stock_grades_historical(ticker: str, limit: int = 100) -> str:
        """获取分析师评级历史数据"""
    
        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/stable/grades-historical"
        try:
            resp = requests.get(
                url,
                params={"symbol": ticker, "limit": limit, "apikey": api_key},
                timeout=10,
            )
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: getting historical grades for {ticker}: {e}"
        return json.dumps(data)
  • server.py:751-760 (registration)
    The decorator that registers the 'get_stock_grades_historical' tool with the FastMCP server, including the name and a description with parameter schema details.
    @fmp_server.tool(
        name="get_stock_grades_historical",
        description="""获取分析师评级历史记录。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
        limit: int
            返回记录数量,最大 1000,默认 100""",
    )
  • The tool description string that defines the input schema (parameters: ticker str, limit int=100) for validation and usage.
        description="""获取分析师评级历史记录。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
        limit: int
            返回记录数量,最大 1000,默认 100""",
    )

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