Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_option_chain

Retrieve detailed option chain data for a specific stock, including calls and puts, by providing the ticker symbol, expiration date, and option type. Use this to analyze and strategize financial options trading.

Instructions

根据股票代码、到期日和期权类型获取期权链数据。

参数说明: ticker: str 股票代码,例如 "AAPL" expiration_date: str 期权到期日,格式为 'YYYY-MM-DD' option_type: str 期权类型:'calls' 或 'puts'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expiration_dateYes
option_typeYes
tickerYes

Implementation Reference

  • The core handler function for the 'get_option_chain' tool. It retrieves option chain data from the Financial Modeling Prep API for a given ticker, filters by expiration date and option type (calls/puts), handles errors, and returns filtered JSON data.
    async def get_option_chain(ticker: str, expiration_date: str, option_type: str) -> str:
        """Fetch the option chain for a given ticker symbol, expiration date, and option type."""
    
        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/chain/{ticker}",
                params={"expiration": expiration_date, "apikey": api_key},
                timeout=10,
            )
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: getting option chain for {ticker}: {e}"
    
        filtered = [
            item
            for item in data
            if item.get("expirationDate") == expiration_date
            and item.get("optionType", "").lower() == option_type.lower()
        ]
        return json.dumps(filtered)
  • server.py:609-621 (registration)
    The @fmp_server.tool decorator registers the 'get_option_chain' tool, specifying its name and detailed description including input parameters (schema). This is how the tool is exposed in the MCP server.
    @fmp_server.tool(
        name="get_option_chain",
        description="""根据股票代码、到期日和期权类型获取期权链数据。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
        expiration_date: str
            期权到期日,格式为 'YYYY-MM-DD'
        option_type: str
            期权类型:'calls' 或 'puts'
    """,
    )
  • Type hints in the function signature define the input schema: ticker (str), expiration_date (str), option_type (str), returning str (JSON).
    async def get_option_chain(ticker: str, expiration_date: str, option_type: str) -> str:
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 what the tool does but lacks behavioral details such as rate limits, authentication requirements, error conditions, or what the output format looks like. The description does not disclose any operational constraints beyond basic parameter usage.

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 core purpose in the first sentence, followed by parameter details. Every sentence earns its place by providing essential information without redundancy. Minor deduction for slightly verbose parameter formatting in Chinese.

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 does well on parameters but lacks completeness for a data retrieval tool: it doesn't describe the return structure, pagination, or error handling. It's adequate for basic use but has clear gaps in operational context.

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?

With 0% schema description coverage, the description fully compensates by providing detailed parameter semantics: it explains each parameter's purpose, gives examples (e.g., 'AAPL'), specifies formats ('YYYY-MM-DD'), and enumerates valid values ('calls' or 'puts'). This adds significant value beyond the bare schema.

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

Purpose5/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 with specific verbs ('获取期权链数据' - get option chain data) and resources (stock ticker, expiration date, option type). It distinguishes itself from siblings like 'get_option_expiration_dates' by focusing on retrieving the actual chain data rather than just expiration dates.

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 implies usage context through the parameter explanations (e.g., '期权类型:'calls' 或 'puts''), but does not explicitly state when to use this tool versus alternatives like 'get_stock_info' or 'get_historical_stock_prices'. No guidance on prerequisites or exclusions is provided.

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