M5: hardening — retries, per-domain rate limiting, resource limits, docs
- renderer: per-domain politeness limiter (Redis fixed window, in-memory fallback; over-limit requests wait bounded, 429 past deadline); render retry with DNS-failure fast-fail - orchestrator: one retry on connection-level stage failures (not timeouts) - compose: per-container CPU/memory limits; all hardening knobs env-driven and documented in .env.example - README: quick start, MCP + REST usage, architecture, config, dev workflow Verified: rate limit window enforced (3rd request waited for reset), full scrape + MCP web_search smoke green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
a70a6b5f5f
commit
64ffeabd49
7 changed files with 212 additions and 10 deletions
80
README.md
Normal file
80
README.md
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# 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](PRD.md) for full requirements and architecture.
|
||||
|
||||
## Quick start
|
||||
|
||||
```bash
|
||||
cp .env.example .env # optional; defaults work
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
The orchestrator is the only exposed service, on port 8000.
|
||||
|
||||
### MCP (primary interface)
|
||||
|
||||
Streamable HTTP endpoint: `http://localhost:8000/mcp`
|
||||
|
||||
Claude Code:
|
||||
|
||||
```bash
|
||||
claude mcp add --transport http local-web-search http://localhost:8000/mcp
|
||||
```
|
||||
|
||||
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)
|
||||
|
||||
```bash
|
||||
curl -X POST localhost:8000/search -d '{"query":"..."}' -H 'content-type: application/json'
|
||||
curl -X POST localhost:8000/search/contents -d '{"query":"...","max_results":5}' -H 'content-type: application/json'
|
||||
curl -X POST localhost:8000/scrape -d '{"url":"https://..."}' -H 'content-type: application/json'
|
||||
curl localhost:8000/health
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
## 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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue