Skip to content

160-tool MCP server for real-time global intelligence from free public APIs: markets, liquidity, prediction markets, SEC filings, conflict, military, aircraft-cohort early warning, migration and border flows, cyber, climate, news and more. Dated observation history, 29 research prompts, cited briefs, geofences, SSE dashboard. MIT, no paid API keys.

fix: Jinja2 None-crash in report templates — |default(0) → or 0

Marc Shadec12f45eaa8fb
diff --git a/src/world_intel_mcp/reports/templates/country_dossier.html b/src/world_intel_mcp/reports/templates/country_dossier.html
index 6304997..244c496 100644
--- a/src/world_intel_mcp/reports/templates/country_dossier.html
+++ b/src/world_intel_mcp/reports/templates/country_dossier.html
@@ -50,7 +50,7 @@
<div class="grid">
<div class="card" style="text-align:center;">
<h3>Instability Index</h3>
- <div class="stat-number">{{ "%.1f"|format(instability.instability_index|default(0)) }}</div>
+ <div class="stat-number">{{ "%.1f"|format(instability.instability_index or 0) }}</div>
<div class="stat-label" style="margin:0.5rem 0;">
<span class="risk-badge risk-{{ instability.risk_level|default('moderate')|lower }}">{{ instability.risk_level|default('Unknown') }}</span>
</div>
diff --git a/src/world_intel_mcp/reports/templates/market_overview.html b/src/world_intel_mcp/reports/templates/market_overview.html
index ee6814d..61cfc47 100644
--- a/src/world_intel_mcp/reports/templates/market_overview.html
+++ b/src/world_intel_mcp/reports/templates/market_overview.html
@@ -74,7 +74,7 @@
<h3>Sector Heatmap</h3>
<div style="display:flex;flex-wrap:wrap;gap:4px;margin-bottom:1.5rem;">
{% for s in sector_heatmap %}
- {% set pct = s.change_pct|default(0) %}
+ {% set pct = s.change_pct if s.change_pct is not none else 0 %}
{% if pct >= 2 %}
{% set bg = '#166534' %}
{% elif pct >= 0.5 %}
@@ -113,12 +113,12 @@
{% for c in crypto[:15] %}
<tr>
<td style="font-weight:600;">{{ c.symbol|default(c.id|default(''))|upper }}{% if c.name %} <span style="color:#64748b;font-weight:normal;">{{ c.name }}</span>{% endif %}</td>
- <td>{{ "${:,.2f}".format(c.current_price|default(c.price|default(0))) }}</td>
- <td class="{{ 'up' if (c.price_change_percentage_24h|default(c.change_24h|default(0))) >= 0 else 'down' }}">
- {{ "%+.2f"|format(c.price_change_percentage_24h|default(c.change_24h|default(0))) }}%
+ <td>{{ "${:,.2f}".format(c.current_price or c.price or 0) }}</td>
+ <td class="{{ 'up' if (c.price_change_percentage_24h or c.change_24h or 0) >= 0 else 'down' }}">
+ {{ "%+.2f"|format(c.price_change_percentage_24h or c.change_24h or 0) }}%
</td>
<td>
- {% set mcap = c.market_cap|default(0) %}
+ {% set mcap = c.market_cap or 0 %}
{% if mcap >= 1e12 %}${{ "%.1f"|format(mcap / 1e12) }}T
{% elif mcap >= 1e9 %}${{ "%.1f"|format(mcap / 1e9) }}B
{% elif mcap >= 1e6 %}${{ "%.1f"|format(mcap / 1e6) }}M
@@ -126,7 +126,7 @@
{% else %}—{% endif %}
</td>
<td>
- {% set vol = c.total_volume|default(c.volume_24h|default(0)) %}
+ {% set vol = c.total_volume or c.volume_24h or 0 %}
{% if vol >= 1e9 %}${{ "%.1f"|format(vol / 1e9) }}B
{% elif vol >= 1e6 %}${{ "%.1f"|format(vol / 1e6) }}M
{% elif vol > 0 %}${{ "{:,.0f}".format(vol) }}
@@ -186,8 +186,8 @@
<tr>
<td style="font-weight:600;">{{ name }}</td>
{% if data is mapping %}
- <td class="{{ 'up' if (data.flow|default(data.net_flow|default(0))) >= 0 else 'down' }}">
- {% set flow = data.flow|default(data.net_flow|default(0)) %}
+ <td class="{{ 'up' if (data.flow or data.net_flow or 0) >= 0 else 'down' }}">
+ {% set flow = data.flow or data.net_flow or 0 %}
{% if flow >= 1e9 %}${{ "%+.1f"|format(flow / 1e9) }}B
{% elif flow >= 1e6 %}${{ "%+.1f"|format(flow / 1e6) }}M
{% else %}{{ "%+.2f"|format(flow) }}{% endif %}