Web search, fetch, and research pipeline for LLMs — usable as a Python SDK, a standalone MCP server, and an Open WebUI plugin.
Project description
websearch-kit
Web search, fetch, and research pipeline for LLMs — one engine, three surfaces: a Python SDK, a standalone MCP server, and an Open WebUI plugin.
Query expansion → multi-provider search → SSRF-guarded concurrent fetching (40-UA browser profile, pinned-IP connect) → trafilatura extraction → BM25 rerank with adaptive context budgeting → numbered, citable context for your LLM.
No fail-silent: a call either raises a typed error or returns a result where
every dropped, blocked, truncated, or substituted item is enumerated as a
structured Degradation. On the live web that looks like:
ok : True partial: True
sources : 10 # 5 fetched pages + 5 relevance-filtered snippets
warnings :
- [fetch] https://cloud.google.com/...: response exceeded byte cap (1054971 > 1048576 bytes)
stats : 10 raw -> 10 unique, 5 fetched, context 23471 chars,
timings {'search': 854, 'fetch': 1662, 'extract': 878, 'rank': 3}
Status: 0.1.0. See SPEC.md, CHANGELOG.md.
Features
- One engine, three surfaces — the SDK core is the only pipeline; the MCP server and Open WebUI adapters are thin translators over it, so behavior and config semantics never drift between surfaces.
- Full research pipeline —
research()runs search → fetch → extract → rank → assemble in one call and returns a numbered[N]context block with 1:1 source citations, ready to drop into a prompt. - Multi-provider search — zero-key
ddgsout of the box; keyed Tavily / Brave / Serper / Exa and self-hosted SearXNG via config; ordered fallback chains with per-provider circuit breakers. - Hardened fetching — SSRF guard (private / reserved / metadata IP ranges blocked at connect time with pinned-IP enforcement), per-response byte caps, rotating 40-UA browser profile, concurrent fetches with deadline budgeting.
- Quality extraction & ranking — trafilatura article extraction, BM25 reranking (golden-tested math), adaptive context budgeting: the most relevant pages get more of the character budget, marginal ones shrink, noise is dropped.
- No-fail-silent contract — every degradation (blocked URL, truncated page, provider fallback, budget cut) is a typed, enumerable warning; nothing disappears without a trace.
- LLM query expansion (optional) — expand a question into multiple search queries via any OpenAI-compatible endpoint or an injected callback.
- Caching — in-memory by default, sqlite persistence a config flag away.
- Typed throughout — pyright-strict clean, structured results on every surface (Pydantic models in the SDK, JSON structured output over MCP).
- 688+ tests including live-web smoke suites and hand-computed golden tests.
How to use
Python SDK
pip install "websearch-kit[ddgs]" # ddgs = the zero-API-key search provider
import asyncio
from websearch_kit import SearchKit
async def main():
async with SearchKit() as kit: # zero-config: ddgs, no keys, no LLM
report = await kit.research("RISC-V vs ARM datacenter adoption")
print(report.context) # numbered [N] block for your LLM
for s in report.sources:
print(f"[{s.n}] {s.title} — {s.url}")
print(report.warnings) # everything the run degraded on
asyncio.run(main())
Beyond research(), the kit exposes the pipeline stages individually:
results = await kit.search("python 3.14 free threading", count=5) # snippets only
pages = await kit.fetch(["https://docs.python.org/3.14/whatsnew/"]) # URLs, extracted
status = await kit.health() # provider probe
Prefer blocking code? SyncSearchKit mirrors the async API 1:1. Keyed
providers, fallback chains, sqlite caching, and LLM query expansion are all
config away — see docs/deployment/sdk.md and
examples/.
MCP server
Add to your MCP client config (Claude Code, Claude Desktop, or any MCP client):
{
"mcpServers": {
"websearch-kit": {
"command": "uvx",
"args": ["--from", "websearch-kit[mcp,ddgs]", "websearch-kit-mcp"]
}
}
}
Four read-only tools with typed structured output, over stdio or streamable HTTP:
| Tool | What it does |
|---|---|
web_search |
Snippet-level results — context-economical |
fetch_page |
Read one URL as markdown, cursor pagination for long pages |
research |
Full pipeline → [N] context block + one resource link per citation |
health |
Provider latency, circuit-breaker state, config checks |
For HTTP transport, scaling, and hardening flags see docs/deployment/mcp.md and examples/mcp_config_examples.md.
Open WebUI
Import adapters/owui/websearch_kit_filter.json
via Admin Panel → Functions → Import (OWUI's import expects its JSON
export format — or create a new Function and paste
websearch_kit_filter.py instead).
It pip-installs this SDK automatically via its frontmatter requirements:
line and searches key-free out of the box (ddgs); valves switch it to your
instance's configured web search or a keyed provider.
Toggle the pill to research every message, or trigger one-off:
?? quantum routers --count 12 --lang en --reply de --fresh week
A Tool variant for model-invoked (agentic) use ships alongside it. See docs/deployment/owui.md.
Documentation
- SPEC.md — normative behavioral contract (pipeline semantics, ranking math, degradation codes, SSRF ruleset)
- docs/architecture.md — how the engine is layered
- docs/domains/ — one standard document per domain
- docs/adr/ — the eight load-bearing decisions
- VERSIONING.md — SemVer policy and public-API definition
- SECURITY.md — SSRF posture and threat model
License
MIT — with a CI-enforced permissive-only dependency policy (no GPL/AGPL;
trafilatura>=1.8.0 pinned for its Apache-2.0 relicense).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file websearch_kit-0.3.2.tar.gz.
File metadata
- Download URL: websearch_kit-0.3.2.tar.gz
- Upload date:
- Size: 510.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8da1853fedc55560f1766a73e0cb1dd8a4af28b6339ce94323465c34cf19777
|
|
| MD5 |
1537c8a2d2f239be01ad2a12f6822798
|
|
| BLAKE2b-256 |
8d6b96c62a4be88e6ff0d5a8aa47e3e34fac70bca61d117cb870a9422739737f
|
Provenance
The following attestation bundles were made for websearch_kit-0.3.2.tar.gz:
Publisher:
publish.yml on rmarnold/websearch-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
websearch_kit-0.3.2.tar.gz -
Subject digest:
b8da1853fedc55560f1766a73e0cb1dd8a4af28b6339ce94323465c34cf19777 - Sigstore transparency entry: 1740674614
- Sigstore integration time:
-
Permalink:
rmarnold/websearch-kit@c6fffcad07ff7be5745d9b3d0411eb7b28a6e35c -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/rmarnold
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c6fffcad07ff7be5745d9b3d0411eb7b28a6e35c -
Trigger Event:
push
-
Statement type:
File details
Details for the file websearch_kit-0.3.2-py3-none-any.whl.
File metadata
- Download URL: websearch_kit-0.3.2-py3-none-any.whl
- Upload date:
- Size: 187.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c7c7dcd2033f5485aa827d04d0e5f797dc49d6016af0d415e569f155e6f7c9b
|
|
| MD5 |
03671e7bfd41f6ba9a49a4f1b0a910ca
|
|
| BLAKE2b-256 |
ce44785489c08c988cf36429218012bd7a9bc1ef3bc92468cda2649ec3a95185
|
Provenance
The following attestation bundles were made for websearch_kit-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on rmarnold/websearch-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
websearch_kit-0.3.2-py3-none-any.whl -
Subject digest:
0c7c7dcd2033f5485aa827d04d0e5f797dc49d6016af0d415e569f155e6f7c9b - Sigstore transparency entry: 1740674698
- Sigstore integration time:
-
Permalink:
rmarnold/websearch-kit@c6fffcad07ff7be5745d9b3d0411eb7b28a6e35c -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/rmarnold
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c6fffcad07ff7be5745d9b3d0411eb7b28a6e35c -
Trigger Event:
push
-
Statement type: