Skip to main content
Glama
24mlight

A Share MCP

get_index_constituents

Fetch constituent stocks for major Chinese A-share indices like HS300, SZ50, or ZZ500 to analyze market composition and track index performance.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYes
dateNo
limitNo
formatNomarkdown

Implementation Reference

  • The main handler function for the 'get_index_constituents' tool, decorated with @app.tool() for registration, which wraps the core logic in run_tool_with_handling and delegates to fetch_index_constituents.
    @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}",
        )
  • Schema-like mapping of supported index names (including Chinese aliases) to canonical keys, used by validate_index_key for input validation.
    INDEX_MAP = {
        "hs300": "hs300",
        "沪深300": "hs300",
        "zz500": "zz500",
        "中证500": "zz500",
        "sz50": "sz50",
        "上证50": "sz50",
    }
  • mcp_server.py:53-53 (registration)
    Top-level registration call that invokes register_index_tools, thereby registering the get_index_constituents tool (along with other index tools) to the MCP app.
    register_index_tools(app, active_data_source)
  • Core helper function implementing the tool logic: validates inputs, maps index name, fetches data from the data source, and formats the output table.
    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)
Behavior1/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It fails to mention whether this is a read-only operation, if it requires authentication, rate limits, error handling, or what the output format entails (e.g., list of stocks, historical data). The description is too minimal to inform agent behavior beyond a basic fetch action.

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 front-loads the core action ('fetch') and resources. However, it lacks necessary detail for clarity, making it under-specified rather than optimally concise, but it avoids redundancy and waste.

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 of a financial data tool with 4 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It doesn't explain return values, error conditions, or behavioral nuances, leaving significant gaps for agent usage in a context with many sibling tools.

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 description must compensate by explaining parameters. It only implies the 'index' parameter via the listed indices (hs300/sz50/zz500) but doesn't clarify valid values or semantics. Other parameters (date, limit, format) are entirely undocumented, leaving their purposes and effects unclear.

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 specific indices (hs300/sz50/zz500), which clarifies the resource. However, it's vague about what 'constituents' means (e.g., stocks, weights, metadata) and doesn't distinguish it from similar sibling tools like 'get_hs300_stocks' or 'get_sz50_stocks', leaving ambiguity in 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?

No guidance is provided on when to use this tool versus alternatives like 'get_hs300_stocks' or 'get_sz50_stocks', which appear to overlap in functionality. The description lacks context about prerequisites, exclusions, or comparative use cases, offering only a generic statement.

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