get_time_info
Retrieve current time in ISO format and timestamp along with the most recent trading day for Chinese stock market analysis and timing operations.
Instructions
获取当前时间(ISO格式、时间戳)和最近一个交易日
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/china_stock_mcp/server.py:438-457 (handler)The handler function implementing the get_time_info tool logic: retrieves current local time (ISO format and timestamp) and the most recent trading day by fetching and processing trade date history from akshare.def get_time_info() -> dict: """获取当前时间(ISO格式、时间戳)和最近一个交易日.""" local_time = datetime.now().astimezone() current_date = local_time.date() # 获取交易日历数据 trade_date_df = ak.tool_trade_date_hist_sina() trade_dates = [d for d in trade_date_df["trade_date"]] # 提取所有交易日期 # 筛选出小于等于当前日期的交易日,并按降序排列 past_dates = sorted([d for d in trade_dates if d <= current_date], reverse=True) # 找到最近的一个交易日 last_trading_day = past_dates[0].strftime("%Y-%m-%d") if past_dates else None return { "iso_format": local_time.isoformat(), "timestamp": local_time.timestamp(), "last_trading_day": last_trading_day, }
- src/china_stock_mcp/server.py:435-437 (registration)Registers the 'get_time_info' tool with the MCP framework using the @mcp.tool decorator, providing the tool name and description. The input schema is inferred from the function signature (no parameters required).@mcp.tool( name="get_time_info", description="获取当前时间(ISO格式、时间戳)和最近一个交易日" )