Skip to main content
Glama
24mlight

A-Share MCP Server

get_sz50_stocks

Retrieve the current constituents of the SZSE 50 index, providing stock data for China's A-share market in your preferred format.

Instructions

SZSE 50 constituents.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNo
limitNo
formatNomarkdown

Implementation Reference

  • MCP tool handler and registration for 'get_sz50_stocks'. Delegates to use case 'fetch_index_constituents' via run_tool_with_handling for execution and error handling.
    @app.tool()
    def get_sz50_stocks(date: Optional[str] = None, limit: int = 250, format: str = "markdown") -> str:
        """SZSE 50 constituents."""
        return run_tool_with_handling(
            lambda: fetch_index_constituents(active_data_source, index="sz50", date=date, limit=limit, format=format),
            context="get_sz50_stocks",
        )
  • Use case helper 'fetch_index_constituents' that handles sz50 index by calling data_source.get_sz50_stocks(), validates input, and formats the DataFrame 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_sz50_stocks in BaostockDataSource, which fetches constituents using Baostock's query_sz50_stocks API via shared helper.
    def get_sz50_stocks(self, date: Optional[str] = None) -> pd.DataFrame:
        """Fetches SZSE 50 index constituents using Baostock."""
        return _fetch_index_constituent_data(bs.query_sz50_stocks, "SZSE 50", date)
  • Abstract method definition in FinancialDataSource interface specifying the get_sz50_stocks signature.
    def get_sz50_stocks(self, date: Optional[str] = None) -> pd.DataFrame:
        pass
  • Shared helper function _fetch_index_constituent_data used by get_sz50_stocks to query Baostock API, handle errors, and return DataFrame.
    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 any behavioral traits, such as whether it's a read-only operation, requires authentication, has rate limits, or returns data in a specific structure (e.g., list, table). The description offers no insights beyond the tool name, leaving the agent with no operational context.

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

Conciseness3/5

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

The description is extremely concise ('SZSE 50 constituents.'), which is efficient but under-specified. It's front-loaded but lacks necessary detail, making it more of an under-description than optimal brevity. While it avoids waste, it doesn't provide enough substance to be truly helpful, balancing between conciseness and inadequacy.

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 tool's complexity (3 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what the tool returns (e.g., a list of stocks, their details), how parameters affect output, or behavioral aspects. With no structured data to rely on, the description fails to provide the minimal context needed for an agent to use the tool effectively.

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?

The input schema has 3 parameters (date, limit, format) with 0% description coverage, meaning their purposes are undocumented. The description adds no information about these parameters, such as what 'date' filters, what 'limit' controls, or what 'format' options exist. It fails to compensate for the schema's lack of documentation, leaving parameters semantically 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 'SZSE 50 constituents' restates the tool name 'get_sz50_stocks' in slightly different wording, making it tautological. It doesn't specify what action the tool performs (e.g., 'retrieve', 'list', or 'fetch') or clarify the resource scope beyond the name. While it identifies the SZSE 50 index, it lacks a clear verb to distinguish its function from siblings like 'get_hs300_stocks' or 'get_zz500_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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools (e.g., 'get_hs300_stocks' for different indices) or contextual factors like date ranges or output formats. Without any usage instructions, the agent must infer applicability from the name alone, which is insufficient for effective tool selection.

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