Skip to main content
Glama
24mlight

A Share MCP

get_market_analysis_timeframe

Convert market analysis time periods into clear, human-readable labels for A-share stock data interpretation.

Instructions

Return a human-friendly timeframe label.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodNorecent

Implementation Reference

  • MCP tool handler decorated with @app.tool(). Logs the tool call and delegates execution to the use case layer 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",
        )
  • Core helper function implementing the timeframe calculation logic based on the given period parameter, independent of data source.
    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')}"
  • mcp_server.py:18-56 (registration)
    Imports and calls the register_date_utils_tools function which registers the get_market_analysis_timeframe tool among others.
    from src.tools.date_utils import register_date_utils_tools
    from src.tools.analysis import register_analysis_tools
    from src.tools.helpers import register_helpers_tools
    
    # --- Logging Setup ---
    # Call the setup function from utils
    # You can control the default level here (e.g., logging.DEBUG for more verbose logs)
    setup_logging(level=logging.INFO)
    logger = logging.getLogger(__name__)
    
    # --- Dependency Injection ---
    # Instantiate the data source - easy to swap later if needed
    active_data_source: FinancialDataSource = BaostockDataSource()
    
    # --- Get current date for system prompt ---
    current_date = datetime.now().strftime("%Y-%m-%d")
    
    # --- FastMCP App Initialization ---
    app = FastMCP(
        server_name="a_share_data_provider",
        description=f"""今天是{current_date}。提供中国A股市场数据分析工具。此服务提供客观数据分析,用户需自行做出投资决策。数据分析基于公开市场信息,不构成投资建议,仅供参考。
    
    ⚠️ 重要说明:
    1. 最新交易日不一定是今天,需要从 get_latest_trading_date() 获取
    2. 请始终使用 get_latest_trading_date() 工具获取实际当前最近的交易日,不要依赖训练数据中的日期认知
    3. 当分析"最近"或"近期"市场情况时,必须首先调用 get_market_analysis_timeframe() 工具确定实际的分析时间范围
    4. 任何涉及日期的分析必须基于工具返回的实际数据,不得使用过时或假设的日期
    """,
        # Specify dependencies for installation if needed (e.g., when using `mcp install`)
        # dependencies=["baostock", "pandas"]
    )
    
    # --- 注册各模块的工具 ---
    register_stock_market_tools(app, active_data_source)
    register_financial_report_tools(app, active_data_source)
    register_index_tools(app, active_data_source)
    register_market_overview_tools(app, active_data_source)
    register_macroeconomic_tools(app, active_data_source)
    register_date_utils_tools(app, active_data_source)
Behavior2/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 mentions returning a 'human-friendly timeframe label' but does not specify format, data source, or any constraints like rate limits or permissions. This leaves significant gaps in understanding how the tool behaves beyond its basic output.

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, clear sentence that directly states the tool's function without unnecessary words. It is front-loaded and efficient, making it easy to grasp quickly, which is ideal for conciseness.

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

Completeness2/5

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

Given the lack of annotations, output schema, and low parameter coverage, the description is incomplete. It does not provide enough context about the tool's behavior, output format, or how it integrates with other tools, making it inadequate for a tool that likely deals with financial timeframes in a complex server environment.

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?

The input schema has one parameter 'period' with 0% description coverage, and the tool description does not explain what 'period' means, its possible values, or how it affects the output. With low schema coverage, the description fails to compensate, leaving the parameter's semantics unclear.

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

Purpose3/5

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

The description states the tool 'Return a human-friendly timeframe label,' which clarifies its purpose as providing a formatted timeframe label. However, it lacks specificity about what 'market analysis' entails or what context this timeframe is used for, making it somewhat vague compared to more detailed sibling tools like get_historical_k_data or get_recent_trading_range.

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?

There is no guidance on when to use this tool versus alternatives. Sibling tools include get_last_n_trading_days, get_recent_trading_range, and get_trade_dates, which might offer similar or overlapping functionality, but the description does not mention any distinctions, prerequisites, or exclusions 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