
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 分