No description
Find a file
User e6c2cc1e8c Prepare for public release: AGPL license, curl installer, bearer-token auth
- LICENSE: AGPL-3.0
- install.sh: curl-pipeable bootstrap for Linux/macOS (VPS/LXC) — installs
  Docker if missing, clones, generates strong LWSS_API_KEY + SearXNG secret,
  compose up, prints the ready-to-run 'claude mcp add' command; idempotent and
  preserves .env on re-run
- auth: optional bearer token (LWSS_API_KEY) on all orchestrator MCP + REST
  requests via middleware; /health exempt; empty key disables auth (LAN only);
  constant-time compare
- compose: configurable bind address (ORCHESTRATOR_BIND, default 0.0.0.0) so
  the endpoint can stay localhost-only behind a tunnel; API key plumbed through
- docker-compose.override.yml pattern (gitignored) + .example for machine-local
  config like LAN SearXNG extra_hosts
- README: install one-liner, auth + security (SSRF/tunnel) notes, license
- PRD: auth documented in §8; multi-tenant non-goal clarified

Verified: auth rejects unauthenticated REST + MCP (401), passes with a valid
bearer token, /health stays open; full dockerized stack healthy; MCP client
connects only with the Authorization header.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 00:43:04 -07:00
config M3: search — SearXNG container, searcher service, orchestrator /search 2026-07-05 22:07:10 -07:00
searxng M3: search — SearXNG container, searcher service, orchestrator /search 2026-07-05 22:07:10 -07:00
services Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
.env.example Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
.gitignore Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
docker-compose.override.yml.example Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
docker-compose.yml Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
install.sh Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
LICENSE Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
PRD.md Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00
README.md Prepare for public release: AGPL license, curl installer, bearer-token auth 2026-07-06 00:43:04 -07:00

Local Web Search Stack (LWSS)

Self-hosted, private web search + page retrieval for local LLMs — a functional replacement for Tavily/Serper/Firecrawl, exposed as an MCP server. No SaaS in the request path, no per-call fees, no LLM anywhere in the stack (the calling model does its own ranking/filtering; extraction is purely mechanical).

See PRD.md for full requirements and architecture.

Install (VPS / LXC / any Linux or macOS host)

One command — installs Docker if missing, clones the repo, generates a strong API key + SearXNG secret, and brings the stack up:

curl -fsSL https://git.neilbantoc.dev/neil/local-web-search/raw/branch/main/install.sh | bash

When it finishes it prints your MCP endpoint, the generated API key, and the exact claude mcp add command to run on your client machine. Re-running the installer updates the checkout and restarts the stack, preserving your .env (and API key). Useful overrides: LWSS_DIR, LWSS_PORT, LWSS_BIND, LWSS_BRANCH (see the top of install.sh).

Quick start (manual / development)

cp .env.example .env
# set LWSS_API_KEY to a strong value (or `openssl rand -hex 32`); empty disables auth
docker compose up --build

The orchestrator is the only exposed service, on port 8000.

Authentication

If LWSS_API_KEY is set (the installer always sets it), every request to the MCP and REST endpoints must carry Authorization: Bearer <key>. /health is always exempt so healthchecks/monitors work. An empty key disables auth — only do that on trusted/LAN networks.

MCP (primary interface)

Streamable HTTP endpoint: http://<host>:8000/mcp

Claude Code:

claude mcp add --transport http local-web-search http://<host>:8000/mcp \
  --header "Authorization: Bearer <your-api-key>"

Tools:

Tool Args Returns
web_search query, max_results=5, include_content=true ranked results: url, title, snippet (+ cleaned page text)
fetch_url url cleaned text, title, metadata for one page

REST (debug / non-MCP clients)

AUTH='-H "Authorization: Bearer <your-api-key>"'   # omit if auth is disabled
curl -X POST localhost:8000/search           -d '{"query":"..."}'            -H 'content-type: application/json' -H "Authorization: Bearer <key>"
curl -X POST localhost:8000/search/contents  -d '{"query":"...","max_results":5}' -H 'content-type: application/json' -H "Authorization: Bearer <key>"
curl -X POST localhost:8000/scrape           -d '{"url":"https://..."}'      -H 'content-type: application/json' -H "Authorization: Bearer <key>"
curl localhost:8000/health   # no auth needed

Every REST response includes a trace: per-stage timings, cache hit/miss, and a degraded list naming stages that fell back or partially failed.

Architecture

MCP client → orchestrator (REST+MCP) → searcher → searxng (local)
                                     → renderer (Playwright)
                                     → extractor (Trafilatura + readability)
                          redis: search / rendered-HTML / extracted-text caches
  • searcher — queries the SearXNG pool (file-based list in config/instances.yml, failover mode; add instances there for rotation later), normalizes + dedups results.
  • renderer — always renders via headless Chromium; single browser, pooled contexts, concurrency cap + queue; per-domain rate limiting (Redis token window); render retry with DNS-failure fast-fail; Redis HTML cache.
  • extractor — mechanical extraction only: Trafilatura (precision → recall) then readability-lxml fallback; flags thin content.
  • orchestrator — sequencing, per-URL parallelism, partial-result degradation, scrape-result cache, aggregated /health.

Configuration

All knobs are env vars (see .env.example): cache TTLs, renderer concurrency and timeouts, per-domain rate limit, stage timeouts, SearXNG secret. The SearXNG instance pool lives in config/instances.yml (hand-editable; reloaded on change without restart).

Security notes

When exposed beyond a trusted LAN, the API key is the only thing gating your renderer — anyone with the key (or with the port open and auth disabled) can drive it to fetch arbitrary URLs. Guidance:

  • Always keep LWSS_API_KEY set on any internet-reachable host.
  • Prefer a private tunnel. Set ORCHESTRATOR_BIND=127.0.0.1 and reach the box over Tailscale / WireGuard / Cloudflare Tunnel rather than opening the port. That keeps the endpoint off the public internet entirely.
  • Renderer SSRF surface: fetch_url / /scrape will fetch any URL given to it, including internal addresses reachable from the container. Don't run this where it can reach sensitive internal services you wouldn't want proxied.
  • Rotate the key by editing .env and docker compose up -d orchestrator.

Development

Python services run directly with uvicorn (--app-dir services/<name>), the renderer with node services/renderer/src/server.js. Everything degrades gracefully without Redis (caching disabled). Each service is curl-able in isolation on its own port: searcher 8001, renderer 8002, extractor 8003.

License

AGPL-3.0. If you run a modified version as a network service, the license requires you to make your modified source available to its users.