hz_generate_summary
Generate Markdown summaries from Horizon content stages to condense information and extract key insights for analysis.
Instructions
从某阶段内容生成 Markdown 摘要。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run_id | Yes | ||
| language | No | zh | |
| source_stage | No | ||
| horizon_path | No | ||
| config_path | No | ||
| save_to_horizon_data | No |
Implementation Reference
- horizon_mcp/service.py:383-437 (handler)The business logic implementation of the summary generation tool.
async def generate_summary( self, run_id: str, language: str = "zh", source_stage: str | None = None, horizon_path: str | None = None, config_path: str | None = None, save_to_horizon_data: bool = False, ) -> dict[str, Any]: stage = source_stage or self._pick_summary_stage(run_id) items, ctx = self._load_stage_items( run_id=run_id, stage=stage, horizon_path=horizon_path, config_path=config_path, ) total_fetched = self._total_fetched(run_id, fallback=len(items)) date_str = datetime.now(timezone.utc).strftime("%Y-%m-%d") summarizer = ctx.runtime.DailySummarizer() summary = await summarizer.generate_summary( items, date_str, total_fetched, language=language, ) run_summary_path = self.run_store.save_summary(run_id, language, summary) published_path = None if save_to_horizon_data: storage = make_storage(ctx.runtime, ctx.config_path) published_path = storage.save_daily_summary(date_str, summary, language=language) summary_meta = { "summary_stage": stage, "summary_language": language, "summary_generated_at": datetime.now(timezone.utc).isoformat(), "summary_artifact": str(run_summary_path.resolve()), } if published_path: summary_meta["summary_published_path"] = str(Path(published_path).resolve()) meta = self.run_store.update_meta(run_id, summary_meta) return { "run_id": run_id, "language": language, "source_stage": stage, "total_fetched": total_fetched, "items_used": len(items), "summary_path": str(run_summary_path.resolve()), "published_path": str(Path(published_path).resolve()) if published_path else None, "preview": summary[:1200], "meta": meta, } - horizon_mcp/server.py:238-258 (registration)The MCP tool registration and handler entrypoint.
async def hz_generate_summary( run_id: str, language: str = "zh", source_stage: str | None = None, horizon_path: str | None = None, config_path: str | None = None, save_to_horizon_data: bool = False, ) -> dict[str, Any]: """从某阶段内容生成 Markdown 摘要。""" return await _run_tool( "hz_generate_summary", lambda: service.generate_summary( run_id=run_id, language=language, source_stage=source_stage, horizon_path=horizon_path, config_path=config_path, save_to_horizon_data=save_to_horizon_data, ), )