get_financial_metrics
Extract key financial metrics from the three major financial statements by inputting a stock symbol and specifying the number of recent records to analyze.
Instructions
Get key financial metrics from the three major financial statements.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| recent_n | No | Number of most recent records to return | |
| symbol | Yes | Stock symbol/ticker (e.g. '000001') |
Input Schema (JSON Schema)
{
"properties": {
"recent_n": {
"anyOf": [
{
"minimum": 1,
"type": "integer"
},
{
"type": "null"
}
],
"default": 10,
"description": "Number of most recent records to return",
"title": "Recent N"
},
"symbol": {
"description": "Stock symbol/ticker (e.g. '000001')",
"title": "Symbol",
"type": "string"
}
},
"required": [
"symbol"
],
"type": "object"
}
Implementation Reference
- src/akshare_one_mcp/server.py:237-249 (handler)The MCP tool 'get_financial_metrics' handler, including schema via Annotated parameters and registration via @mcp.tool decorator. Fetches financial metrics data for a given stock symbol using akshare_one and returns the most recent records as JSON.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 "[]"