Skip to main content
Glama
al-one

MCP Server for stock and crypto

A股板块资金流

stock_sector_fund_flow_rank

Retrieve sector, concept, or regional fund flow rankings for China A-share markets (Shanghai and Shenzhen) for today, 5-day, or 10-day periods.

Instructions

获取中国A股市场(上证、深证)的行业资金流向数据

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNo天数,仅支持: {'今日','5日','10日'},如果需要获取今日数据,请确保是交易日今日
cateNo仅支持: {'行业资金流','概念资金流','地域资金流'}行业资金流

Implementation Reference

  • The @mcp.tool decorator registers 'stock_sector_fund_flow_rank' as an MCP tool with title 'A股板块资金流' and a description of the data it returns.
    @mcp.tool(
        title="A股板块资金流",
        description="获取中国A股市场(上证、深证)的行业资金流向数据",
    )
    def stock_sector_fund_flow_rank(
        days: str = Field("今日", description="天数,仅支持: {'今日','5日','10日'},如果需要获取今日数据,请确保是交易日"),
        cate: str = Field("行业资金流", description="仅支持: {'行业资金流','概念资金流','地域资金流'}"),
    ):
        dfs = ak_cache(ak.stock_sector_fund_flow_rank, indicator=days, sector_type=cate, ttl=1200)
        if dfs is None:
            return "获取数据失败"
        try:
            dfs.sort_values("今日涨跌幅", ascending=False, inplace=True)
            dfs.drop(columns=["序号"], inplace=True)
        except Exception:
            pass
        try:
            dfs = pd.concat([dfs.head(20), dfs.tail(20)])
            return dfs.to_csv(index=False, float_format="%.2f").strip()
        except Exception as exc:
            return str(exc)
  • The function 'stock_sector_fund_flow_rank' executes the tool logic: calls ak_cache wrapping ak.stock_sector_fund_flow_rank with indicator and sector_type parameters, sorts by '今日涨跌幅', drops the '序号' column, and returns top/bottom 20 rows as CSV.
    def stock_sector_fund_flow_rank(
        days: str = Field("今日", description="天数,仅支持: {'今日','5日','10日'},如果需要获取今日数据,请确保是交易日"),
        cate: str = Field("行业资金流", description="仅支持: {'行业资金流','概念资金流','地域资金流'}"),
    ):
        dfs = ak_cache(ak.stock_sector_fund_flow_rank, indicator=days, sector_type=cate, ttl=1200)
        if dfs is None:
            return "获取数据失败"
        try:
            dfs.sort_values("今日涨跌幅", ascending=False, inplace=True)
            dfs.drop(columns=["序号"], inplace=True)
        except Exception:
            pass
        try:
            dfs = pd.concat([dfs.head(20), dfs.tail(20)])
            return dfs.to_csv(index=False, float_format="%.2f").strip()
        except Exception as exc:
            return str(exc)
  • The function parameters define the input schema: 'days' (str, default '今日', values: {'今日','5日','10日'}) and 'cate' (str, default '行业资金流', values: {'行业资金流','概念资金流','地域资金流'}) with pydantic Field descriptions.
    def stock_sector_fund_flow_rank(
        days: str = Field("今日", description="天数,仅支持: {'今日','5日','10日'},如果需要获取今日数据,请确保是交易日"),
        cate: str = Field("行业资金流", description="仅支持: {'行业资金流','概念资金流','地域资金流'}"),
  • The 'ak_cache' helper function wraps akshare calls with a two-tier cache (in-memory + diskcache), keyed by function name and arguments, with configurable TTL.
    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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries full burden for behavioral disclosure. It adds no information about data freshness, source, ranking nature, side effects, or output structure. The tool's behavior remains opaque.

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 one short sentence with no fluff. However, it could be slightly more informative without increasing length, e.g., mentioning output format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Without output schema, the description should explain return values (e.g., sector rankings, net flows). It does not, leaving the agent unsure how to use the tool's output. Parameter defaults are handled, but core missing context lowers completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds no extra meaning beyond the schema; both parameters' defaults and enums are already explained in the schema.

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 retrieves fund flow data for A-share sectors (Shanghai/Shenzhen). However, the parameter 'cate' includes '概念资金流' and '地域资金流', which are not '行业' (industry) as stated. This slight mismatch reduces clarity slightly.

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 its many siblings (e.g., stock_indicators_a, stock_prices). No explicit context, exclusions, or alternative suggestions are given.

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

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

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