Hriday fun

Local Research Stack (Zero-Idle MCP)

An on-demand local search and page-extraction MCP gateway for Apple Silicon that wakes backend services only for bounded call leases, reclaiming 528 MB of idle background RAM.

AI-01
Category AI & Linux
Status Verified Local Build
Year 2026
Systems lens Hardware-style watchdog timers and on-demand power gating to eliminate standby waste.
AI-01Signal block diagram
Local Research Stack zero-idle MCP gateway and watchdog diagramCL15 AI CLIENTS9 unified local toolsU1ON-DEMAND GATEWAY5–300s Call Time BudgetZero-grace teardown on exitWD1DETACHED WATCHDOG · Crash CleanupBK1LOCAL BACKEND POOLLocal Search & Page ReaderReddit & Headless Browser528 MB → 0 MB idle services
Figure AI-01 — On-demand 9-tool gateway with per-call time budgets and independent watchdog cleanup.Swipe diagram →

Why I built it

On a 16 GB Mac, wiring local search, crawler, and Reddit servers across five AI coding assistants quietly burned 528 MB of RAM at idle and injected 47 tool schemas into every prompt before I typed a word. Local Research Stack replaces all six resident daemons with one 9-tool gateway that keeps every backend powered off until a call arrives.

How it works

  • Static 9-Tool Discovery: Coding assistants read 9 focused research tools (web_search, read_url, crawl_page, reddit_search, and peers) from a lightweight stdio shim without booting any search engine or browser process.
  • Bounded Call Leases (5–300 s): Every tool invocation declares an explicit runtime_seconds lease. The gateway wakes only the required backend, coordinates concurrent callers via a shared lock file, and stops the backend immediately once the final lease expires—with zero idle grace period.
  • Detached Crash-Safe Watchdog: If an AI client hangs or receives SIGKILL mid-query, an independent supervisor reaps expired leases and child headless browser processes automatically. Page extraction also blocks private LAN/loopback ranges and caches recent fetches in SQLite.

What I tested & current scope

Six live integration tests verify normal lease teardown, hard timeout aborts, overlapping multi-agent leases, forced gateway termination, and a simulated frozen client (SIGSTOP), confirming zero orphaned processes or stale locks afterward.

Idle backend service memory drops from 528 MB to 0 MB; an active chat’s lightweight stdio connector remains resident while open (~70 MB), and peak RAM during live JS rendering still reflects headless Chromium.

Tools & parts

Node.js Python MCP Gateway macOS Launch Agents SQLite
Tap any item to jump hridayk.com