leanweb-mcp
Uses a self-hosted (or existing) SearXNG instance as the search backend for the web_search tool, issuing queries to SearXNG's JSON search API and returning numbered results with titles, URLs and short snippets (plus suggestions and failing engines when nothing is found). Configured via LEANWEB_SEARXNG_URL; the SearXNG instance must have json enabled in search.formats.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
leanweb-mcp
Self-hosted web search and token-cheap page reading for small-context local LLMs.
An MCP server with six tools: one for search (through your own SearXNG) and five for reading web pages in parts. The model sees a page's size and outline first, then reads only the sections it needs. Every tool output is hard-capped server-side, so one tool call can't flood the context window.
Status: works for me, maintained as-is. Issues and PRs are welcome, but there is no roadmap or support promise.
Why
With a 32K–64K context, a single "read this URL" call that returns the whole page (often 10–25K tokens after markdown conversion) can use up a third of the window. Scraping MCP servers can also cost thousands of tokens of tool definitions on every request before the model does anything. leanweb aims to make each step small:
web_searchreturns titles, URLs and one-line snippets (capped at 2,500 chars).page_inforeturns the page's size and a heading outline with ~tokens per section (capped at 3,000 chars).page_find/page_section/page_selectread only what's needed (capped at 16,000 chars).
Related MCP server: Web Explorer MCP
Benchmarks
Measured on 2026-11-12 with a local llama-server setup: GTX 1080 Ti 11 GB, Qwen3.6-35B-A3B, 64K context.
Test page: composio.dev/content/best-opencode-plugins.
Token figures are chars / 4 estimates.
What the model receives | chars | ~tokens |
Raw HTML | 388k | ~97k |
Whole page, plain HTML→markdown conversion | 41.2k | ~10.3k |
Whole page, leanweb cleaned | 24.6k | ~6.2k |
| 2.2k | ~550 |
| 1.7k | ~440 |
One | 1.2k | ~300 |
A typical outline → find → one-section read cost about 1.3K tokens for this page, compared with about 10K for the whole page as plain markdown.
Tool definitions also count. Removing a 17-tool scraping MCP server from the client saved ~12.5K tokens of tool definitions per request. leanweb's six tools take about 3.9K chars (~1K tokens).
Quick start
Requires Docker with Compose v2.24+. The image is about 2.4 GB because it includes Chromium for the browser fallback.
git clone https://github.com/0xJonty/leanweb-mcp.git
cd leanweb-mcp
cp .env.example .env
sed -i "s/^SEARXNG_SECRET=.*/SEARXNG_SECRET=$(openssl rand -hex 32)/" .env
docker compose up -d --build
python3 scripts/smoke.py http://127.0.0.1:8200/mcp # optional check, stdlib onlyThe MCP endpoint is http://127.0.0.1:8200/mcp (streamable HTTP, JSON responses, stateless, no auth).
By default it is only reachable from the same machine. To use it from other machines on your network, set
LEANWEB_BIND to the LAN address and add that address:port to LEANWEB_ALLOWED_HOSTS. Read
SECURITY.md before you do.
The compose file runs two containers:
leanweb: built from this repo's
Dockerfile, on top of thepyd4vinci/scrapling:0.5.1image.searxng: the upstream
searxng/searxngimage, unmodified and pinned. It gets a minimalsearxng/settings.yml(JSON output on, limiter off) and is not published on the host.
To use a SearXNG you already run, set LEANWEB_SEARXNG_URL and remove the searxng service. That instance
needs json in search.formats.
Without Docker
pip install -e . # Python 3.10+
scrapling install # browser + system deps for the headless-browser fallback
LEANWEB_SEARXNG_URL=http://127.0.0.1:8080 leanweb-mcpTools
Tool | Returns | Cap (chars) |
| Numbered results: title, URL, one-line snippet (≤ 200 chars). On zero results: SearXNG's suggestions and the engines that failed. | 2,500 |
| Title, cleaned size in chars and ~tokens, images removed, heading outline with ~tokens per section (including subsections). Drops deeper heading levels to fit the cap. | 3,000 |
| Sections that mention a word (case-insensitive, substring), with hit counts, sizes and snippets for the top hits. On pages without headings, the char offsets of the hits. | 2,000 |
| The section from the matching heading to the next heading of the same or higher level. Cut sections end with | 16,000 |
| Markdown for each element matching a CSS selector. | 16,000 |
| Page text from a char offset. The cut note gives the next | 16,000 |
How heading lookup works:
Matching ignores case and punctuation. An exact match wins over a substring match, so
installfinds a heading called "Install" before "How to install widgets".Repeated headings get unique labels in the outline, such as
2. Beta > InstallorHistory > Development. The model can pass a label back exactly as shown, or useParent > Child.
Example page_info output (from the smoke test):
Title: Web scraping - Wikipedia
Size: 28,911 chars ~7,228 tokens (cleaned) | images removed: 3 | fetched via http, 0 min ago
Outline - 19 headings, ~tokens include subsections:
# Web scraping (~7,228)
## History (~239)
## Techniques (~1,145)
### Human copy-and-paste (~152)
...
## Legal issues (~2,386)
### United States (~1,764)
...
Next: page_find(url, word) or page_section(url, heading).Fetching and cleaning
Fetch: Scrapling plain HTTP first (curl_cffi with browser impersonation). The headless Chromium fallback runs only if HTTP fails or returns under 500 cleaned chars. There is no Cloudflare or challenge solving.
Clean: removes scripts, styles,
nav,footer, forms and controls, and site headers with no h1–h3. It also removes hidden elements (hidden,aria-hidden,display:none), which often hold junk or text aimed at AI agents, plus heading permalink glyphs and MediaWiki edit links and citation markers. If one<main>or<article>holds most of the text, only that is used.Convert: the result becomes markdown with images removed (and counted), links reduced to their text, stray tags stripped (code blocks untouched) and blank lines collapsed.
Cache: each cleaned page is stored on disk for 6 hours, keyed by URL, so reading several sections fetches the page once. A per-URL lock means concurrent calls share one fetch.
Configuration
Set these in .env for Docker Compose, or in the environment otherwise. .env.example has
the same list with comments.
Variable | Default | Purpose |
| (required, Compose) | SearXNG secret key. Generate with |
|
| Host address the endpoint is published on (Compose). |
|
| Host port the endpoint is published on (Compose). |
|
| Bind address without Docker ( |
|
| Port without Docker. |
|
| MCP endpoint path. |
|
| Python log level. |
|
| Accepted |
|
| Accepted browser |
|
|
|
|
| Retry with the browser below this many cleaned chars. |
|
| Plain HTTP timeout (s). |
|
| Browser fetch timeout (s). |
|
| Maximum simultaneous browser fetches. |
|
| Raw HTML beyond this is ignored. |
|
| Cache lifetime. |
|
| Cache directory without Docker (Compose uses the |
|
| SearXNG base URL (Compose default: |
|
| Search timeout (s). |
|
| Default |
|
| Upper limit for |
|
| Snippet length per search result. |
|
|
|
|
|
|
|
|
|
|
| Hard ceiling for |
|
| Default |
|
| Default |
|
| Default |
Client setup
Every client needs the same thing: a streamable HTTP MCP server at http://<host>:<port>/mcp with no
authentication. The examples below use http://127.0.0.1:8200/mcp. If the client connects through another
hostname, add that host:port to LEANWEB_ALLOWED_HOSTS, or requests will get HTTP 421.
llama.cpp web UI
Start
llama-serverwith--webui-mcp-proxy.In the web UI, open the MCP servers page (
/#/mcp-servers) and choose Add New Server.Enter the URL and turn on Use llama-server proxy. The proxy is required because leanweb doesn't send CORS headers. Connections then come from the
llama-servermachine, so that is the address leanweb must accept.
Pi
pi mcp add leanweb --url http://127.0.0.1:8200/mcp # add -l to write the project's .pi/mcp.json
pi mcp listClaude Code
claude mcp add --transport http leanweb http://127.0.0.1:8200/mcpOpenCode (opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"leanweb": { "type": "remote", "url": "http://127.0.0.1:8200/mcp", "enabled": true }
}
}Newer OpenCode configs nest servers under mcp.servers; check the docs for your version.
Anything else: point any MCP client that supports streamable HTTP at the URL. For stdio-only clients, use a stdio-to-HTTP bridge.
Recommended system prompt for small models
Small models follow an explicit order much better than a list of tools. This block works well in practice:
## Web tools
- web_search(query, max_results=5): titles, URLs and one-line snippets. Answer from the snippets when they are enough; otherwise open the 1-2 best URLs.
- To read a page, in this order:
1. page_info(url) FIRST: size in ~tokens and the heading outline with ~tokens per section.
2. page_find(url, word): which sections mention a word, with hit counts.
3. page_section(url, heading): read only the sections you need. Copy the heading exactly from the outline; "A > B" lines are repeated headings, pass them as-is. If a section comes back cut, read one of its listed subsections instead.
4. page_select(url, css_selector): tables ("table"), lists, specific elements, or link URLs ("a::attr(href)"); the other tools strip links.
5. page_head(url, max_chars, start): pages with no headings, or text before the first heading. Continue with the start= value from the cut note; on pages without headings, page_find gives char offsets to jump to.
- Never read the same section or chunk twice; it is already in your context. Repeat page_info/page_find calls are cheap because pages are cached.
- Stop reading as soon as you can answer, and cite the URLs you used.Limitations
Read-only, GET-only. No clicking, forms, logins, POST requests or screenshots.
Challenge pages fail by design. Bot-protection challenges such as Cloudflare are not solved; the tool returns an error instead.
HTML and plain text only. PDFs and other binary types are rejected.
Cleaning is heuristic. Content that lives in a
nav,footer, heading-less<header>or hidden element is dropped.page_selectsees the cleaned page, so selectors for removed elements match nothing.Token counts are chars / 4 estimates, not tokenizer counts.
The cache has no size limit, only the TTL. It is one process: an in-memory copy plus files on disk.
The private-address check covers only the URL you pass, not redirects. See SECURITY.md.
Tested only on Linux/amd64, with the pinned Scrapling 0.5.1 image.
Development
pip install -e ".[test]"
pytest # unit tests, no network
pytest -m live # real fetch; set LEANWEB_SEARXNG_URL to also test searchCredits and licenses
leanweb-mcp is MIT-licensed (see LICENSE). It builds on:
Scrapling (BSD-3-Clause) by Karim Shoair: HTTP and browser fetching, CSS selection, and the
pyd4vinci/scraplingbase image.SearXNG (AGPL-3.0): the search backend. It runs as a separate, unmodified upstream container that is pulled at deploy time. No SearXNG code is included in this repository.
markdownify (MIT), MCP Python SDK (MIT) and lxml (BSD-3-Clause).
Images built from the Dockerfile include the base image's contents (Chromium, Playwright and others) under their own licenses.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Web search and page reading for AI agents, including JSON APIs, RSS feeds and YouTube.
Web scraping for agents. Point it at a URL and it returns the page as clean markdown, JavaScript-rendered pages included. Point it at a site and it maps the URLs or crawls the section you need in the background, a few pages at a time so results fit in the conversation. Search the web and read full pages, extract fields with a JSON schema you define (validated, never invented), read a store's catalogue or a blog's posts from the platform's own feed, and check whether a page has changed. Failed requests cost nothing. The free plan includes 1,500 credits a month.
Scrape, map, crawl, search and monitor the web. Runs locally with no API key, cites every source.
Web search and page-reading for AI agents. One-click OAuth connect, or a Caesar API key.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables local LLMs to search the web and fetch clean content from URLs without API keys, using SearxNG and Mozilla Readability.241MIT
- AlicenseAqualityDmaintenanceEnables private web search and webpage content extraction using a local SearxNG instance, prioritizing user privacy and autonomy.212 PyPI2MIT
- FlicenseNot gradedqualityDmaintenanceEnables web search and content scraping from multiple engines via a local SearXNG instance, allowing AI assistants to retrieve and extract web content.1-
- AlicenseAqualityCmaintenanceEnables privacy-preserving web search and content extraction through a self-hosted SearXNG instance, aggregating 70+ engines and converting pages to Markdown for LLM use.3MIT