get_latest_news
Retrieve recent news data from multiple platforms to identify current trends and topics.
Instructions
获取最新一批爬取的新闻数据,快速了解当前热点
Args: platforms: 平台ID列表,如 ['zhihu', 'weibo', 'douyin'] - 不指定时:使用 config.yaml 中配置的所有平台 - 支持的平台来自 config/config.yaml 的 platforms 配置 - 每个平台都有对应的name字段(如"知乎"、"微博"),方便AI识别 limit: 返回条数限制,默认50,最大1000 注意:实际返回数量可能少于请求值,取决于当前可用的新闻总数 include_url: 是否包含URL链接,默认False(节省token)
Returns: JSON格式的新闻列表
重要:数据展示建议 本工具会返回完整的新闻列表(通常50条)给你。但请注意:
工具返回:完整的50条数据 ✅
建议展示:向用户展示全部数据,除非用户明确要求总结
用户期望:用户可能需要完整数据,请谨慎总结
何时可以总结:
用户明确说"给我总结一下"或"挑重点说"
数据量超过100条时,可先展示部分并询问是否查看全部
注意:如果用户询问"为什么只显示了部分",说明他们需要完整数据
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| platforms | No | ||
| limit | No | ||
| include_url | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp_server/tools/data_query.py:34-88 (handler)The implementation of the get_latest_news tool handler in DataQueryTools class.
def get_latest_news( self, platforms: Optional[List[str]] = None, limit: Optional[int] = None, include_url: bool = False ) -> Dict: """ 获取最新一批爬取的新闻数据 Args: platforms: 平台ID列表,如 ['zhihu', 'weibo'] limit: 返回条数限制,默认20 include_url: 是否包含URL链接,默认False(节省token) Returns: 新闻列表字典 Example: >>> tools = DataQueryTools() >>> result = tools.get_latest_news(platforms=['zhihu'], limit=10) >>> print(result['total']) 10 """ try: # 参数验证 platforms = validate_platforms(platforms) limit = validate_limit(limit, default=50) # 获取数据 news_list = self.data_service.get_latest_news( platforms=platforms, limit=limit, include_url=include_url ) return { "news": news_list, "total": len(news_list), "platforms": platforms, "success": True } except MCPError as e: return { "success": False, "error": e.to_dict() } except Exception as e: return { "success": False, "error": { "code": "INTERNAL_ERROR", "message": str(e) } }