Skip to main content
Glama

get_financial_metrics

Retrieve key financial metrics for Chinese companies using stock symbols to analyze financial performance and make informed investment decisions.

Instructions

获取公司关键财务指标

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes股票代码 (例如: '000001')
output_formatNo输出数据格式: json, csv, xml, excel, markdown, html。默认: markdownmarkdown

Implementation Reference

  • The main handler function decorated with @mcp.tool for 'get_financial_metrics'. It defines parameters, a nested fetcher helper, uses fallback data fetching, and formats output.
    @mcp.tool(name="get_financial_metrics", description="获取公司关键财务指标") def get_financial_metrics( symbol: Annotated[str, Field(description="股票代码 (例如: '000001')")], output_format: Annotated[ Literal["json", "csv", "xml", "excel", "markdown", "html"], Field(description="输出数据格式: json, csv, xml, excel, markdown, html。默认: markdown"), ] = "markdown" ) -> str: """ 获取三大财务报表的关键财务指标. """ def get_get_financial_metrics_fetcher(source: str, **kwargs: Any) -> pd.DataFrame: if source == "sina": return ak.stock_financial_abstract(**kwargs) elif source == "ths": return ak.stock_financial_abstract_ths(**kwargs,indicator="按报告期") else: return ako.get_financial_metrics(**kwargs) df = _fetch_data_with_fallback( fetch_func=get_get_financial_metrics_fetcher, primary_source="sina", fallback_sources=[ "eastmoney_direct", "ths" ], symbol=symbol, ) if df.empty: df = pd.DataFrame() return _format_dataframe_output(df, output_format)
  • Nested helper function that maps data sources to specific akshare functions for fetching financial metrics.
    def get_get_financial_metrics_fetcher(source: str, **kwargs: Any) -> pd.DataFrame: if source == "sina": return ak.stock_financial_abstract(**kwargs) elif source == "ths": return ak.stock_financial_abstract_ths(**kwargs,indicator="按报告期") else: return ako.get_financial_metrics(**kwargs)
  • The @mcp.tool decorator registering the 'get_financial_metrics' tool with its name and description.
    @mcp.tool(name="get_financial_metrics", description="获取公司关键财务指标")

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/xinkuang/china-stock-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server