vn6295337 Claude Opus 4.5 commited on
Commit
7de6ec4
·
1 Parent(s): fbe5ac1

Fix mcp_client.py - restore nested financials/debt access

Browse files

The get_sec_fundamentals_basket returns nested structure:
{"financials": {...}, "debt": {...}}

Reverted incorrect change that tried to access result.get("revenue")
directly. Correct access is result.get("financials").get("revenue").

🤖 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 +8 -6
mcp_client.py CHANGED
@@ -270,9 +270,12 @@ async def _extract_and_emit_metrics(
270
  return
271
 
272
  if source == "financials":
273
- # Result IS the financials data directly (not nested under "financials" key)
 
 
 
274
  # Revenue has temporal data from SEC EDGAR
275
- revenue = result.get("revenue") or {}
276
  if isinstance(revenue, dict) and revenue.get("value"):
277
  await emit_metric(
278
  progress_callback, source, "revenue", revenue["value"],
@@ -282,7 +285,7 @@ async def _extract_and_emit_metrics(
282
  )
283
 
284
  # Net margin - now a dict with temporal data
285
- net_margin = result.get("net_margin_pct") or result.get("net_margin")
286
  if isinstance(net_margin, dict) and net_margin.get("value") is not None:
287
  await emit_metric(
288
  progress_callback, source, "net_margin", net_margin["value"],
@@ -295,7 +298,7 @@ async def _extract_and_emit_metrics(
295
  await emit_metric(progress_callback, source, "net_margin", net_margin)
296
 
297
  # EPS has temporal data
298
- eps = result.get("eps") or {}
299
  if isinstance(eps, dict) and eps.get("value"):
300
  await emit_metric(
301
  progress_callback, source, "EPS", eps["value"],
@@ -304,8 +307,7 @@ async def _extract_and_emit_metrics(
304
  form=eps.get("form")
305
  )
306
 
307
- # Debt metrics are in the debt sub-object from fetch_debt_metrics
308
- debt = result.get("debt") or {}
309
  debt_to_equity = debt.get("debt_to_equity")
310
  if isinstance(debt_to_equity, dict) and debt_to_equity.get("value") is not None:
311
  await emit_metric(
 
270
  return
271
 
272
  if source == "financials":
273
+ # Result structure: {"financials": {...}, "debt": {...}, ...}
274
+ financials = result.get("financials") or {}
275
+ debt = result.get("debt") or {}
276
+
277
  # Revenue has temporal data from SEC EDGAR
278
+ revenue = financials.get("revenue") or {}
279
  if isinstance(revenue, dict) and revenue.get("value"):
280
  await emit_metric(
281
  progress_callback, source, "revenue", revenue["value"],
 
285
  )
286
 
287
  # Net margin - now a dict with temporal data
288
+ net_margin = financials.get("net_margin_pct") or financials.get("net_margin")
289
  if isinstance(net_margin, dict) and net_margin.get("value") is not None:
290
  await emit_metric(
291
  progress_callback, source, "net_margin", net_margin["value"],
 
298
  await emit_metric(progress_callback, source, "net_margin", net_margin)
299
 
300
  # EPS has temporal data
301
+ eps = financials.get("eps") or {}
302
  if isinstance(eps, dict) and eps.get("value"):
303
  await emit_metric(
304
  progress_callback, source, "EPS", eps["value"],
 
307
  form=eps.get("form")
308
  )
309
 
310
+ # Debt metrics from the debt sub-object
 
311
  debt_to_equity = debt.get("debt_to_equity")
312
  if isinstance(debt_to_equity, dict) and debt_to_equity.get("value") is not None:
313
  await emit_metric(