Skip to main content
Glama
24mlight

A Share MCP

get_trade_dates

Retrieve trading and non-trading dates for A-share markets within a specified date range, returning results as a formatted table with trading day indicators.

Instructions

    Fetch trading dates within a specified range.

    Args:
        start_date: Optional. Start date in 'YYYY-MM-DD' format. Defaults to 2015-01-01 if None.
        end_date: Optional. End date in 'YYYY-MM-DD' format. Defaults to the current date if None.

    Returns:
        Markdown table with 'is_trading_day' (1=trading, 0=non-trading).
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateNo
end_dateNo
limitNo
formatNomarkdown

Implementation Reference

  • MCP tool handler implementation for 'get_trade_dates'. This is the function executed when the tool is called, handling parameters, logging, and delegating to the use case via run_tool_with_handling.
    @app.tool()
    def get_trade_dates(start_date: Optional[str] = None, end_date: Optional[str] = None, limit: int = 250, format: str = "markdown") -> str:
        """
        Fetch trading dates within a specified range.
    
        Args:
            start_date: Optional. Start date in 'YYYY-MM-DD' format. Defaults to 2015-01-01 if None.
            end_date: Optional. End date in 'YYYY-MM-DD' format. Defaults to the current date if None.
    
        Returns:
            Markdown table with 'is_trading_day' (1=trading, 0=non-trading).
        """
        logger.info(f"Tool 'get_trade_dates' called for range {start_date or 'default'} to {end_date or 'default'}")
        return run_tool_with_handling(
            lambda: fetch_trade_dates(active_data_source, start_date=start_date, end_date=end_date, limit=limit, format=format),
            context="get_trade_dates",
        )
  • mcp_server.py:54-54 (registration)
    Registration of market overview tools, including 'get_trade_dates', by calling register_market_overview_tools during app setup.
    register_market_overview_tools(app, active_data_source)
  • Interface definition specifying the signature for get_trade_dates method in FinancialDataSource.
    @abstractmethod
    def get_trade_dates(self, start_date: Optional[str] = None, end_date: Optional[str] = None) -> pd.DataFrame:
        """Fetches trading dates information within a range."""
        pass
  • Use case helper function that fetches trade dates from data source, applies validation and formatting.
    def fetch_trade_dates(data_source: FinancialDataSource, *, start_date: Optional[str], end_date: Optional[str], limit: int, format: str) -> str:
        validate_output_format(format)
        df = data_source.get_trade_dates(start_date=start_date, end_date=end_date)
        meta = {"start_date": start_date or "default", "end_date": end_date or "default"}
        return format_table_output(df, format=format, max_rows=limit, meta=meta)
  • Concrete implementation in Baostock data source that queries the API for trade dates and returns a DataFrame.
    def get_trade_dates(self, start_date: Optional[str] = None, end_date: Optional[str] = None) -> pd.DataFrame:
        """Fetches trading dates using Baostock."""
        logger.info(
            f"Fetching trade dates from {start_date or 'default'} to {end_date or 'default'}")
        try:
            with baostock_login_context():  # Login might not be strictly needed for this, but keeping consistent
                rs = bs.query_trade_dates(
                    start_date=start_date, end_date=end_date)
    
                if rs.error_code != '0':
                    logger.error(
                        f"Baostock API error (Trade Dates): {rs.error_msg} (code: {rs.error_code})")
                    # Unlikely to have 'no record found' for dates, but handle API errors
                    raise DataSourceError(
                        f"Baostock API error fetching trade dates: {rs.error_msg} (code: {rs.error_code})")
    
                data_list = []
                while rs.next():
                    data_list.append(rs.get_row_data())
    
                if not data_list:
                    # This case should ideally not happen if the API returns a valid range
                    logger.warning(
                        f"No trade dates returned for range {start_date}-{end_date} (empty result set).")
                    raise NoDataFoundError(
                        f"No trade dates found for range {start_date}-{end_date} (empty result set).")
    
                result_df = pd.DataFrame(data_list, columns=rs.fields)
                logger.info(f"Retrieved {len(result_df)} trade date records.")
                return result_df
    
        except (LoginError, NoDataFoundError, DataSourceError, ValueError) as e:
            logger.warning(
                f"Caught known error fetching trade dates: {type(e).__name__}")
            raise e
        except Exception as e:
            logger.exception(f"Unexpected error fetching trade dates: {e}")
            raise DataSourceError(
                f"Unexpected error fetching trade dates: {e}")
Behavior3/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. It discloses the return format ('Markdown table') and the meaning of 'is_trading_day' values, which is helpful. However, it doesn't mention behavioral aspects like rate limits, authentication needs, or potential errors (e.g., invalid date formats), leaving gaps in understanding how the tool behaves in practice.

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 well-structured and appropriately sized. It starts with a clear purpose statement, followed by organized sections for arguments and returns, with no redundant information. Every sentence adds value, making it efficient and easy to parse.

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

Completeness3/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), the description is partially complete. It covers the core functionality and some parameters but misses details on 'limit' and 'format', and lacks behavioral context like error handling. It's adequate for basic use but has clear gaps for reliable agent operation.

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

Parameters4/5

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

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains 'start_date' and 'end_date' parameters with format details and defaults, and implies the output structure. However, it doesn't cover 'limit' or 'format' parameters, which are in the schema but undocumented in the description, preventing a perfect score.

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's purpose: 'Fetch trading dates within a specified range.' It uses a specific verb ('fetch') and identifies the resource ('trading dates'), making the function understandable. However, it doesn't explicitly differentiate from siblings like 'get_last_n_trading_days' or 'is_trading_day', which could cause confusion about when to use each.

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 alternatives. With many sibling tools related to trading dates (e.g., 'get_last_n_trading_days', 'is_trading_day', 'get_month_end_trading_dates'), there is no indication of how this tool differs or when it's preferred, leaving the agent without context for 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