Skip to main content
Glama
24mlight

A Share MCP

get_hs300_stocks

Retrieve CSI 300 index constituents to analyze A-share market composition and track major Chinese stocks for investment research.

Instructions

CSI 300 constituents.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNo
limitNo
formatNomarkdown

Implementation Reference

  • MCP tool handler for get_hs300_stocks. Decorated with @app.tool(), it invokes the use case via run_tool_with_handling for execution and error handling.
    @app.tool()
    def get_hs300_stocks(date: Optional[str] = None, limit: int = 250, format: str = "markdown") -> str:
        """CSI 300 constituents."""
        return run_tool_with_handling(
            lambda: fetch_index_constituents(active_data_source, index="hs300", date=date, limit=limit, format=format),
            context="get_hs300_stocks",
        )
  • mcp_server.py:53-53 (registration)
    Registration call for index tools, including get_hs300_stocks, by invoking register_index_tools(app, active_data_source).
    register_index_tools(app, active_data_source)
  • Use case helper fetch_index_constituents that routes to data_source.get_hs300_stocks() for HS300 index and formats the 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)
  • Data source implementation of get_hs300_stocks, delegating to shared _fetch_index_constituent_data helper using Baostock's query_hs300_stocks API.
    def get_hs300_stocks(self, date: Optional[str] = None) -> pd.DataFrame:
        """Fetches CSI 300 index constituents using Baostock."""
        return _fetch_index_constituent_data(bs.query_hs300_stocks, "CSI 300", date)
  • Shared helper function _fetch_index_constituent_data that performs the actual Baostock API query, error handling, and DataFrame construction for index constituents.
    def _fetch_index_constituent_data(
        bs_query_func,
        index_name: str,
        date: Optional[str] = None
    ) -> pd.DataFrame:
        logger.info(
            f"Fetching {index_name} constituents for date={date or 'latest'}")
        try:
            with baostock_login_context():
                # date is optional, defaults to latest
                rs = bs_query_func(date=date)
    
                if rs.error_code != '0':
                    logger.error(
                        f"Baostock API error ({index_name} Constituents) for date {date}: {rs.error_msg} (code: {rs.error_code})")
                    if "no record found" in rs.error_msg.lower() or rs.error_code == '10002':
                        raise NoDataFoundError(
                            f"No {index_name} constituent data found for date {date}. Baostock msg: {rs.error_msg}")
                    else:
                        raise DataSourceError(
                            f"Baostock API error fetching {index_name} constituents: {rs.error_msg} (code: {rs.error_code})")
    
                data_list = []
                while rs.next():
                    data_list.append(rs.get_row_data())
    
                if not data_list:
                    logger.warning(
                        f"No {index_name} constituent data found for date {date} (empty result set).")
                    raise NoDataFoundError(
                        f"No {index_name} constituent data found for date {date} (empty result set).")
    
                result_df = pd.DataFrame(data_list, columns=rs.fields)
                logger.info(
                    f"Retrieved {len(result_df)} {index_name} constituents for date {date or 'latest'}.")
                return result_df
    
        except (LoginError, NoDataFoundError, DataSourceError, ValueError) as e:
            logger.warning(
                f"Caught known error fetching {index_name} constituents for date {date}: {type(e).__name__}")
            raise e
        except Exception as e:
            logger.exception(
                f"Unexpected error fetching {index_name} constituents for date {date}: {e}")
            raise DataSourceError(
                f"Unexpected error fetching {index_name} constituents for date {date}: {e}")
Behavior1/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 fails to describe what the tool returns (e.g., a list of stocks, their details), any side effects, rate limits, or error conditions. This leaves the agent with no understanding of the tool's behavior beyond its name.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single phrase, 'CSI 300 constituents.' It is front-loaded and wastes no words, though this brevity comes at the cost of clarity and completeness.

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

Completeness1/5

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

Given the complexity (3 parameters with 0% schema coverage, no annotations, no output schema), the description is severely incomplete. It doesn't explain the tool's purpose, usage, behavior, or parameters, making it inadequate for an AI agent to understand and invoke the tool correctly.

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

Parameters1/5

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

Schema description coverage is 0%, so parameters 'date', 'limit', and 'format' are undocumented in the schema. The description adds no information about these parameters, such as their purpose (e.g., date for historical constituents, limit for pagination, format for output type), leaving their semantics completely unclear.

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

Purpose2/5

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

The description 'CSI 300 constituents' restates the tool name 'get_hs300_stocks' without specifying the action. It identifies the resource (CSI 300 stocks) but lacks a verb indicating what the tool does with them (e.g., fetch, list, retrieve). This is tautological and doesn't distinguish it from siblings like 'get_index_constituents' or 'get_sz50_stocks'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/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. It doesn't mention sibling tools like 'get_index_constituents' (which might be more general) or 'get_sz50_stocks' (for another index), nor does it specify any context or prerequisites for usage.

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