Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_ratings

Retrieve real-time or historical stock ratings using the Yahoo Finance MCP Server. Input a stock symbol to access snapshot or past rating data, with customizable limits for results.

Instructions

获取股票评级数据,可选择快照或历史记录。

参数说明: symbol: str 股票代码,例如 "AAPL" rating_type: str snapshot 或 historical,默认 snapshot limit: int 返回数量,默认 1

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
rating_typeNosnapshot
symbolYes

Implementation Reference

  • The handler function that implements the get_ratings tool by fetching stock analyst ratings (snapshot or historical) from the Financial Modeling Prep API using the provided symbol, rating_type, and limit parameters.
    async def get_ratings(symbol: str, rating_type: str = "snapshot", limit: int = 1) -> str:
        """根据类型获取评级信息"""
    
        api_key = os.environ.get("FMP_API_KEY")
        if not api_key:
            return "Error: FMP_API_KEY environment variable not set."
    
        base = "https://financialmodelingprep.com/stable"
        endpoint_map = {
            "snapshot": "ratings-snapshot",
            "historical": "ratings-historical",
        }
        endpoint = endpoint_map.get(rating_type.lower())
        if not endpoint:
            return "Error: invalid rating type"
        url = f"{base}/{endpoint}"
        try:
            resp = requests.get(
                url,
                params={"symbol": symbol, "limit": limit, "apikey": api_key},
                timeout=10,
            )
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: getting {rating_type} ratings for {symbol}: {e}"
        return json.dumps(data)
  • server.py:1004-1015 (registration)
    The decorator that registers the get_ratings tool with the MCP server, including name, description, and parameter documentation.
    @fmp_server.tool(
        name="get_ratings",
        description="""获取股票评级数据,可选择快照或历史记录。
    
    参数说明:
        symbol: str
            股票代码,例如 "AAPL"
        rating_type: str
            snapshot 或 historical,默认 snapshot
        limit: int
            返回数量,默认 1""",
    )
  • Type annotations defining the input schema (symbol: str, rating_type: str='snapshot', limit: int=1) and output str for the tool.
    async def get_ratings(symbol: str, rating_type: str = "snapshot", limit: int = 1) -> str:
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool retrieves data (implied read-only) and describes two modes (snapshot/historical), but doesn't disclose important behavioral traits like rate limits, authentication requirements, data freshness, error conditions, or what format the ratings data returns. For a data retrieval tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and well-structured. The first sentence states the purpose clearly, followed by a parameter section with bullet-point explanations. Each sentence earns its place by adding value. It could be slightly more front-loaded with a clearer distinction from sibling tools.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is partially complete. It covers parameters well but lacks behavioral context and output information. For a data retrieval tool without annotations or output schema, the description should ideally explain what the ratings data looks like and any important constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides excellent parameter semantics beyond the schema. With 0% schema description coverage, the description fully compensates by explaining all three parameters: symbol (stock code with example), rating_type (snapshot/historical with default), and limit (return count with default). It adds meaningful context that the schema alone doesn't provide.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '获取股票评级数据' (get stock rating data). It specifies the resource (stock ratings) and the action (get/retrieve). While it doesn't explicitly differentiate from all siblings, it distinguishes from tools like get_stock_grades or get_stock_grades_historical by focusing specifically on 'ratings' rather than 'grades'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some implied usage context by mentioning the choice between snapshot or historical data, which suggests when to use each rating_type. However, it doesn't explicitly state when to use this tool versus alternatives like get_stock_grades or get_stock_grades_historical, nor does it mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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