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.
Python ai-toolsai-watchanthropicclaudecybersecuritydashboardgeofencinggeopoliticalgeospatialintelligencemarketsmcpmigrationmilitarymodel-context-protocolnuclearosintreal-timespace-weatherthreat-intelligence
Cache: resolve the default path when the cache opens, not at import
Phoenix Agent (mac-studio)a061107e77c9
diff --git a/src/world_intel_mcp/cache.py b/src/world_intel_mcp/cache.pyindex fdf1dae..d26fd4b 100644--- a/src/world_intel_mcp/cache.py+++ b/src/world_intel_mcp/cache.py@@ -15,15 +15,16 @@ from typing import Anylogger = logging.getLogger("world-intel-mcp.cache")-_DEFAULT_DB = Path.home() / ".cache" / "world-intel-mcp" / "cache.db"-def _default_db_path() -> Path:+ # Resolved per Cache, not at import, so HOME and XDG_CACHE_HOME are read+ # when the cache opens, the same way the temporal and spike baselines+ # resolve theirs.if env_path := os.environ.get("WORLD_INTEL_CACHE_DB"):return Path(env_path).expanduser()if xdg_cache := os.environ.get("XDG_CACHE_HOME"):return Path(xdg_cache).expanduser() / "world-intel-mcp" / "cache.db"- return _DEFAULT_DB+ return Path.home() / ".cache" / "world-intel-mcp" / "cache.db"class Cache:diff --git a/src/world_intel_mcp/tests/test_cache_isolation.py b/src/world_intel_mcp/tests/test_cache_isolation.pyindex 4e32a86..d5eeeb7 100644--- a/src/world_intel_mcp/tests/test_cache_isolation.py+++ b/src/world_intel_mcp/tests/test_cache_isolation.py@@ -8,6 +8,7 @@ from pathlib import Pathimport pytestfrom world_intel_mcp.analysis import spikes, temporal+from world_intel_mcp.cache import Cachedef test_all_module_imports_open_no_databases(tmp_path: Path) -> None:@@ -94,6 +95,28 @@ def test_baseline_path_resolved_on_first_use(baseline._conn.close()+def test_cache_default_path_follows_home_set_after_import(+ monkeypatch, tmp_path: Path,+) -> None:+ """With neither override set, the cache lands under the HOME in force+ when it is built, beside the baselines, not the HOME of import time."""+ monkeypatch.delenv("WORLD_INTEL_CACHE_DB", raising=False)+ monkeypatch.delenv("XDG_CACHE_HOME", raising=False)+ home = tmp_path / "home-set-after-import"+ home.mkdir()+ monkeypatch.setenv("HOME", str(home))+ expected = home / ".cache" / "world-intel-mcp"++ cache = Cache()+ try:+ assert cache.db_path == expected / "cache.db"+ assert cache.db_path.is_file()+ assert Path(temporal._default_db_path()).parent == expected+ assert Path(spikes._default_db_path()).parent == expected+ finally:+ cache.close()++@pytest.mark.parametrize("module,cls", [(temporal, temporal.TemporalBaseline),(spikes, spikes.KeywordSpikeDetector),