AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix(mcp): bundle the research persistence module (#1205)
Ilia Alshanetskyfae9c4b1d7d1
diff --git a/changelog.d/+cr-007-mcp-store-bundle.fixed.md b/changelog.d/+cr-007-mcp-store-bundle.fixed.mdnew file mode 100644index 00000000..c4e213fe--- /dev/null+++ b/changelog.d/+cr-007-mcp-store-bundle.fixed.md@@ -0,0 +1 @@+Include the research persistence module in MCP bundles so enabling `LAST30DAYS_STORE` saves findings without failing before results are returned.diff --git a/mcp/scripts/sync-engine.sh b/mcp/scripts/sync-engine.shindex 0f040121..30d178d7 100755--- a/mcp/scripts/sync-engine.sh+++ b/mcp/scripts/sync-engine.sh@@ -1,8 +1,9 @@#!/usr/bin/env bash-# Mirrors skills/last30days/scripts/{last30days.py,lib/} into mcp/vendored/+# Mirrors skills/last30days/scripts/{last30days.py,store.py,lib/} into+# mcp/internal/engine/vendored/# so the Go binary's embed.FS captures the engine at build time.#-# Source of truth: skills/last30days/scripts/. Never edit mcp/vendored/ directly.+# Source of truth: skills/last30days/scripts/. Never edit the mirror directly.# Run before `go build` locally and in CI before `printing-press bundle`.set -euo pipefail@@ -24,8 +25,8 @@ mkdir -p "${VENDORED}"# Clear stale content while keeping the .gitkeep that anchors the embed path.find "${VENDORED}" -mindepth 1 -not -name ".gitkeep" -delete-# Copy the entry script and the lib/ tree (modules + lib/vendor/).-cp "${ENGINE_SRC}/last30days.py" "${VENDORED}/last30days.py"+# Copy the entry script, persistence module, and lib/ tree (modules + lib/vendor/).+cp "${ENGINE_SRC}/last30days.py" "${ENGINE_SRC}/store.py" "${VENDORED}/"cp -R "${ENGINE_SRC}/lib" "${VENDORED}/lib"# Strip caches so the embed.FS stays deterministic.diff --git a/tests/test_mcp_engine_bundle.py b/tests/test_mcp_engine_bundle.pynew file mode 100644index 00000000..009dcd8d--- /dev/null+++ b/tests/test_mcp_engine_bundle.py@@ -0,0 +1,72 @@+"""Exercise the Python engine layout produced for the MCP binary."""++import json+import shutil+import sqlite3+import subprocess+import sys+from contextlib import closing+from pathlib import Path+++ROOT = Path(__file__).resolve().parents[1]+++def test_synced_engine_persists_research_and_emits_json(tmp_path):+ staged_repo = tmp_path / "bundle source"+ scripts = staged_repo / "skills" / "last30days" / "scripts"+ shutil.copytree(+ ROOT / "skills" / "last30days" / "scripts",+ scripts,+ ignore=shutil.ignore_patterns("__pycache__", "*.pyc"),+ )+ sync_script = staged_repo / "mcp" / "scripts" / "sync-engine.sh"+ sync_script.parent.mkdir(parents=True)+ shutil.copy2(ROOT / "mcp" / "scripts" / "sync-engine.sh", sync_script)+ subprocess.run(+ ["bash", str(sync_script)],+ cwd=tmp_path,+ check=True,+ capture_output=True,+ text=True,+ timeout=30,+ )++ engine = staged_repo / "mcp" / "internal" / "engine" / "vendored"+ save_dir = tmp_path / "saved research"+ topic = "MCP persistence regression"+ result = subprocess.run(+ [+ sys.executable,+ "-I",+ str(engine / "last30days.py"),+ topic,+ "--mock",+ "--quick",+ "--search=reddit",+ "--no-browser-cookies",+ "--emit=json",+ "--save-dir",+ str(save_dir),+ ],+ cwd=tmp_path,+ env={+ "PATH": str(tmp_path / "empty-bin"),+ "LAST30DAYS_CONFIG_DIR": str(tmp_path / "config"),+ "LAST30DAYS_CACHE_DIR": str(tmp_path / "cache"),+ "LAST30DAYS_SKIP_KEYCHAIN": "1",+ "LAST30DAYS_STORE": "1",+ },+ capture_output=True,+ text=True,+ timeout=30,+ )++ assert result.returncode == 0, result.stderr+ assert json.loads(result.stdout)["query"] == topic+ db_path = save_dir / "research.db"+ assert db_path.is_file()+ with closing(sqlite3.connect(db_path)) as conn:+ assert conn.execute("SELECT name FROM topics").fetchall() == [(topic,)]+ assert conn.execute("SELECT status FROM research_runs").fetchall() == [("completed",)]+ assert conn.execute("SELECT COUNT(*) FROM findings").fetchone()[0] > 0