Skip to main content
Glama
24mlight

A-Share MCP Server

get_index_constituents

Retrieve constituent stocks for major Chinese A-share market indices including HS300, SZ50, and ZZ500 to analyze index composition and track holdings.

Instructions

Generic index constituent fetch (hs300/sz50/zz500).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYes
dateNo
limitNo
formatNomarkdown

Implementation Reference

  • FastMCP tool handler for 'get_index_constituents', decorated with @app.tool(), delegates to use case via run_tool_with_handling.
    @app.tool()
    def get_index_constituents(index: str, date: Optional[str] = None, limit: int = 250, format: str = "markdown") -> str:
        """Generic index constituent fetch (hs300/sz50/zz500)."""
        return run_tool_with_handling(
            lambda: fetch_index_constituents(active_data_source, index=index, date=date, limit=limit, format=format),
            context=f"get_index_constituents:{index}",
        )
  • Core use case function implementing the logic to fetch, validate, map index key, retrieve data from source, and format output.
    def fetch_index_constituents(data_source: FinancialDataSource, *, index: str, date: Optional[str], limit: int, format: str) -> str:
        validate_output_format(format)
        key = validate_index_key(index, INDEX_MAP)
        if key == "hs300":
            df = data_source.get_hs300_stocks(date=date)
        elif key == "sz50":
            df = data_source.get_sz50_stocks(date=date)
        else:
            df = data_source.get_zz500_stocks(date=date)
        meta = {"index": key, "as_of": date or "latest"}
        return format_table_output(df, format=format, max_rows=limit, meta=meta)
  • Mapping of index names (English/Chinese) to canonical keys used for input validation in get_index_constituents.
    INDEX_MAP = {
        "hs300": "hs300",
        "沪深300": "hs300",
        "zz500": "zz500",
        "中证500": "zz500",
        "sz50": "sz50",
        "上证50": "sz50",
    }
  • mcp_server.py:53-53 (registration)
    Top-level call to register all index tools, including get_index_constituents.
    register_index_tools(app, active_data_source)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions fetching constituents but doesn't describe what the tool returns (e.g., list of stocks, data format, pagination), any rate limits, authentication needs, or error handling. For a tool with 4 parameters and no output schema, this leaves critical behavioral traits unspecified, though it doesn't contradict annotations.

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 a single, efficient sentence that is front-loaded with the core purpose. There's no wasted verbiage, making it easy to parse quickly. However, it could be more structured by explicitly listing parameters or use cases, but it's appropriately sized for its limited content.

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?

Given the complexity (4 parameters, no annotations, no output schema, and sibling tools with similar names), the description is incomplete. It doesn't explain return values, differentiate from siblings, or detail parameter usage, leaving significant gaps for the agent to understand how to invoke the tool correctly in context.

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

Parameters2/5

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

Schema description coverage is 0%, so the schema provides no parameter descriptions. The tool description only implies that 'index' accepts hs300/sz50/zz500 values but doesn't explain the 'date', 'limit', or 'format' parameters. It adds minimal meaning beyond the schema, failing to compensate for the coverage gap, which is inadequate for a tool with 4 parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool fetches index constituents and lists three specific indexes (hs300/sz50/zz500), which provides a basic purpose. However, it's vague about what 'constituents' means (e.g., stocks, weights, details) and doesn't clearly differentiate from sibling tools like get_hs300_stocks, get_sz50_stocks, or get_zz500_stocks, which appear to serve similar functions. The generic phrasing lacks specificity in verb and resource scope.

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 offers no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like get_hs300_stocks that might overlap, nor does it provide context such as prerequisites, use cases, or exclusions. Without any usage instructions, the agent must infer from tool names alone, which is insufficient for clear decision-making.

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/24mlight/a-share-mcp-is-just-i-need'

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