websearch-mcp
Semantic web search MCP server that navigates the live web using a cheap LLM and local embeddings, caching results for fast responses to similar queries without relying on general search engines.
README
websearch-mcp
Semantic web search as an MCP server, using no general search engine — no Google, Bing, DuckDuckGo, or Exa. A cheap LLM navigates the live web, a local embedding model indexes everything it walks past, and the index answers the next similar question by itself.
The idea
Building a general web index means crawling billions of pages. This does the opposite: it looks things up only when asked, and remembers what it found.
query → local vector index
├─ good hit → return immediately (milliseconds, no API cost)
└─ no hit → navigate the live web:
LLM picks entry sites → fetch page → LLM scores the page's links
against the goal → expand only the most promising ones → repeat
→ index every page walked past
So it gets faster the more you use it: a brand-new topic takes a minute or two, and anything in that neighbourhood is a cache hit afterwards.
The load-bearing trick is that the model prunes at every node. A page has 50–150 outgoing links, so expanding all of them is exponential and hopeless. Scoring them against the goal turns the tree into a guided beam search — affordable precisely because the model is cheap.
Entry points
With no search engine, navigation starts from each site's own search — what a person does when they know which site holds the answer but not which page. Every entry below was probed live:
| Entry point | Notes |
|---|---|
| Wikipedia (en/zh) | Article URLs directly — its /w/ search is robots-disallowed. An article on X links to the authoritative sources on X, which makes it the best general-purpose hub |
| GitHub repos / issues | Site search works |
| Hacker News | Official Algolia JSON API |
| Stack Exchange | Official JSON API (the HTML site rejects non-browser user agents) |
| MDN / PyPI / PaperMC javadoc | Site search or a fixed entry page |
Sites whose search is robots-disallowed (Reddit, ArchWiki, Baidu Baike) or that are JavaScript-only shells (devdocs, the Hacker News web UI) are deliberately absent — where an official API exists, that is used instead.
Add your own with kb_add_hub, or edit websearch/hubs.py.
Tools
| Tool | Purpose |
|---|---|
web_search |
Semantic search. Checks the local index first, navigates the live web on a miss |
web_read |
Fetch one URL's main text (and index it) |
kb_status |
Index size, domains covered, cache hit rate |
kb_add_hub |
Register a site as a future entry point |
What gets stored
Per page: URL, title, summary, tags, and a 384-dimension vector — about 2KB. Page text is never retained. A hundred thousand pages fit in roughly 200MB.
Retrieval is brute-force cosine over the whole matrix (~50ms at 100k pages), so there is no ANN index to build or tune until this grows by another order of magnitude.
index.sqlite3— metadatavectors.npy+vector_ids.json— the vector matrix
Precision
Vector similarity alone is not enough. Multilingual e5 packs unrelated text into a narrow band, so an off-topic page can still score 0.80 — early versions happily answered a question about kimchi with Minecraft documentation. Retrieval is therefore followed by a cheap LLM relevance pass, and when nothing survives it says so instead of returning whatever the index happens to hold.
Being a good citizen
- robots.txt fully respected, plus a 1 req/s per-domain rate limit
- SSRF protection — hosts are resolved and private/loopback/link-local addresses refused
- Prompt injection — crawled content is always wrapped in data tags and explicitly marked as data, never instructions
- URL normalisation and content hashing to avoid re-indexing the same page
Running it
python3 -m venv .venv
.venv/bin/pip install --extra-index-url https://download.pytorch.org/whl/cpu torch
.venv/bin/pip install -r requirements.txt
cp .env.example .env # fill in OPENROUTER_API_KEY
OPENROUTER_API_KEY=... WEBSEARCH_DATA=/var/lib/websearch .venv/bin/python server.py
Wire it into any MCP client:
{
"websearch": {
"command": "/opt/websearch-mcp/.venv/bin/python",
"args": ["/opt/websearch-mcp/server.py"],
"env": {
"HOME": "/var/lib/websearch",
"HF_HOME": "/var/lib/websearch/hf",
"WEBSEARCH_DATA": "/var/lib/websearch"
}
}
}
Everything in websearch/config.py can be overridden by environment variable — navigation budget (NAV_MAX_PAGES, NAV_MAX_DEPTH, NAV_MAX_SECONDS), embedding model (EMBED_MODEL), politeness (PER_DOMAIN_DELAY), and so on. See .env.example.
Queries and summaries work in any language the embedding model covers; the LLM is asked to answer in the language of the query.
Cost
Embeddings run locally, so indexing is free. The LLM is used only for choosing entry sites, scoring links, and judging relevance — roughly $0.005 per cold query and nothing at all for a cache hit, using a cheap model such as DeepSeek V4 Flash through OpenRouter.
Honest limitations
- This does not replace a general search engine for arbitrary queries. It is strong in the areas you have actually used it in, and empty everywhere else.
- A brand-new topic costs one to two minutes on the first query. That is the price of navigating rather than querying a pre-built index.
- When a site redesigns or changes its robots.txt, the corresponding entry point breaks and
hubs.pyneeds updating.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。