Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_financial_statement

Retrieve detailed financial statements for companies, including annual or quarterly income statements, balance sheets, and cash flow reports, using stock tickers and financial type specifications.

Instructions

获取公司财报,类型包括年度/季度的收入表、资产负债表和现金流量表。

参数说明: ticker: str 股票代码,例如 "AAPL" financial_type: str 财报类型:income_stmt_annual、income_stmt_quarterly、balance_sheet_annual、balance_sheet_quarterly、cashflow_annual、cashflow_quarterly

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
financial_typeYes
tickerYes

Implementation Reference

  • The async handler function that implements the get_financial_statement tool logic, fetching income statement, balance sheet, or cash flow from Financial Modeling Prep API based on ticker and financial_type.
    async def get_financial_statement(ticker: str, financial_type: str) -> str:
        """Get financial statement 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"
        period = "annual"
        if financial_type in [
            FinancialType.income_stmt_quarterly,
            FinancialType.balance_sheet_quarterly,
            FinancialType.cashflow_quarterly,
        ]:
            period = "quarter"
    
        endpoint_map = {
            FinancialType.income_stmt_annual: "income-statement",
            FinancialType.income_stmt_quarterly: "income-statement",
            FinancialType.balance_sheet_annual: "balance-sheet-statement",
            FinancialType.balance_sheet_quarterly: "balance-sheet-statement",
            FinancialType.cashflow_annual: "cash-flow-statement",
            FinancialType.cashflow_quarterly: "cash-flow-statement",
        }
        endpoint = endpoint_map.get(FinancialType(financial_type))
        if not endpoint:
            return "Error: invalid financial type"
        url = f"{base}/{endpoint}/{ticker}"
        try:
            resp = requests.get(url, params={"period": period, "apikey": api_key}, timeout=10)
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: getting financial statement for {ticker}: {e}"
    
        return json.dumps(data)
  • server.py:232-242 (registration)
    Registers the get_financial_statement tool with the FastMCP server using the @tool decorator, including name, description, and parameter details.
    @fmp_server.tool(
        name="get_financial_statement",
        description="""获取公司财报,类型包括年度/季度的收入表、资产负债表和现金流量表。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
        financial_type: str
            财报类型:income_stmt_annual、income_stmt_quarterly、balance_sheet_annual、balance_sheet_quarterly、cashflow_annual、cashflow_quarterly
    """,
    )
  • Defines the FinancialType enum used to validate and map the financial_type parameter to API endpoints.
    class FinancialType(str, Enum):
        income_stmt_annual = "income_stmt_annual"
        income_stmt_quarterly = "income_stmt_quarterly"
        balance_sheet_annual = "balance_sheet_annual"
        balance_sheet_quarterly = "balance_sheet_quarterly"
        cashflow_annual = "cashflow_annual"
        cashflow_quarterly = "cashflow_quarterly"
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 mentions what data is retrieved but doesn't disclose behavioral traits like rate limits, authentication requirements, data freshness, error conditions, or response format. The description is purely functional without operational context.

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 with two clear sections: a purpose statement and parameter documentation. Every sentence earns its place. Minor improvement could be front-loading the parameter section more clearly, but overall it's efficient without waste.

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 good parameter coverage but lacks behavioral and output context. For a data retrieval tool with 2 parameters, it's minimally adequate but misses important operational details like response format, error handling, and data scope limitations.

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?

Schema description coverage is 0%, so the description must compensate fully. It provides complete parameter documentation: ticker format with example ('AAPL') and financial_type with all 6 possible enum values explicitly listed. This adds substantial meaning beyond the bare schema, effectively documenting both parameters.

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 company financial statements) with specific resource types (income statement, balance sheet, cash flow statement) and periodicity (annual/quarterly). It distinguishes from siblings by focusing on financial statements rather than quotes, news, or other data. However, it doesn't explicitly differentiate from potential similar tools not in the sibling list.

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 any prerequisites, constraints, or comparison with sibling tools like get_analyst_estimates or get_dcf_valuation that might provide related financial data. Usage context is implied but not explicit.

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