Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_economic_data

Retrieve macroeconomic data such as treasury rates, indicators, calendar events, and market risk premiums from Yahoo Finance, using date ranges and specific parameters for targeted insights.

Instructions

获取宏观经济数据。

参数说明: data_type: str treasury_rates、economic_indicators、economic_calendar、market_risk_premium name: str 经济指标名称,data_type 为 economic_indicators 时必填 from_date: str 起始日期,格式 YYYY-MM-DD to_date: str 结束日期,格式 YYYY-MM-DD

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
data_typeYes
from_dateNo
nameNo
to_dateNo

Implementation Reference

  • The handler function that implements the get_economic_data tool, fetching macroeconomic data from Financial Modeling Prep API based on specified data_type, handling parameters like name, dates, and different endpoints.
    async def get_economic_data(
        data_type: str,
        name: str = "",
        from_date: str = "",
        to_date: str = "",
    ) -> 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 = {
            "treasury_rates": "treasury-rates",
            "economic_indicators": "economic-indicators",
            "economic_calendar": "economic-calendar",
            "market_risk_premium": "market-risk-premium",
        }
        endpoint = endpoint_map.get(data_type.lower())
        if not endpoint:
            return "Error: invalid data type"
    
        params = {"apikey": api_key}
        if data_type == "economic_indicators":
            if not name:
                return "Error: name is required for economic_indicators"
            params["name"] = name
        if from_date and to_date:
            params.update({"from": from_date, "to": to_date})
    
        url = f"{base}/{endpoint}"
        try:
            resp = requests.get(url, params=params, timeout=10)
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: getting economic data {data_type}: {e}"
        return json.dumps(data)
  • server.py:525-538 (registration)
    The @fmp_server.tool decorator that registers the get_economic_data function as an MCP tool, providing the name and detailed description of parameters serving as schema documentation.
    @fmp_server.tool(
        name="get_economic_data",
        description="""获取宏观经济数据。
    
    参数说明:
        data_type: str
            treasury_rates、economic_indicators、economic_calendar、market_risk_premium
        name: str
            经济指标名称,data_type 为 economic_indicators 时必填
        from_date: str
            起始日期,格式 YYYY-MM-DD
        to_date: str
            结束日期,格式 YYYY-MM-DD""",
    )
  • The function signature defining the input parameters and return type for the tool, which implicitly serves as the input schema.
    async def get_economic_data(
        data_type: str,
        name: str = "",
        from_date: str = "",
        to_date: str = "",
    ) -> str:
Behavior2/5

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

With no annotations provided, the description carries full burden but provides minimal behavioral context. It mentions data_type options but doesn't describe what the tool returns, whether it's read-only, if there are rate limits, authentication requirements, or what happens with invalid parameters. The description doesn't contradict annotations (none exist), but it fails to provide adequate behavioral disclosure for a data retrieval tool.

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 main purpose first, followed by parameter details. The Chinese text is concise, and every sentence adds value. However, the parameter section could be better structured with clearer separation between different data_type requirements.

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 (4 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what data is returned, format of results, error conditions, or how different data_type values affect output. For a tool with multiple data retrieval modes and no structured output documentation, this leaves significant gaps for an AI agent.

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 provides significant parameter semantics beyond the 0% schema coverage. It explains data_type options (treasury_rates, economic_indicators, economic_calendar, market_risk_premium), clarifies that name is required when data_type is economic_indicators, and specifies date formats (YYYY-MM-DD). This compensates well for the complete lack of schema descriptions, though it doesn't fully explain all parameter interactions.

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

Purpose3/5

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

The description states '获取宏观经济数据' (get macroeconomic data) which provides a basic purpose, but it's vague about what specific data is retrieved and how it differs from sibling tools like get_calendar_data or get_historical_stock_prices. It doesn't clearly distinguish this economic data tool from other data retrieval tools in the server.

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 any prerequisites, context for use, or comparisons to sibling tools like get_calendar_data (which might overlap with economic_calendar data_type). There's no explicit when/when-not usage information.

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