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""",
    )
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions a limit parameter with a maximum of 1000 and default of 100, which adds some behavioral context. However, it doesn't disclose other important traits like whether this is a read-only operation, potential rate limits, authentication needs, or what the return format looks like (e.g., JSON structure, pagination).

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 front-loaded with the purpose statement first, followed by parameter details. Every sentence earns its place by providing essential information without redundancy. The bilingual nature (Chinese purpose, Chinese parameter labels with English examples) is efficient for clarity.

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 no annotations and no output schema, the description provides basic purpose and parameter semantics but lacks details on behavioral traits and return values. For a tool with 2 parameters and historical data retrieval, it's minimally adequate but leaves gaps in understanding the full operation and results.

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

Parameters4/5

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

The description adds significant meaning beyond the input schema, which has 0% schema description coverage. It explains that 'ticker' is a stock symbol like 'AAPL' and 'limit' specifies the number of records to return with a maximum of 1000 and default of 100. This compensates well for the lack of schema descriptions, though it doesn't cover all possible nuances (e.g., ticker format constraints).

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 as '获取分析师评级历史记录' (get analyst rating historical records), which is a specific verb+resource combination. It distinguishes from siblings like 'get_stock_grades' (which might be current ratings) and 'get_ratings' (which could be different rating types), though it doesn't explicitly differentiate them.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools like 'get_stock_grades' or 'get_ratings', nor does it specify prerequisites or contexts for usage beyond the basic parameter requirements.

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