Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_stock_grades

Retrieve the latest analyst ratings for a specific stock using its ticker symbol, such as "AAPL", to inform investment decisions with expert insights.

Instructions

获取分析师最新评级。

参数说明: ticker: str 股票代码,例如 "AAPL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYes

Implementation Reference

  • The main handler function for the get_stock_grades tool. It takes a stock ticker, fetches analyst grades from the Financial Modeling Prep API using the FMP_API_KEY, handles errors, and returns the data as JSON string.
    async def get_stock_grades(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" 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 stock grades for {ticker}: {e}" return json.dumps(data)
  • server.py:726-733 (registration)
    The decorator that registers the get_stock_grades tool with the MCP server, including the tool name and input schema description.
    @fmp_server.tool( name="get_stock_grades", description="""获取分析师最新评级。 参数说明: ticker: str 股票代码,例如 "AAPL""", )
  • The description in the tool decorator defines the input schema: ticker (str, stock symbol like AAPL). Output is str (JSON).
    description="""获取分析师最新评级。 参数说明: ticker: str 股票代码,例如 "AAPL""", )

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