Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_option_expiration_dates

Retrieve available option expiration dates for a specific stock ticker using the Yahoo Finance MCP Server. Input the stock symbol to fetch relevant options data for informed trading decisions.

Instructions

获取指定股票可用的期权到期日。

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYes

Implementation Reference

  • The handler function that implements the core logic of the tool. It retrieves the available option expiration dates for the specified stock ticker from the Financial Modeling Prep API, handles errors, sorts the dates, and returns them as a JSON string.
    async def get_option_expiration_dates(ticker: str) -> str:
        """Fetch the available options expiration dates for a given ticker symbol."""
    
        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/api/v3"
        try:
            resp = requests.get(
                f"{base}/options/available-expirations/{ticker}", params={"apikey": api_key}, timeout=10
            )
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: getting option expiration dates for {ticker}: {e}"
        expirations = data if isinstance(data, list) else data.get("expirations", [])
        return json.dumps(sorted(expirations))
  • server.py:580-588 (registration)
    Registers the tool with the FastMCP server, specifying the name and a description that includes the input parameter schema (ticker: str).
    @fmp_server.tool(
        name="get_option_expiration_dates",
        description="""获取指定股票可用的期权到期日。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
    """,
    )
  • Defines the input schema in the tool description: requires a 'ticker' parameter of type string (e.g., 'AAPL'). The function signature also provides type hints: ticker: str -> str.
        description="""获取指定股票可用的期权到期日。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
    """,
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states it 'gets' data, implying a read-only operation, but doesn't disclose behavioral traits like rate limits, authentication needs, data freshness, format of returned dates, or whether it's a real-time or cached query. For a financial data tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

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: the first sentence states the purpose clearly, followed by a parameter explanation. There's no wasted text, though the structure could be slightly improved by integrating the parameter note more seamlessly. Every sentence earns its place.

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

Completeness2/5

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

Given the complexity (financial data query), no annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't explain what the output looks like (e.g., list of dates, format), error conditions, or dependencies. For a tool that likely returns structured date data, this leaves too much unspecified for reliable agent use.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining the ticker parameter as a stock code with an example ('AAPL'), which clarifies the expected format. However, it doesn't cover other potential aspects like validation rules or supported exchanges. With one parameter partially documented, this meets the baseline for minimal compensation.

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 available option expiration dates for a specified stock). It specifies the verb (get/获取) and resource (option expiration dates/期权到期日), and distinguishes it from siblings like get_option_chain (which likely provides full option chains). However, it doesn't explicitly differentiate from all siblings, just implies a specific scope.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, when not to use it, or compare it to sibling tools like get_option_chain. The only implied context is needing option expiration dates for a stock, but no explicit usage rules are given.

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