Skip to main content
Glama
24mlight

A-Share MCP Server

previous_trading_day

Find the previous trading day for China's A-share market to calculate accurate date-based financial metrics and analysis.

Instructions

Get the previous trading day before the given date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes

Implementation Reference

  • MCP tool handler function for 'previous_trading_day'. Decorated with @app.tool() for registration and execution. Delegates to the use case layer's previous_trading_day function via run_tool_with_handling for error handling and logging.
    @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}",
        )
  • Core implementation of previous_trading_day logic. Fetches trading days from the data source around the given date and returns the most recent trading day strictly before the input date, or the input date if none found.
    def previous_trading_day(data_source: FinancialDataSource, *, date: str) -> str:
        target = datetime.strptime(date, "%Y-%m-%d")
        start = (target - timedelta(days=31)).strftime("%Y-%m-%d")
        df = _fetch_trading_days(data_source, start_date=start, end_date=date)
        days = df[df["is_trading_day"] == "1"]["calendar_date"].tolist()
        prev = max([d for d in days if d < date], default=None)
        return prev or date
  • mcp_server.py:56-56 (registration)
    Top-level registration call in the main MCP server file that registers the date_utils tools module, including the previous_trading_day tool.
    register_date_utils_tools(app, active_data_source)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but doesn't cover critical aspects like error handling (e.g., invalid date formats), performance traits, rate limits, or what happens if the input date is a non-trading day. This leaves significant gaps for an agent to understand operational 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 that front-loads the core functionality without any wasted words. It's appropriately sized for a simple tool, making it easy to parse quickly.

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 tool's moderate complexity (date-based calculation with financial context), no annotations, no output schema, and poor schema coverage, the description is incomplete. It doesn't explain return values, error cases, or dependencies on other tools like 'is_trading_day', leaving the agent with insufficient context for reliable use.

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 0% description coverage, with one required parameter 'date' undocumented. The description mentions 'given date' but adds no semantic details such as expected format (e.g., YYYY-MM-DD), timezone handling, or validation rules. It fails to compensate for the schema's lack of documentation.

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 verb ('Get') and resource ('previous trading day'), specifying it operates relative to a given date. However, it doesn't explicitly differentiate from sibling tools like 'get_last_n_trading_days' or 'next_trading_day', which handle similar trading date concepts, so it falls short of a perfect score.

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 such as 'get_last_n_trading_days' for multiple days or 'is_trading_day' for validation. It lacks context about prerequisites, exclusions, or typical use cases, offering only a basic functional statement.

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