
Mcp Webgate
io.github.x-hannibal由 GitHub 帳號 x-hannibal 發布v0.1.33更新於 Oct 24, 2026
Web search that doesn't wreck your AI's memory.
概覽
本機 MCP 伺服器,讓 AI 助理進行網頁搜尋與頁面擷取,去除 HTML 雜訊並把輸出硬性限制在字元預算內。
- 可以做什麼
- 依一個或多個查詢搜尋網頁,回傳清洗並排序後的頁面正文,以及未擷取結果的摘要池
- 擷取指定的單一網址,回傳可讀文字,並附上截斷標記與字元數
- 可選擇把結果交給相容 OpenAI 的次要模型,用於查詢擴展、語意重排或產生附引用的 Markdown 摘要
- 讀取入門指南,了解該用哪個工具以及如何調整預算
- 適用情境
- 適合助理需要上網查資料、但直接擷取原始 HTML 會塞爆上下文視窗的情況。適用於一般性檢索、多查詢搜尋與單頁閱讀,特別是重視有界、乾淨文字而非完整頁面還原時。
- 執行需求
- 以 Python 套件形式在本機執行(uvx 或 pip),需要 Python 與 uv。必須設定搜尋後端:自架的 SearXNG 實例(透過 WEBGATE_SEARXNG_URL 指定位址),或 Brave、Tavily、Exa、SerpAPI 其中之一的 API 金鑰。選用的 LLM 功能需要相容 OpenAI 的端點與模型,透過 WEBGATE_LLM_* 環境變數或 webgate.toml 設定。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mcp Webgate,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
mcp-webgate
[Python Version] [License] [MCP Protocol] [Latest Release] [Beta]
Web search that doesn't wreck your AI's memory.
mcp-webgate is an MCP server that gives your AI clean, bounded web content — across all major AI clients:
- IDEs: Claude Desktop, Claude Code, Zed, Cursor, Windsurf, VSCode
- CLI Agents: Gemini CLI, Claude CLI, custom agents
🌱 A Gentle Introduction
What is mcp-webgate? When your AI uses a standard "fetch URL" tool, it gets the raw HTML of the page — ads, menus, scripts, cookie banners and all. A single news article can dump 200,000 tokens of garbage into the AI's memory, wiping out your entire conversation.
mcp-webgate is a protective filter that sits between your AI and the web:
- Strips the junk — menus, scripts, ads, footers are removed with surgical HTML parsing; only readable text passes through
- Hard-caps every response — no page can ever blow up your context window, no matter how big the original was
- Optionally summarizes — route results through a secondary local LLM that produces a compact Markdown report with citations; your primary AI gets a polished briefing instead of a wall of text
The result: clean, bounded, useful web content — always.
🔬 Real example: what happens under the hood
Searching for "mcp model context protocol" with LLM features on:
13 sources distilled into ~1,450 tokens. A single naive fetch of just one of those pages (e.g. a security blog at 563 KB) would dump ~140,000 tokens of raw HTML into your AI's context. webgate processes all 13 and delivers a clean briefing that fits in a footnote.
This is an intensive case (5 queries × 5 results). A typical search with 3–5 results still saves 95%+ of context compared to raw fetching — and your AI gets structured, ranked content instead of a wall of HTML soup.
🚀 Quick Start
1. Make sure you have uvx
uvx runs Python tools without installing them permanently. You only need to do this once.
2. Set up a search backend
The easiest option is SearXNG — free, no account, runs locally:
No Docker? Use a cloud backend instead (Brave, Tavily, Exa, SerpAPI) — see Backends.
3. Add webgate to your AI client
See the Integrations table for your specific client. As a quick example, for Claude Desktop:
Open the config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add this:
Restart the client after editing.
4. Ask your AI to search!
The AI will use webgate_query automatically. You're done.
🔍 How it works
🛠️ Tools
webgate gives your AI three tools:
webgate_fetch — read a single page
Use this when you already know the URL you want. The AI passes the URL and gets back the cleaned text — up to max_query_budget characters (default 32,000).
webgate_query — search + fetch + clean
Runs a full search cycle. Pass one query (or several) and get back cleaned, ranked results.
Multiple queries run in parallel and are merged:
Output without LLM — returns cleaned page content for each result:
Output with LLM summarization — returns a compact Markdown report:
Output when LLM fails — error reason shown, full sources returned as fallback:
snippet_pool contains extra results from the search that were not fetched (search-engine snippet only). The AI can use these to decide if more fetches are worthwhile.
webgate_onboarding — how-to guide
Returns a JSON guide explaining how to use webgate effectively. The AI should call this once at the start of a session if in doubt about which tool to use.
🔧 Using webgate with local or smaller models
Most frontier models follow MCP tool instructions automatically. Smaller or local models sometimes ignore the server-provided guidance and fall back to a built-in fetch tool instead — returning raw HTML that floods the context with noise.
If you notice this happening, add an explicit instruction block to your system prompt:
This works because user system prompt instructions take precedence over MCP server-level guidance, making the constraint explicit at the highest-priority layer the model sees.
Tip: if your client supports named system prompts or prompt templates, save the block above as a reusable preset so you don't have to paste it every time.
🎛️ Tuning
This section explains what the key parameters do and when to change them. The defaults work well for most cases — only tweak if you have a specific reason.
What is a "character budget"?
webgate measures text in characters (not tokens). A rough conversion for English text:
4 characters ≈ 1 token
webgate_fetch budget
When you fetch a single URL, the ceiling is max_query_budget (default 32,000 chars). The tool parameter max_chars can request less, but never more than this ceiling.
Why max_query_budget and not max_result_length? Because you're fetching one page — the "total output" IS that one page, so the right limit is the overall context budget, not the per-page cap designed for multi-source queries.
webgate_query budget — without LLM
With no LLM, the cleaned sources go directly to your AI's context. webgate distributes max_query_budget across all fetched pages so the total never exceeds the budget:
Per-page limit =
max_query_budget÷ number of results (capped atmax_result_length)
The total output is always at most max_query_budget, regardless of how many results you request — the per-page share automatically shrinks to compensate.
webgate_query budget — with LLM summarization
When a secondary LLM is summarizing, it compresses the content before passing the result to your primary AI. This means it's safe — and beneficial — to give it more raw material to work from.
webgate scales up the input using input_budget_factor (default 3):
LLM input budget =
max_query_budget×input_budget_factorDefault: 32,000 × 3 = 96,000 chars
The secondary LLM sees much more content per page. Your primary AI sees only the final report — typically 1,000–3,000 tokens — regardless of how many sources were processed. This is the main efficiency advantage of LLM mode.
Quick tuning guide
🤖 LLM Features
Optional, opt-in. When llm.enabled = false (the default), webgate is fully deterministic. Enable the [llm] block to unlock three extra capabilities.
🤔 When to enable LLM features
Privacy: with LLM disabled, no data leaves your machine except web requests. With LLM enabled, cleaned search results (not raw HTML) are sent to the configured base_url. Point it at a local Ollama instance to keep everything on-device.
Latency trade-off: each enabled feature adds one LLM round-trip per query. Expansion adds ~1–5s; summarization adds ~5–30s depending on model and content volume. For interactive use, summarization with a fast local model (e.g. Gemma 3 4B) is a good starting point.
Setup
Or with env vars:
base_url accepts any OpenAI-compatible endpoint: OpenAI, Ollama, LM Studio, vLLM, Together AI, Groq, and others.
Query expansion
When you send a single query and expansion_enabled = true, the LLM automatically generates complementary search variants before hitting the backend. If you already pass multiple queries, this step is skipped.
Falls back silently to your original query if the LLM fails.
Summarization
When summarization_enabled = true, the LLM reads all fetched pages and writes a structured Markdown report with inline citations. Your AI receives the report instead of the raw text.
- Success:
summary+citations(lean output — no raw content passed to your AI) - Failure:
llm_summary_errorwith the reason + fullsourcesas fallback (your AI can still work with the cleaned content)
The report length target is max_summary_words. When 0 (default), it is derived from max_query_budget / 5 — e.g. with a 32k budget, the target is ~6,400 words.
Reranking
Results are always reranked by BM25 (keyword overlap, zero cost) before being returned. Optionally, the LLM can do a second pass for semantic relevance:
LLM reranking adds latency proportional to your LLM response time. Enable it only if result ordering matters more than speed.
Pipeline: clean → BM25 rerank → (LLM rerank) → (LLM summarize) → output
🔗 Integrations
mcp-webgate works with all major AI clients:
📦 Installation
Via uvx (recommended — no install needed)
Via pip / uv
⚙️ Full Configuration
Ready-to-use config files are in examples/.
Resolution order
Config is read once at startup; restart the server to apply changes.
You can configure webgate in three ways — mix and match as needed:
webgate.toml— checked at startup in./webgate.tomlthen~/webgate.toml- Env vars —
WEBGATE_*prefix, always strings (MCP JSON requirement) - CLI args —
--kebab-case, integers stay integers, ideal for multi-instance setups
Config file (webgate.toml)
MCP client config examples
With env vars (all values must be strings):
With CLI args (integers stay integers — ideal for running independent instances in Zed, Cursor, etc.):
Boolean flags support --flag / --no-flag syntax (e.g. --llm-enabled, --no-llm-rerank-enabled).
Full reference
🔌 Backends
SearXNG quickstart (Docker)
Then set WEBGATE_SEARXNG_URL=http://localhost:8080.
Exa notes
Exa uses neural (semantic) search by default — the primary reason to use it over keyword backends. use_autoprompt is hardcoded to false (not user-configurable) because mcp-webgate handles query expansion via its own LLM expander.
SerpAPI notes
engine selects the underlying search engine (google, bing, duckduckgo, yandex, yahoo). gl and hl significantly affect result quality for non-English queries.
🐛 Debug mode
When enabled, every tool call logs a structured entry:
fetch: URL, raw KB downloaded, clean KB returned, elapsed msquery: queries used, results requested/fetched/failed, raw MB, clean KB, total elapsed ms
🛡️ Protections summary
These protections are always active — they are the core value proposition and cannot be disabled.
📚 Documentation Structure
Integration Guides
- IDE Integration — Claude Desktop, Claude Code, Zed, Cursor, Windsurf, VSCode
- Agent Integration — Gemini CLI, Claude CLI, custom agents
- Advanced Features — BM25/LLM reranking internals, adaptive budget allocation
🧪 Beta Status
mcp-webgate is in beta. Core functionality is stable and the server is used in production, but the configuration API 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:
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
- GitHub Repository — Source code and issues
- PyPI Package — Python Package Index
- MCP Registry — Model Context Protocol Registry
- MCP Protocol — Model Context Protocol specification
Need help? Check the documentation or open an issue on GitHub.
來源:README.md,提交 d17b95c
工具
0版本歷史
1- v0.1.33最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分