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.

Migration in the CLI and collector; surges keep IDP-only countries

Phoenix Agent (mac-studio)8a7c0b097e33
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d2aebf..29ba7c9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,23 @@ Cross-border migration and a fix to the displacement summary.
absolute and per-1,000 terms with world regions, a World Bank region
filter, or one country's series since 1960.
+### Added: migration in the CLI and collector
+- `intel migration-flows`, `intel migration-surges`, `intel migration-history`
+ and `intel net-migration` render the four tools as tables, with the same
+ error surfacing as every other command. A change with no prior-year
+ figure renders "n/a", never "+0".
+- The collector gains `migration_surges` and `net_migration` (55 sources)
+ and a `migration` domain group (`--sources migration`, which also takes
+ `displacement`).
+
+### Fixed: migration surges
+- A country whose UNHCR rows were all internal (IDPs, nobody abroad) never
+ entered the surge comparison, so its IDP jump was dropped.
+- Internal-displacement rows now carry `idps_first_reported` when the prior
+ year had no IDP figure. Live 2024 -> 2025 ranked Guatemala (+573,000) and
+ Cambodia (+517,555) as IDP surges from a prior figure of 0, which can be
+ a first report rather than new displacement; the CLI labels those rows.
+
### Fixed: displacement summary
- `intel_displacement_summary` never sent UNHCR `coo_all=true`, so UNHCR
answered with one global row and `by_origin` held a single entry named
diff --git a/CLAUDE.md b/CLAUDE.md
index 39900b2..30e7b7e 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -57,7 +57,7 @@ collector.py (daemon) ──┘
**Vector store** (`vector_store.py`): Optional Qdrant + FastEmbed (BAAI/bge-small-en-v1.5, 384-dim ONNX). Async background worker queue (`asyncio.Queue` + `asyncio.to_thread()`) for non-blocking storage. Fetcher auto-stores on fresh HTTP fetches. 65+ source name → category mappings for filtered search.
-**Collector** (`collector.py`): Standalone daemon for 24/7 vector store population. 53 sources organized by domain, with `--daemon`, `--interval`, `--sources` CLI args. Dynamic import via `_import_fetch_fn()`. Per-source timeout overrides in `SOURCE_TIMEOUTS` (the `aoi_digest` sweep gets 240 s; everything else the flat 45 s). Entry point: `intel-collector`.
+**Collector** (`collector.py`): Standalone daemon for 24/7 vector store population. 55 sources organized by domain, with `--daemon`, `--interval`, `--sources` CLI args. Dynamic import via `_import_fetch_fn()`. Per-source timeout overrides in `SOURCE_TIMEOUTS` (the `aoi_digest` sweep gets 240 s; everything else the flat 45 s). Entry point: `intel-collector`.
**Reports** (`reports.py`): PDF/HTML intelligence report generator. Collects 18 domains in parallel, renders styled HTML, converts to PDF via WeasyPrint. Optional dependency: `pip install -e ".[pdf]"`.
diff --git a/README.md b/README.md
index c2ecd41..3d5824f 100644
--- a/README.md
+++ b/README.md
@@ -127,6 +127,8 @@ Map-first ops center: Leaflet map with toggle-able layers (quakes, military, con
```bash
intel markets # stock indices
intel earthquakes --min-mag 5.0
+intel migration-surges # year-over-year displacement jumps (UNHCR)
+intel migration-flows -o Sudan
intel status # cache + circuit breaker health
```
@@ -145,7 +147,7 @@ collector.py (daemon) ─┘
- **CircuitBreaker**: Per-source tracking. 3 consecutive failures trips for 5 minutes. Each RSS feed gets its own breaker.
- **Cache**: SQLite WAL-mode TTL cache. `get()` returns live data, `get_stale()` returns expired data for fallback.
- **VectorStore**: Qdrant + FastEmbed (BAAI/bge-small-en-v1.5, 384-dim). Async background worker queue for non-blocking storage. Enables semantic search across all accumulated intelligence.
-- **Collector**: Standalone daemon that fetches all 53 sources in parallel and populates the vector store. Run once or as a daemon (default: 5-minute interval). Includes the AOI change sweep, so a running daemon continuously watches every defined geofence.
+- **Collector**: Standalone daemon that fetches all 55 sources in parallel and populates the vector store. Run once or as a daemon (default: 5-minute interval). Includes the AOI change sweep, so a running daemon continuously watches every defined geofence.
- **Sources** (`sources/*.py`): 30+ modules, each exports `async def fetch_*(fetcher, **kwargs) -> dict`.
- **Analysis** (`analysis/*.py`): Cross-domain synthesis — signal aggregation, instability indexing, NLP, company enrichment, macro composite.
- **Config** (`config/*.py`): Curated datasets — 22 hotspots, 70+ bases, 40 ports, 24 pipelines, 24 nuclear facilities, 34 cables, 48 datacenters, 27 spaceports, 82 exchanges.
diff --git a/src/world_intel_mcp/cli.py b/src/world_intel_mcp/cli.py
index d67ea80..af3204c 100644
--- a/src/world_intel_mcp/cli.py
+++ b/src/world_intel_mcp/cli.py
@@ -49,6 +49,7 @@ from .sources import (
intelligence,
prediction,
displacement,
+ migration,
aviation,
cyber,
shipping,
@@ -929,6 +930,255 @@ def displacement_cmd(ctx: click.Context, year: int | None) -> None:
console.print(table)
+# ---------------------------------------------------------------------------
+# Migration
+# ---------------------------------------------------------------------------
+
+
+def _signed(value: Any) -> str:
+ return "n/a" if value is None else f"{value:+,}"
+
+
[email protected](name="migration-flows")
[email protected]("--year", "-y", default=None, type=int, help="Reporting year (default: latest)")
[email protected]("--origin", "-o", default=None, help="Origin country, ISO3 code or region")
[email protected]("--destination", "-d", default=None, help="Destination country, ISO3 code or region")
[email protected]("--limit", "-n", default=25, help="Max corridors")
[email protected]("--min-people", default=0, help="Skip corridors smaller than this")
+def migration_flows_cmd(
+ ctx: click.Context,
+ year: int | None,
+ origin: str | None,
+ destination: str | None,
+ limit: int,
+ min_people: int,
+) -> None:
+ """Largest UNHCR origin -> destination corridors (year-end stocks)."""
+ f = _get_fetcher()
+ data = _run(
+ migration.fetch_migration_flows(
+ f, year=year, origin=origin, destination=destination,
+ limit=limit, min_people=min_people,
+ )
+ )
+ if _bail_on_error(ctx, data):
+ return
+
+ filters = [
+ f"{label} {escape(sel['name'])}"
+ for label, sel in (("from", data.get("origin_filter")), ("to", data.get("destination_filter")))
+ if sel
+ ]
+ console.print(
+ f"[bold]Displacement corridors ({data.get('year', '?')})[/bold]"
+ + (f" {' '.join(filters)}" if filters else "")
+ )
+ console.print(
+ f" {data.get('corridor_count', 0):,} corridors, "
+ f"{data.get('total_people', 0):,} people\n"
+ )
+ table = Table(title="Corridors", box=box.SIMPLE_HEAVY)
+ table.add_column("Origin", style="bold")
+ table.add_column("Destination")
+ table.add_column("People", justify="right")
+ table.add_column("Change vs prior year", justify="right")
+ for c in data.get("corridors", []):
+ table.add_row(
+ _cell(c.get("origin", "")),
+ _cell(c.get("destination", "")),
+ f"{c.get('people', 0):,}",
+ _signed(c.get("change")),
+ )
+ console.print(table)
+
+
[email protected](name="migration-surges")
[email protected]("--year", "-y", default=None, type=int, help="Reporting year (default: latest)")
[email protected]("--min-change", default=50_000, help="Smallest year-over-year change to report")
[email protected]("--limit", "-n", default=20, help="Max rows per ranking")
+def migration_surges_cmd(
+ ctx: click.Context, year: int | None, min_change: int, limit: int
+) -> None:
+ """Year-over-year jumps in people displaced from each origin."""
+ f = _get_fetcher()
+ data = _run(
+ migration.fetch_migration_surges(f, year=year, min_change=min_change, limit=limit)
+ )
+ if _bail_on_error(ctx, data):
+ return
+
+ console.print(
+ f"[bold]Displacement surges {data.get('compared_with', '?')} -> "
+ f"{data.get('year', '?')}[/bold] (min change {data.get('min_change', 0):,})\n"
+ )
+ for key, title in (
+ ("origin_outflow_increases", "Rising outflows by origin"),
+ ("origin_outflow_decreases", "Falling outflows by origin"),
+ ):
+ table = Table(title=title, box=box.SIMPLE_HEAVY)
+ table.add_column("Origin", style="bold")
+ table.add_column("People abroad", justify="right")
+ table.add_column("Change", justify="right")
+ table.add_column("% of pop.", justify="right")
+ table.add_column("Level")
+ for o in data.get(key, []):
+ pct = o.get("change_abroad_pct_of_population")
+ table.add_row(
+ _cell(o.get("origin", "")),
+ f"{o.get('people_abroad', 0):,}",
+ _signed(o.get("change_abroad")),
+ "n/a" if pct is None else f"{pct:+.2f}%",
+ o.get("level") or "",
+ )
+ console.print(table)
+
+ idps = data.get("internal_displacement_increases", [])
+ if idps:
+ table = Table(title="Rising internal displacement", box=box.SIMPLE_HEAVY)
+ table.add_column("Country", style="bold")
+ table.add_column("IDPs", justify="right")
+ table.add_column("Change", justify="right")
+ table.add_column("Note")
+ for o in idps:
+ table.add_row(
+ _cell(o.get("origin", "")), f"{o.get('idps', 0):,}", _signed(o.get("change_idps")),
+ "none reported prior year" if o.get("idps_first_reported") else "",
+ )
+ console.print(table)
+
+ table = Table(title="Rising corridors", box=box.SIMPLE_HEAVY)
+ table.add_column("Origin", style="bold")
+ table.add_column("Destination")
+ table.add_column("People", justify="right")
+ table.add_column("Change", justify="right")
+ for c in data.get("corridor_increases", []):
+ table.add_row(
+ _cell(c.get("origin", "")), _cell(c.get("destination", "")),
+ f"{c.get('people', 0):,}", _signed(c.get("change")),
+ )
+ console.print(table)
+
+ for o in data.get("unattributed_origin_changes", []):
+ console.print(
+ f" [dim]Not ranked: {escape(str(o.get('origin', '')))} "
+ f"{_signed(o.get('change_abroad'))} (not a country; often a host reporting change)[/dim]"
+ )
+ console.print(f"[dim]Levels are {escape(data.get('levels', {}).get('basis', 'heuristic'))}.[/dim]")
+
+
[email protected](name="migration-history")
+ "--role", "-r", type=click.Choice(["origin", "host"]), default="origin",
+ help="origin = people from the country; host = people it hosts",
+)
[email protected]("--from", "year_from", default=1951, help="First year")
[email protected]("--to", "year_to", default=None, type=int, help="Last year")
+def migration_history_cmd(
+ ctx: click.Context, country: str, role: str, year_from: int, year_to: int | None
+) -> None:
+ """One country's UNHCR displacement series and its largest waves."""
+ f = _get_fetcher()
+ data = _run(
+ migration.fetch_migration_history(
+ f, country=country, role=role, year_from=year_from, year_to=year_to
+ )
+ )
+ if _bail_on_error(ctx, data):
+ return
+
+ console.print(
+ f"[bold]{escape(str(data.get('country', country)))} as {role}[/bold]: "
+ f"{escape(str(data.get('meaning', '')))}"
+ )
+ peak, latest = data.get("peak"), data.get("latest")
+ if latest:
+ idps = f", {latest.get('idps', 0):,} IDPs" if role == "origin" else ""
+ console.print(f" Latest {latest.get('year')}: {latest.get('people', 0):,} people{idps}")
+ if peak:
+ console.print(f" Peak {peak.get('year')}: {peak.get('people', 0):,} people")
+ console.print(f" {data.get('years', 0)} years of data since {data.get('first_year', '?')}\n")
+
+ table = Table(title="Largest waves", box=box.SIMPLE_HEAVY)
+ table.add_column("Year", style="bold")
+ table.add_column("People", justify="right")
+ table.add_column("Increase", justify="right")
+ table.add_column("% change", justify="right")
+ for w in data.get("largest_waves", []):
+ pct = w.get("pct_change")
+ table.add_row(
+ str(w.get("year", "")), f"{w.get('people', 0):,}", _signed(w.get("increase")),
+ "n/a" if pct is None else f"{pct:+.1f}%",
+ )
+ console.print(table)
+
+
[email protected](name="net-migration")
[email protected]("--country", "-c", default=None, help="One country: its series since 1960")
[email protected]("--region", "-r", default=None, help="World Bank region code or name")
[email protected]("--limit", "-n", default=20, help="Max rows per ranking")
+def net_migration_cmd(
+ ctx: click.Context, country: str | None, region: str | None, limit: int
+) -> None:
+ """World Bank net migration, all reasons (immigrants minus emigrants)."""
+ f = _get_fetcher()
+ data = _run(
+ migration.fetch_net_migration(f, country=country, region=region, limit=limit)
+ )
+ if _bail_on_error(ctx, data):
+ return
+
+ if country:
+ latest = data.get("latest") or {}
+ console.print(
+ f"[bold]Net migration: {escape(str(data.get('country', country)))}[/bold] "
+ f"({escape(str(data.get('region', '')))})"
+ )
+ if latest:
+ console.print(
+ f" Latest {latest.get('year')}: {_signed(latest.get('net_migration'))}"
+ f" ({latest.get('per_1000')} per 1,000)\n"
+ )
+ for key, title in (
+ ("largest_net_inflow_years", "Largest net inflow years"),
+ ("largest_net_outflow_years", "Largest net outflow years"),
+ ):
+ table = Table(title=title, box=box.SIMPLE_HEAVY)
+ table.add_column("Year", style="bold")
+ table.add_column("Net migration", justify="right")
+ table.add_column("Per 1,000", justify="right")
+ for e in data.get(key, []):
+ table.add_row(
+ str(e.get("year", "")), _signed(e.get("net_migration")),
+ "n/a" if e.get("per_1000") is None else f"{e['per_1000']:+.2f}",
+ )
+ console.print(table)
+ else:
+ scope = escape(str(data.get("region_filter") or "all countries"))
+ console.print(f"[bold]Net migration, latest year ({scope})[/bold]\n")
+ for key, title in (
+ ("top_net_immigration", "Largest net immigration"),
+ ("top_net_emigration", "Largest net emigration"),
+ ):
+ table = Table(title=title, box=box.SIMPLE_HEAVY)
+ table.add_column("Country", style="bold")
+ table.add_column("Year", justify="right")
+ table.add_column("Net migration", justify="right")
+ table.add_column("Per 1,000", justify="right")
+ for r in data.get(key, []):
+ table.add_row(
+ _cell(r.get("name", "")), str(r.get("year", "")),
+ _signed(r.get("net_migration")),
+ "n/a" if r.get("per_1000") is None else f"{r['per_1000']:+.2f}",
+ )
+ console.print(table)
+ console.print("[dim]Source: UN WPP via World Bank; recent years can be projections.[/dim]")
+
+
# ---------------------------------------------------------------------------
# Aviation
# ---------------------------------------------------------------------------
diff --git a/src/world_intel_mcp/collector.py b/src/world_intel_mcp/collector.py
index 4259dbd..4211562 100644
--- a/src/world_intel_mcp/collector.py
+++ b/src/world_intel_mcp/collector.py
@@ -62,6 +62,10 @@ SOURCES = [
("acled_events", "sources.conflict", "fetch_acled_events", {}),
("ucdp_events", "sources.conflict", "fetch_ucdp_events", {}),
("displacement", "sources.displacement", "fetch_displacement_summary", {}),
+ # Migration (2): UNHCR year-over-year surges and World Bank net migration.
+ # Both are annual series; the fetcher cache keeps repeat cycles cheap.
+ ("migration_surges", "sources.migration", "fetch_migration_surges", {}),
+ ("net_migration", "sources.migration", "fetch_net_migration", {}),
# Military (2)
("military_flights", "sources.military", "fetch_military_flights", {}),
# Infrastructure (4)
@@ -152,6 +156,7 @@ DOMAIN_GROUPS = {
"cyclones",
],
"conflict": ["acled_events", "ucdp_events", "displacement"],
+ "migration": ["displacement", "migration_surges", "net_migration"],
"military": ["military_flights"],
"infrastructure": ["internet_outages", "cable_health", "service_status"],
"maritime": ["nav_warnings"],
diff --git a/src/world_intel_mcp/sources/migration.py b/src/world_intel_mcp/sources/migration.py
index 9bd9a1d..a0a2344 100644
--- a/src/world_intel_mcp/sources/migration.py
+++ b/src/world_intel_mcp/sources/migration.py
@@ -398,6 +398,9 @@ async def fetch_migration_surges(
for (o, _d), e in table.items():
a = origins.setdefault(o, {"origin_name": e["origin_name"], "now": 0, "was": 0})
a["now" if sign == 1 else "was"] += e["people"]
+ # A country with only internal displacement has no corridor rows; it still belongs here.
+ for o in set(idp_cur) | set(idp_prev):
+ origins.setdefault(o, {"origin_name": None, "now": 0, "was": 0})
origin_changes, unattributed = [], []
for o, a in origins.items():
delta = a["now"] - a["was"]
@@ -410,6 +413,8 @@ async def fetch_migration_surges(
"origin": _name(o, a["origin_name"], countries), "origin_iso3": o,
"people_abroad": a["now"], "prior_year_people_abroad": a["was"], "change_abroad": delta,
"idps": idp_cur.get(o, 0), "change_idps": idp_delta,
+ # No IDP figure the year before: the jump may be a first report, not new displacement.
+ "idps_first_reported": idp_cur.get(o, 0) > 0 and idp_prev.get(o, 0) == 0,
"population": pop,
"change_abroad_pct_of_population": round(100.0 * delta / pop, 2) if pop else None,
"level": _surge_level(delta, pop) if delta >= min_change else None,
diff --git a/src/world_intel_mcp/tests/test_cli.py b/src/world_intel_mcp/tests/test_cli.py
index e3a1085..5fdbb1b 100644
--- a/src/world_intel_mcp/tests/test_cli.py
+++ b/src/world_intel_mcp/tests/test_cli.py
@@ -98,6 +98,10 @@ def test_command_registry() -> None:
"gdelt",
"predictions",
"displacement",
+ "migration-flows",
+ "migration-surges",
+ "migration-history",
+ "net-migration",
"delays",
"threats",
"brief",
@@ -134,7 +138,7 @@ def test_command_registry() -> None:
# `_cmd` suffix when deriving default command names, so the
# user-facing name still comes out right.
assert "webcams" in names
- assert len(names) == 54
+ assert len(names) == 58
# ---------------------------------------------------------------------------
@@ -954,6 +958,126 @@ def test_displacement_outage_shape_bails_not_zero_totals(
assert "Grand total: 0" not in result.output
+def test_migration_flows_passes_filters_and_renders_corridors(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ calls: list = []
+ payload = {
+ "year": 2025,
+ "origin_filter": {"kind": "country", "name": "Sudan"},
+ "destination_filter": None,
+ "total_people": 1_334_595,
+ "corridor_count": 1,
+ "corridors": [
+ {"origin": "Sudan", "destination": "Chad", "people": 1_334_595, "change": 222_134},
+ ],
+ }
+ monkeypatch.setattr(cli.migration, "fetch_migration_flows", _fake(payload, calls))
+ result = _invoke("migration-flows", "-o", "SDN", "-y", "2025", "-n", "5", "--min-people", "1000")
+ assert result.exit_code == 0
+ assert calls == [{"year": 2025, "origin": "SDN", "destination": None, "limit": 5, "min_people": 1000}]
+ assert "Displacement corridors (2025) from Sudan" in result.output
+ assert "Chad" in result.output
+ assert "1,334,595" in result.output
+ assert "+222,134" in result.output
+
+
+def test_migration_flows_unknown_prior_year_is_not_zero_change(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ # change=None means UNHCR had no prior year to compare; rendering "+0"
+ # would claim a measured standstill.
+ payload = {"year": 2025, "total_people": 10, "corridor_count": 1,
+ "corridors": [{"origin": "A", "destination": "B", "people": 10, "change": None}]}
+ monkeypatch.setattr(cli.migration, "fetch_migration_flows", _fake(payload))
+ result = _invoke("migration-flows")
+ assert "n/a" in result.output
+ assert "+0" not in result.output
+
+
+def test_migration_surges_renders_levels_flags_and_unranked(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ calls: list = []
+ payload = {
+ "year": 2025, "compared_with": 2024, "min_change": 100_000,
+ "origin_outflow_increases": [
+ {"origin": "Sudan", "people_abroad": 3_761_034, "change_abroad": 984_126,
+ "change_abroad_pct_of_population": 1.9, "level": "mass"},
+ ],
+ "origin_outflow_decreases": [
+ {"origin": "Afghanistan", "people_abroad": 3_972_525, "change_abroad": -2_178_793,
+ "change_abroad_pct_of_population": -4.97, "level": None},
+ ],
+ "internal_displacement_increases": [
+ {"origin": "Guatemala", "idps": 573_000, "change_idps": 573_000, "idps_first_reported": True},
+ ],
+ "corridor_increases": [
+ {"origin": "Sudan", "destination": "Libya", "people": 639_166, "change": 383_518},
+ ],
+ "unattributed_origin_changes": [{"origin": "Unknown", "change_abroad": 1_548_961}],
+ "levels": {"basis": "heuristic thresholds of this tool"},
+ }
+ monkeypatch.setattr(cli.migration, "fetch_migration_surges", _fake(payload, calls))
+ result = _invoke("migration-surges", "--min-change", "100000", "-n", "3")
+ assert result.exit_code == 0
+ assert calls == [{"year": None, "min_change": 100_000, "limit": 3}]
+ assert "2024 -> 2025" in result.output
+ assert "+984,126" in result.output and "mass" in result.output
+ assert "-2,178,793" in result.output
+ assert "none reported prior year" in result.output
+ assert "Libya" in result.output
+ assert "Not ranked: Unknown" in result.output
+
+
+def test_migration_history_passes_role_and_renders_waves(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ calls: list = []
+ payload = {
+ "country": "Syrian Arab Rep.", "role": "origin", "meaning": "people FROM this country",
+ "years": 4, "first_year": 2011,
+ "latest": {"year": 2014, "people": 3_887_000, "idps": 7_600_000},
+ "peak": {"year": 2014, "people": 3_887_000},
+ "largest_waves": [{"year": 2013, "people": 2_400_000, "increase": 1_671_000, "pct_change": 229.2}],
+ }
+ monkeypatch.setattr(cli.migration, "fetch_migration_history", _fake(payload, calls))
+ result = _invoke("migration-history", "Syria", "--from", "2011", "--to", "2014")
+ assert result.exit_code == 0
+ assert calls == [{"country": "Syria", "role": "origin", "year_from": 2011, "year_to": 2014}]
+ assert "7,600,000 IDPs" in result.output
+ assert "Peak 2014: 3,887,000" in result.output
+ assert "+1,671,000" in result.output
+ assert "+229.2%" in result.output
+
+
+def test_net_migration_ranking_and_country_modes(monkeypatch: pytest.MonkeyPatch) -> None:
+ calls: list = []
+ ranking = {
+ "region_filter": None,
+ "top_net_immigration": [{"name": "Germany", "year": 2024, "net_migration": 700_000, "per_1000": 8.4}],
+ "top_net_emigration": [{"name": "Chad", "year": 2024, "net_migration": -120_000, "per_1000": None}],
+ }
+ monkeypatch.setattr(cli.migration, "fetch_net_migration", _fake(ranking, calls))
+ result = _invoke("net-migration", "-n", "5")
+ assert result.exit_code == 0
+ assert calls == [{"country": None, "region": None, "limit": 5}]
+ assert "Germany" in result.output and "+700,000" in result.output and "+8.40" in result.output
+ assert "-120,000" in result.output
+
+ series = {
+ "country": "Germany", "region": "Europe & Central Asia",
+ "latest": {"year": 2024, "net_migration": 700_000, "per_1000": 8.4},
+ "largest_net_inflow_years": [{"year": 2015, "net_migration": 1_175_000, "per_1000": 14.33}],
+ "largest_net_outflow_years": [],
+ }
+ monkeypatch.setattr(cli.migration, "fetch_net_migration", _fake(series))
+ result = _invoke("net-migration", "-c", "DEU")
+ assert result.exit_code == 0
+ assert "Net migration: Germany" in result.output
+ assert "+1,175,000" in result.output and "+14.33" in result.output
+
+
def test_delays_all_clear_message(monkeypatch: pytest.MonkeyPatch) -> None:
payload = {"delayed_count": 0, "total_checked": 30, "delayed": []}
monkeypatch.setattr(cli.aviation, "fetch_airport_delays", _fake(payload))
@@ -2021,6 +2145,10 @@ _ERROR_SWEEP = [
(("gdelt",), cli.news, "fetch_gdelt_search"),
(("predictions",), cli.prediction, "fetch_prediction_markets"),
(("displacement",), cli.displacement, "fetch_displacement_summary"),
+ (("migration-flows",), cli.migration, "fetch_migration_flows"),
+ (("migration-surges",), cli.migration, "fetch_migration_surges"),
+ (("migration-history", "Sudan"), cli.migration, "fetch_migration_history"),
+ (("net-migration",), cli.migration, "fetch_net_migration"),
(("delays",), cli.aviation, "fetch_airport_delays"),
(("threats",), cli.cyber, "fetch_cyber_threats"),
(("brief",), cli.intelligence, "fetch_country_brief"),
diff --git a/src/world_intel_mcp/tests/test_collector.py b/src/world_intel_mcp/tests/test_collector.py
index 4ab1df2..24c6b57 100644
--- a/src/world_intel_mcp/tests/test_collector.py
+++ b/src/world_intel_mcp/tests/test_collector.py
@@ -13,8 +13,8 @@ from world_intel_mcp import collector
def test_sources_count_matches_docs() -> None:
- # CLAUDE.md says 53; measured here.
- assert len(collector.SOURCES) == 53
+ # CLAUDE.md says 55; measured here.
+ assert len(collector.SOURCES) == 55
def test_source_names_unique() -> None:
diff --git a/src/world_intel_mcp/tests/test_migration.py b/src/world_intel_mcp/tests/test_migration.py
index e31e8ed..0b47a61 100644
--- a/src/world_intel_mcp/tests/test_migration.py
+++ b/src/world_intel_mcp/tests/test_migration.py
@@ -261,6 +261,19 @@ async def test_surges_rank_origins_levels_and_population_share(fetcher: Fetcher,
assert "heuristic" in result["levels"]["basis"]
+async def test_surges_flag_idps_with_no_prior_year_figure(fetcher: Fetcher, apis,
+ monkeypatch: pytest.MonkeyPatch) -> None:
+ # Live 2024->2025 showed Guatemala +573,000 IDPs from a prior figure of 0: a first
+ # report ranks like a surge unless it is flagged.
+ monkeypatch.setitem(_PAIRS, 2025, [*_PAIRS[2025], _row("COD", "COD", idps=600_000)])
+ result = await migration.fetch_migration_surges(fetcher, year=2025, min_change=50_000)
+ idps = {o["origin_iso3"]: o for o in result["internal_displacement_increases"]}
+ assert idps["COD"]["change_idps"] == 600_000
+ assert idps["COD"]["idps_first_reported"] is True
+ sdn = next(o for o in result["origin_outflow_increases"] if o["origin_iso3"] == "SDN")
+ assert sdn["idps_first_reported"] is False
+
+
def test_surge_levels() -> None:
assert migration._surge_level(600_000, None) == "mass"
assert migration._surge_level(60_000, 5_000_000) == "mass" # 1.2% of population