search_related_news_history
Find historically related news articles based on a reference text, using customizable time ranges and relevance thresholds to identify connections in past coverage.
Instructions
基于种子新闻,在历史数据中搜索相关新闻
Args: reference_text: 参考新闻标题(完整或部分) time_preset: 时间范围预设值,可选: - "yesterday": 昨天 - "last_week": 上周 (7天) - "last_month": 上个月 (30天) - "custom": 自定义日期范围(需要提供 start_date 和 end_date) threshold: 相关性阈值,0-1之间,默认0.4 注意:综合相似度计算(70%关键词重合 + 30%文本相似度) 阈值越高匹配越严格,返回结果越少 limit: 返回条数限制,默认50,最大100 注意:实际返回数量取决于相关性匹配结果,可能少于请求值 include_url: 是否包含URL链接,默认False(节省token)
Returns: JSON格式的相关新闻列表,包含相关性分数和时间分布
重要:数据展示策略
本工具返回完整的相关新闻列表
默认展示方式:展示全部返回的新闻(包括相关性分数)
仅在用户明确要求"总结"或"挑重点"时才进行筛选
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| reference_text | Yes | ||
| time_preset | No | yesterday | |
| threshold | No | ||
| limit | No | ||
| include_url | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp_server/server.py:542-582 (handler)The MCP tool handler function 'search_related_news_history' in mcp_server/server.py, which acts as the entry point and interface for the tool, calling the underlying search implementation.
async def search_related_news_history( reference_text: str, time_preset: str = "yesterday", threshold: float = 0.4, limit: int = 50, include_url: bool = False ) -> str: """ 基于种子新闻,在历史数据中搜索相关新闻 Args: reference_text: 参考新闻标题(完整或部分) time_preset: 时间范围预设值,可选: - "yesterday": 昨天 - "last_week": 上周 (7天) - "last_month": 上个月 (30天) - "custom": 自定义日期范围(需要提供 start_date 和 end_date) threshold: 相关性阈值,0-1之间,默认0.4 注意:综合相似度计算(70%关键词重合 + 30%文本相似度) 阈值越高匹配越严格,返回结果越少 limit: 返回条数限制,默认50,最大100 注意:实际返回数量取决于相关性匹配结果,可能少于请求值 include_url: 是否包含URL链接,默认False(节省token) Returns: JSON格式的相关新闻列表,包含相关性分数和时间分布 **重要:数据展示策略** - 本工具返回完整的相关新闻列表 - **默认展示方式**:展示全部返回的新闻(包括相关性分数) - 仅在用户明确要求"总结"或"挑重点"时才进行筛选 """ tools = _get_tools() result = tools['search'].search_related_news_history( reference_text=reference_text, time_preset=time_preset, threshold=threshold, limit=limit, include_url=include_url ) return json.dumps(result, ensure_ascii=False, indent=2) - mcp_server/tools/search_tools.py:494-503 (handler)The actual implementation logic of 'search_related_news_history' inside the SearchTools class.
def search_related_news_history( self, reference_text: str, time_preset: str = "yesterday", start_date: Optional[datetime] = None, end_date: Optional[datetime] = None, threshold: float = 0.4, limit: int = 50, include_url: bool = False ) -> Dict: