Webshift

io.github.x-hannibal由 GitHub 账号 x-hannibal 发布v0.2.14更新于 Oct 24, 2026

Rust MCP server for denoised web search — fetch, clean, and rerank web content for AI agents.

概览

AI 生成的概览

一个本地运行的 Rust MCP 服务器,可执行网页搜索、抓取页面、去除 HTML 噪声,并向助手返回受大小限制的干净文本。

可以做什么
WebShift 通过 stdio 提供三个工具:webshift_query 执行搜索、抓取、HTML 清洗、BM25 重排序以及可选 LLM 摘要的完整流程;webshift_fetch 抓取并清洗单个页面;webshift_onboarding 返回描述预算、后端和提示的 JSON 指南。它会去除脚本、广告、导航和 Cookie 提示,净化 Unicode 与 BiDi 字符,并强制每页与总字符预算。它只解析静态 HTML,不执行 JavaScript。
适用场景
当助手需要符合上下文预算的搜索结果或页面文本,而不是原始 HTML 时适用。它适合希望使用单一静态二进制、无需 Python 或 Docker 运行时的代理,以及需要对输出大小设置硬性上限的流程。它不适用于依赖 JavaScript 的单页应用、视觉渲染或截图,也不适用于带表单和登录的多页抓取。
运行要求
作为本地进程运行,使用 cargo install webshift-mcp 安装(需要 Rust 工具链),并以 mcp-webshift 二进制启动。需要搜索后端:默认是自托管的 SearXNG,也可使用 Brave、Tavily、Exa、SerpAPI、Google 或 Bing 等云端后端,通过命令行参数、WEBSHIFT_* 环境变量或 webshift.toml 配置。LLM 功能为可选,需要兼容 OpenAI 的端点。
安装前请注意
云端搜索后端需要 API 密钥,通过 WEBSHIFT_BRAVE_API_KEY、WEBSHIFT_GOOGLE_API_KEY、WEBSHIFT_GOOGLE_CX 或 WEBSHIFT_BING_API_KEY 等设置提供,HTTP 后端还可携带 Authorization 请求头;这些会保存在配置或环境变量中。LLM 功能默认关闭,但启用后页面内容和查询会发送到所配置的 LLM 端点,该端点可能是远程的。项目处于 beta 阶段,API 可能变化。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Webshift,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

WebShift

[Crates.io] [docs.rs] [Latest Release] [Beta] [License]


What is WebShift

WebShift is a Rust library and MCP server that shifts noisy web pages into clean, right-sized text for LLM consumption.

Raw HTML is mostly junk: scripts, ads, navigation menus, cookie banners, tracking pixels. Feeding it directly to an LLM floods the context window with tens of thousands of useless tokens and leaves no room for reasoning. WebShift strips all that noise, sterilizes the text, and enforces strict size budgets so the model receives only the content that matters.

What you get

Depending on the features you enable, WebShift can be four things:

Use caseCrateFeature flagsWhat it does
HTML denoiserwebshiftdefault-features = falseclean() — pure Rust HTML-to-text pipeline. Strips noise elements, sterilizes Unicode/BiDi, collapses whitespace. Zero network, zero config. Drop into any Rust project that processes web content for LLMs.
HTML text rewriterwebshiftfeatures = ["text-map"]extract_text_nodes() + replace_text_nodes() — extract individual text nodes from HTML, manipulate them (translate, rewrite, simplify), and rebuild the HTML with structure intact. Tags, attributes, and links are never touched.
Web content clientwebshiftdefault or features = ["llm"]fetch() + query() — streaming HTTP fetcher with size caps, 8 search backends, BM25 reranking, optional LLM query expansion and summarization. Full pipeline from search query to structured results.
MCP serverwebshift-mcpall featuresNative binary (mcp-webshift) that exposes webshift_query, webshift_fetch, and webshift_onboarding over MCP stdio. Single static binary, zero runtime dependencies.

When to use WebShift

  • You're building an AI agent that needs web search and you want clean, budget-controlled text — not raw HTML.
  • You're processing web pages in a Rust pipeline and need a reliable HTML-to-text cleaner that strips noise without losing real content.
  • You need an LLM to translate, rewrite, or simplify text inside HTML without corrupting the markup — text-map gives you a safe round-trip.
  • You want an MCP web search server that works as a single binary — no Python, no pip, no venv, no Docker (unless you want it).
  • You need hard guarantees on output size: per-page caps, total budget caps, streaming download limits.

When NOT to use WebShift

  • You need a headless browser that renders JavaScript-heavy SPAs. WebShift parses static HTML — it doesn't execute JS.
  • You need to render or screenshot a page preserving its visual layout. WebShift processes HTML structure but does not render CSS or compute layout. (Note: text-map does preserve the DOM structure for text rewriting use cases.)
  • You're building a web scraper that needs to navigate across pages, fill forms, or handle authentication flows.

How it works

Question
  |
  +- (optional) LLM query expansion -> multiple search variants
  |
  +- Search via backend (SearXNG, Brave, Tavily, Exa, SerpAPI, Google, Bing, HTTP)
  |
  +- Deduplicate + filter binary URLs
  |
  +- Streaming fetch with per-page size cap
  |
  +- HTML cleaning -> plain text (noise elements, scripts, nav removed)
  |
  +- Unicode/BiDi sterilization
  |
  +- BM25 deterministic reranking
  |   +- (optional) LLM-assisted tier-2 reranking
  |
  +- Budget-aware truncation across all sources
  |
  +- (optional) LLM Markdown summary with inline citations
  |
  +- Structured JSON output

For a detailed explanation of each pipeline stage, BM25 parameters, adaptive budget allocation, and real compression metrics see Under the Hood. For the full configuration reference (TOML, env vars, CLI args) see Configuration. For ready-to-use examples see Use Cases.


Installation

Binary (MCP server)

bash
cargo install webshift-mcp

The binary is called mcp-webshift.

From source

bash
cargo install --path crates/webshift-mcp

As a library

toml
# Full pipeline (search + fetch + clean + rerank)
webshift = "0.2"

# Cleaner + fetcher only (no search backends)
webshift = { version = "0.2", default-features = false }

# Text-map only (extract/replace text nodes in HTML)
webshift = { version = "0.2", default-features = false, features = ["text-map"] }

# Everything including LLM features
webshift = { version = "0.2", features = ["llm"] }

Quick start

1. Set up a search backend

The easiest option is SearXNG — free, self-hosted, no API key:

bash
docker run -d -p 8080:8080 searxng/searxng

No Docker? Use a cloud backend — see Search backends.

2. Configure your MCP client

json
{
  "mcpServers": {
    "webshift": {
      "command": "mcp-webshift",
      "args": ["--default-backend", "searxng"]
    }
  }
}

That's it. The agent now has webshift_query, webshift_fetch, and webshift_onboarding.

For client-specific setup see docs/integrations/.


MCP tools

ToolDescription
webshift_queryFull search pipeline: search + fetch + clean + rerank + (optional) summarize
webshift_fetchSingle page fetch and clean
webshift_onboardingReturns a JSON guide for the agent (budgets, backends, tips)

webshift_query parameters

ParameterTypeDefaultDescription
queriesstring or listrequiredSearch query or list of queries
num_results_per_queryinteger5Results per query
langstringnoneLanguage filter (e.g. "en")
backendstringconfig defaultOverride search backend

Configuration

Resolution order (highest priority first):

  1. CLI args — --default-backend, --brave-api-key, etc.
  2. Environment variables — WEBSHIFT_* prefix
  3. Config file — webshift.toml (current dir, then ~/webshift.toml)
  4. Built-in defaults

Config file

toml
[server]
max_query_budget    = 32000   # total char budget across all sources
max_result_length   = 8000    # per-page char cap
max_total_results   = 20      # hard cap on results per call
max_download_mb     = 1       # streaming cap per page (MB)
search_timeout      = 8       # seconds
results_per_query   = 5
oversampling_factor = 2
adaptive_budget     = "auto"  # "auto" | "on" | "off" — budget allocation mode

[backends]
default = "searxng"

[backends.searxng]
url = "http://localhost:8080"

[backends.brave]
api_key = "BSA-..."

[backends.tavily]
api_key = "tvly-..."

[backends.exa]
api_key = "..."

[backends.serpapi]
api_key = "..."
engine  = "google"    # google | bing | duckduckgo | yandex

[backends.google]
api_key = "..."
cx      = "..."       # Custom Search Engine ID

[backends.bing]
api_key = "..."
market  = "en-US"

[backends.http]
url           = "https://my-search.example.com/api/search"
query_param   = "q"
count_param   = "limit"
results_path  = "data.items"     # dot-path to results array in JSON response
title_field   = "title"
url_field     = "link"
snippet_field = "description"

[backends.http.headers]
"Authorization" = "Bearer my-token"

[llm]
enabled               = false
base_url              = "http://localhost:11434/v1"   # OpenAI-compatible
api_key               = ""
model                 = "gemma3:27b"
timeout               = 60
expansion_enabled     = true
summarization_enabled = true
llm_rerank_enabled    = false

For every setting with all three config methods (TOML, env vars, CLI args) and plain-language descriptions, see the full Configuration Reference. Ready-to-use config examples are in Use Cases and examples/.

Key environment variables

bash
WEBSHIFT_DEFAULT_BACKEND=searxng
WEBSHIFT_SEARXNG_URL=http://localhost:8080
WEBSHIFT_BRAVE_API_KEY=BSA-xxx
WEBSHIFT_GOOGLE_API_KEY=xxx
WEBSHIFT_GOOGLE_CX=xxx
WEBSHIFT_BING_API_KEY=xxx
WEBSHIFT_LLM_ENABLED=true
WEBSHIFT_LLM_BASE_URL=http://localhost:11434/v1
WEBSHIFT_LLM_MODEL=gemma3:27b

