get_financial_metrics
Retrieve key financial metrics from balance sheets, income statements, and cash flow statements for stock analysis and investment research.
Instructions
Get key financial metrics from the three major financial statements.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock symbol/ticker (e.g. '000001') | |
| recent_n | No | Number of most recent records to return |
Implementation Reference
- src/akshare_one_mcp/server.py:236-249 (handler)The main handler function for the 'get_financial_metrics' tool, registered via @mcp.tool decorator. It fetches financial metrics data using ako.get_financial_metrics(symbol), limits rows if specified, and returns JSON.@mcp.tool def get_financial_metrics( symbol: Annotated[str, Field(description="Stock symbol/ticker (e.g. '000001')")], recent_n: Annotated[ int | None, Field(description="Number of most recent records to return", ge=1) ] = 10, ) -> str: """ Get key financial metrics from the three major financial statements. """ df = ako.get_financial_metrics(symbol) if recent_n is not None: df = df.head(recent_n) return df.to_json(orient="records") or "[]"
- Input schema definition using Pydantic Annotated and Field for symbol (required str) and optional recent_n (int >=1).symbol: Annotated[str, Field(description="Stock symbol/ticker (e.g. '000001')")], recent_n: Annotated[ int | None, Field(description="Number of most recent records to return", ge=1) ] = 10, ) -> str:
- src/akshare_one_mcp/server.py:236-236 (registration)Tool registration using @mcp.tool decorator on the handler function.@mcp.tool