Skip to main content
Glama
24mlight

A Share MCP

get_last_n_trading_days

Retrieve recent trading dates for A-share market analysis by specifying the number of days needed for financial calculations and reporting.

Instructions

Return the last N trading dates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNo

Implementation Reference

  • MCP tool handler function for 'get_last_n_trading_days'. It wraps the core use case logic with standardized error handling via run_tool_with_handling.
    @app.tool()
    def get_last_n_trading_days(days: int = 5) -> str:
        """Return the last N trading dates."""
        return run_tool_with_handling(
            lambda: uc_date.get_last_n_trading_days(active_data_source, days=days),
            context=f"get_last_n_trading_days:{days}",
        )
  • Core implementation that fetches recent trade dates from the financial data source and returns the last N trading days as a comma-separated string.
    def get_last_n_trading_days(data_source: FinancialDataSource, *, days: int) -> str:
        today = datetime.now()
        start = (today - timedelta(days=days * 2)).strftime("%Y-%m-%d")
        end = today.strftime("%Y-%m-%d")
        df = _fetch_trading_days(data_source, start_date=start, end_date=end)
        trading_days = df[df["is_trading_day"] == "1"]["calendar_date"].tolist()
        return ", ".join(trading_days[-days:]) if trading_days else ""
  • mcp_server.py:56-56 (registration)
    Invocation of the registration function that adds the get_last_n_trading_days tool (among others) to the FastMCP app.
    register_date_utils_tools(app, active_data_source)

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