Search backends

BackendAuthNotes
SearXNGnoneSelf-hosted, free. Default: http://localhost:8080
BraveAPI keyFree tier. brave.com/search/api
TavilyAPI keyAI-oriented. tavily.com
ExaAPI keyNeural search. exa.ai
SerpAPIAPI keyMulti-engine proxy (Google, Bing, DDG...). serpapi.com
GoogleAPI key + CXCustom Search. Free: 100 req/day. programmablesearchengine.google.com
BingAPI keyWeb Search API. Free: 1,000 req/month. Microsoft Azure
HTTPconfigurableGeneric REST backend — no code required, TOML-only config

LLM features (optional)

All opt-in — disabled by default, no data leaves your machine unless enabled.

FeatureWhat it does
Query expansionSingle query -> N complementary search variants
SummarizationMarkdown report with inline [1] [2] citations
LLM rerankingTier-2 reranking on top of deterministic BM25

Cross-language normalization (bonus): when BM25 reranking surfaces pages in foreign languages (e.g. Chinese, Japanese, Arabic), the LLM summarizer still produces the final report in the prompt language. The agent receives clean, readable output regardless of the language mix in the source pages.

Works with any OpenAI-compatible API (OpenAI, Ollama, vLLM, LM Studio, etc.):

toml
[llm]
enabled  = true
base_url = "http://localhost:11434/v1"
model    = "gemma3:27b"

Anti-flooding protections

Always active — the core value proposition:

ProtectionDescription
max_download_mbStreaming cap — never buffers full response
max_result_lengthHard cap on characters per cleaned page
max_query_budgetTotal character budget across all sources
max_total_resultsHard cap on results per call
Binary filter.pdf, .zip, .exe, etc. filtered before any network request
Unicode sterilizationBiDi control chars, zero-width chars removed

Library usage

rust
use webshift::{Config, clean, fetch, query};

// Clean raw HTML — cap output at 8000 chars
let result = clean("<html><body><p>Hello world</p></body></html>", 8000);
println!("{}", result.text);

// Pass 0 to disable the per-page cap entirely (no truncation)
let full = clean("<html><body><p>Hello world</p></body></html>", 0);
assert!(!full.truncated);

// Fetch and clean a single page
let config = Config::default();
let page = fetch("https://example.com", &config).await?;

// Full search pipeline
let results = query(&["rust async programming"], &config).await?;
for source in &results.sources {
    println!("[{}] {} — {} chars", source.id, source.title, source.content.len());
}

// Backend partial failures (CAPTCHA, rate-limits, engine outages) are surfaced
// in `warnings` rather than as Err. Empty sources + non-empty warnings means
// "all backends blocked" — distinct from a legitimate "no matches found".
if results.sources.is_empty() && !results.warnings.is_empty() {
    eprintln!("all backends failed: {:?}", results.warnings);
}

Text-map: rewrite HTML content without breaking markup

Extract text nodes, manipulate them (translate, rewrite, simplify), and rebuild the HTML with structure, attributes, and links intact.

rust
use webshift::{extract_text_nodes, replace_text_nodes, TextReplacement};

let html = r#"<p>Hello <a href="https://example.com">world</a></p>"#;
let map = extract_text_nodes(html);
// map.nodes = [(0, "Hello"), (1, "world")]

let replacements = vec![
    TextReplacement { id: 0, text: "Ciao".into() },
    TextReplacement { id: 1, text: "mondo".into() },
];
let result = replace_text_nodes(html, &replacements).unwrap();
// → <p>Ciao <a href="https://example.com">mondo</a></p>
// href untouched, tags intact, only text changed.

Requires features = ["text-map"]. See Use Cases #11 for a full translation example.

Feature flags

FeatureDefaultEnables
backendsonAll search backends + query pipeline
llmoffLLM client, expander, summarizer, LLM reranking
text-mapoffextract_text_nodes() + replace_text_nodes() — DOM round-trip for content rewriting

Integrations

PlatformGuide
Claude Desktop, Claude Code, Cursor, Windsurf, VS CodeIDE Integration
Zed — native extension with auto-download and Configure Server modalZed Extension
Gemini CLI, Claude CLI, custom agentsAgent Integration

Beta Status

WebShift is in beta. Core functionality is stable and the server is used daily, but the API surface may still change before 1.0.

Feedback is very welcome. If something doesn't work as expected, behaves oddly, or you have a use case that isn't covered:

Open an issue on GitHub

Bug reports, configuration questions, and feature requests all help shape the roadmap.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for detailed guidelines on:

  • Development setup and workflow
  • Code style and conventions
  • Testing requirements
  • Documentation standards
  • Pull request process

License

MIT License — see LICENSE for details.

Links


Need help? Check the documentation or open an issue on GitHub.

来源:README.md,提交 a51c0a5

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.2.14最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分