ソースを参照

news-mcp: include_articles works with cached get_event_summary

Lukas Goldschmidt 1 ヶ月 前
コミット
04927d3167
1 ファイル変更16 行追加1 行削除
  1. 16 1
      news_mcp/mcp_server_fastmcp.py

+ 16 - 1
news_mcp/mcp_server_fastmcp.py

@@ -184,7 +184,7 @@ async def get_event_summary(event_id: str, include_articles: bool = False):
         ttl_hours=CLUSTERS_TTL_HOURS,
     )
     if cached_summary:
-        return {
+        out = {
             "event_id": event_id,
             "headline": cached_summary.get("headline"),
             "mergedSummary": cached_summary.get("mergedSummary"),
@@ -192,6 +192,21 @@ async def get_event_summary(event_id: str, include_articles: bool = False):
             "sources": cached_summary.get("sources", []),
         }
 
+        if include_articles:
+            cluster = store.get_cluster_by_id(event_id)
+            arts = (cluster or {}).get("articles", []) or []
+            out["articles"] = [
+                {
+                    "title": a.get("title"),
+                    "url": a.get("url"),
+                    "source": a.get("source"),
+                    "timestamp": a.get("timestamp"),
+                }
+                for a in arts
+                if isinstance(a, dict)
+            ]
+        return out
+
     cluster = store.get_cluster_by_id(event_id)
     if not cluster:
         return {