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.
┌─────────────────┐ ┌───────────────────────┐ ┌──────────────────────┐
│ CL1 · 5 CLIENTS │────▶│ U1 · ON-DEMAND GATE │────▶│ BK1 · LOCAL SERVICES │
│ 9 Unified Tools │ │ 5–300s Call Budget │ │ Search · Crawl · Web │
└─────────────────┘ └───────────┬───────────┘ │ 0 MB When Idle │
▼ └──────────────────────┘
┌───────────────────────┐
│ WD1 · WATCHDOG │
│ Crash-Safe Cleanup │
└───────────────────────┘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 explicitruntime_secondslease. 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
SIGKILLmid-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.
Stack & parts