vn6295337 Claude Opus 4.5 commited on
Commit
584203d
·
1 Parent(s): f286eb6

Add status messages for empty news/sentiment data

Browse files

When news or sentiment MCPs return no usable data, emit a
"status" metric explaining why (e.g., "No recent news found")
instead of showing empty data in the UI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. mcp_client.py +7 -0
mcp_client.py CHANGED
@@ -324,13 +324,20 @@ async def _extract_and_emit_metrics(
324
  articles = result.get("articles", [])
325
  if articles:
326
  await emit_metric(progress_callback, source, "articles_found", len(articles))
 
 
327
 
328
  elif source == "sentiment":
 
329
  if result.get("composite_score") is not None:
330
  await emit_metric(progress_callback, source, "composite_score", result["composite_score"])
 
331
  metrics = result.get("metrics", {})
332
  if metrics.get("finnhub", {}).get("sentiment_score") is not None:
333
  await emit_metric(progress_callback, source, "finnhub_score", metrics["finnhub"]["sentiment_score"])
 
 
 
334
 
335
 
336
  def _aggregate_swot(metrics: dict, sources_available: list) -> dict:
 
324
  articles = result.get("articles", [])
325
  if articles:
326
  await emit_metric(progress_callback, source, "articles_found", len(articles))
327
+ else:
328
+ await emit_metric(progress_callback, source, "status", "No recent news found")
329
 
330
  elif source == "sentiment":
331
+ has_data = False
332
  if result.get("composite_score") is not None:
333
  await emit_metric(progress_callback, source, "composite_score", result["composite_score"])
334
+ has_data = True
335
  metrics = result.get("metrics", {})
336
  if metrics.get("finnhub", {}).get("sentiment_score") is not None:
337
  await emit_metric(progress_callback, source, "finnhub_score", metrics["finnhub"]["sentiment_score"])
338
+ has_data = True
339
+ if not has_data:
340
+ await emit_metric(progress_callback, source, "status", "No sentiment data available")
341
 
342
 
343
  def _aggregate_swot(metrics: dict, sources_available: list) -> dict: