Skip to main content
Glama
24mlight

A-Share MCP Server

get_market_analysis_timeframe

Convert technical period inputs into readable timeframe labels for analyzing China's A-share market data and trends.

Instructions

Return a human-friendly timeframe label.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodNorecent

Implementation Reference

  • The MCP tool handler for 'get_market_analysis_timeframe', decorated with @app.tool(). It logs the call and delegates execution to the use_cases.date_utils implementation via run_tool_with_handling.
    @app.tool()
    def get_market_analysis_timeframe(period: str = "recent") -> str:
        """Return a human-friendly timeframe label."""
        logger.info(f"Tool 'get_market_analysis_timeframe' called with period={period}")
        return run_tool_with_handling(
            lambda: uc_date.get_market_analysis_timeframe(period=period),
            context="get_market_analysis_timeframe",
        )
  • The core business logic implementation that computes a human-readable timeframe string (e.g., '2024-11-01 至 2024-12-10') based on the 'period' parameter and current date.
    def get_market_analysis_timeframe(period: str = "recent") -> str:
        now = datetime.now()
        end_date = now
        if period == "recent":
            if now.day < 15:
                if now.month == 1:
                    start_date = datetime(now.year - 1, 11, 1)
                else:
                    prev_month = now.month - 1
                    start_month = prev_month if prev_month > 0 else 12
                    start_year = now.year if prev_month > 0 else now.year - 1
                    start_date = datetime(start_year, start_month, 1)
            else:
                start_date = datetime(now.year, now.month, 1)
        elif period == "quarter":
            quarter = (now.month - 1) // 3 + 1
            start_month = (quarter - 1) * 3 + 1
            start_date = datetime(now.year, start_month, 1)
        elif period == "half_year":
            start_month = 1 if now.month <= 6 else 7
            start_date = datetime(now.year, start_month, 1)
        elif period == "year":
            start_date = datetime(now.year, 1, 1)
        else:
            raise ValueError("Invalid period. Use 'recent', 'quarter', 'half_year', or 'year'.")
        return f"{start_date.strftime('%Y-%m-%d')} 至 {end_date.strftime('%Y-%m-%d')}"
  • The registration function that defines and registers the 'get_market_analysis_timeframe' tool (along with other date tools) using FastMCP's @app.tool() decorator. Called from mcp_server.py.
    def register_date_utils_tools(app: FastMCP, active_data_source: FinancialDataSource):
        """Register date utility tools."""
    
        @app.tool()
        def get_latest_trading_date() -> str:
            """Get the latest trading date up to today."""
            logger.info("Tool 'get_latest_trading_date' called")
            return run_tool_with_handling(
                lambda: uc_date.get_latest_trading_date(active_data_source),
                context="get_latest_trading_date",
            )
    
        @app.tool()
        def get_market_analysis_timeframe(period: str = "recent") -> str:
            """Return a human-friendly timeframe label."""
            logger.info(f"Tool 'get_market_analysis_timeframe' called with period={period}")
            return run_tool_with_handling(
                lambda: uc_date.get_market_analysis_timeframe(period=period),
                context="get_market_analysis_timeframe",
            )
    
        @app.tool()
        def is_trading_day(date: str) -> str:
            """Check if a specific date is a trading day."""
            return run_tool_with_handling(
                lambda: uc_date.is_trading_day(active_data_source, date=date),
                context=f"is_trading_day:{date}",
            )
    
        @app.tool()
        def previous_trading_day(date: str) -> str:
            """Get the previous trading day before the given date."""
            return run_tool_with_handling(
                lambda: uc_date.previous_trading_day(active_data_source, date=date),
                context=f"previous_trading_day:{date}",
            )
    
        @app.tool()
        def next_trading_day(date: str) -> str:
            """Get the next trading day after the given date."""
            return run_tool_with_handling(
                lambda: uc_date.next_trading_day(active_data_source, date=date),
                context=f"next_trading_day:{date}",
            )
    
        @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}",
            )
    
        @app.tool()
        def get_recent_trading_range(days: int = 5) -> str:
            """Return a date range string covering the recent N trading days."""
            return run_tool_with_handling(
                lambda: uc_date.get_recent_trading_range(active_data_source, days=days),
                context=f"get_recent_trading_range:{days}",
            )
    
        @app.tool()
        def get_month_end_trading_dates(year: int) -> str:
            """Return month-end trading dates for a given year."""
            return run_tool_with_handling(
                lambda: uc_date.get_month_end_trading_dates(active_data_source, year=year),
                context=f"get_month_end_trading_dates:{year}",
            )
Behavior1/5

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

No annotations are provided, so the description carries full burden but offers minimal behavioral insight. It mentions 'human-friendly timeframe label' but does not disclose what that entails (e.g., format, source, or any traits like rate limits, permissions, or side effects). This is inadequate for a tool with unknown behavior.

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 a single, efficient sentence with no wasted words. It is appropriately sized and front-loaded, making it easy to parse quickly, though this conciseness comes at the cost of detail.

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 (1 parameter with 0% schema coverage, no output schema, no annotations), the description is incomplete. It does not explain what the tool returns, how it behaves, or provide enough context for effective use, failing to meet minimum requirements for such a tool.

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%, and the description does not compensate by explaining the 'period' parameter. It fails to add meaning beyond the schema, such as what 'period' values are valid or what 'human-friendly' implies for input handling, leaving parameters largely undocumented.

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 'Return a human-friendly timeframe label' is tautological—it restates the tool name 'get_market_analysis_timeframe' without specifying what resource or data it operates on. It lacks a clear verb-resource pairing and does not distinguish this tool from its many siblings, which mostly retrieve financial data (e.g., stock info, economic indicators).

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. Given the sibling tools include various data retrieval functions (e.g., get_historical_k_data, get_recent_trading_range), the description fails to indicate context, prerequisites, or exclusions, leaving the agent without direction.

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