get_stock_grades_summary
Retrieve summarized analyst ratings for stocks to assess investment potential. Input a stock ticker to access actionable insights from financial experts.
Instructions
获取分析师评级汇总。
参数说明: ticker: str 股票代码,例如 "AAPL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticker | Yes |
Implementation Reference
- server.py:790-804 (handler)The handler function that implements the get_stock_grades_summary tool. It retrieves the analyst grades consensus summary for a given stock ticker from the Financial Modeling Prep API and returns the data as JSON.async def get_stock_grades_summary(ticker: str) -> 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-consensus" try: resp = requests.get(url, params={"symbol": ticker, "apikey": api_key}, timeout=10) resp.raise_for_status() data = resp.json() except Exception as e: return f"Error: getting grades summary for {ticker}: {e}" return json.dumps(data)
- server.py:782-789 (registration)The @fmp_server.tool decorator that registers the get_stock_grades_summary tool with the MCP server, including its name and description defining the input parameter (ticker: str).@fmp_server.tool( name="get_stock_grades_summary", description="""获取分析师评级汇总。 参数说明: ticker: str 股票代码,例如 "AAPL""", )