时间参数是 MCP Server 中最容易踩坑的地方:
- 坑一:LLM 常传入不合法的时间戳(如 float 或未来时间),导致接口直接报错甚至需要重启 Server。
- 坑二:LLM 对"现在时间"概念模糊,可能传入 2023-06-25 这类过老的时间戳,查询保留 30 天的 LogStore 时必然为空。
规避方法:
from_timestamp: int = Field(
int(datetime.now().timestamp()) - 3600,
description="from timestamp, unit is second"
),
to_timestamp: int = Field(
int(datetime.now().timestamp()),
description="to timestamp, unit is second"
),
直接给出默认最近 1 小时值,极大概率覆盖查询需求;如返回为空,模型会自动怀疑是否是时间问题并调整。




