Skip to main content
Glama
aahl

AkTools MCP Server

by aahl

stock_indicators_hk

Retrieve key financial report indicators for Hong Kong stocks to analyze company performance and make informed investment decisions.

Instructions

获取港股市场的股票财务报告关键指标

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes股票代码

Implementation Reference

  • The main handler function for the 'stock_indicators_hk' tool. It is decorated with @mcp.tool for registration, takes a stock symbol as input, fetches financial analysis indicators from akshare for HK stocks with caching, and returns the top 15 rows as CSV.
    @mcp.tool(
        title="港股关键指标",
        description="获取港股市场的股票财务报告关键指标",
    )
    def stock_indicators_hk(
        symbol: str = field_symbol,
    ):
        dfs = ak_cache(ak.stock_financial_hk_analysis_indicator_em, symbol=symbol, indicator="报告期")
        keys = dfs.to_csv(index=False, float_format="%.3f").strip().split("\n")
        return "\n".join(keys[0:15])
  • Pydantic Field definition for the 'symbol' parameter used in the tool's input schema, shared across multiple tools.
    field_symbol = Field(description="股票代码")
  • Helper function 'ak_cache' used by the tool to cache akshare API calls with TTL support.
    def ak_cache(fun, *args, **kwargs) -> pd.DataFrame | None:
        key = kwargs.pop("key", None)
        if not key:
            key = f"{fun.__name__}-{args}-{kwargs}"
        ttl1 = kwargs.pop("ttl", 86400)
        ttl2 = kwargs.pop("ttl2", None)
        cache = CacheKey.init(key, ttl1, ttl2)
        all = cache.get()
        if all is None:
            try:
                _LOGGER.info("Request akshare: %s", [key, args, kwargs])
                all = fun(*args, **kwargs)
                cache.set(all)
            except Exception as exc:
                _LOGGER.exception(str(exc))
        return all

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/aahl/mcp-aktools'

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