Skip to main content
Glama
wxs-lang

webscout-mcp

by wxs-lang

webscout-mcp

面向 AI 代理的 Web 搜索与抓取工具,以 MCP 服务器形式提供。支持搜索、抓取、爬取,并从网页中提取结构化数据——无需 API 密钥,不按请求计费,一切都在你的机器上运行。

安装

pip install webscout-mcp

需要 Python 3.10 或更高版本。

Related MCP server: Crawl4AI RAG MCP Server

快速开始

将其添加到你的 MCP 客户端配置中(Claude Code、Cursor、Codex 等):

{
  "mcpServers": {
    "webscout": {
      "command": "webscout-mcp",
      "args": []
    }
  }
}

就这样。你的代理将获得六个工具:

  • web_search - 通过 Bing 搜索,自动回退到 DuckDuckGo HTML,无需密钥

  • web_fetch - 抓取页面并提取正文(markdown/text/html)

  • web_crawl - 支持深度和页数限制的并发 BFS 爬取,遵守 robots.txt

  • web_extract - 使用 CSS 选择器、属性、正则表达式提取结构化数据

  • cache_stats - 检查本地缓存

  • cache_clear - 清空缓存

CLI 用法

除了作为 MCP 服务器运行外,你还可以直接从命令行使用 webscout-mcp:

# Search the web (outputs JSON)
webscout-mcp search "python async libraries" --max-results 5

# Fetch a page (raw content)
webscout-mcp fetch https://example.com --extract --format markdown --raw

# Crawl a site
webscout-mcp crawl https://example.com --depth 2 --pages 10

# Start MCP server (default if no command given)
webscout-mcp serve --transport stdio

使用示例

搜索

web_search(query="best python async libraries", max_results=5)

返回结构化结果,包含标题、URL、摘要,以及提供服务的后端(bingduckduckgo)。如果 Bing 失败或更改了其标记结构,引擎会自动回退到 DuckDuckGo 的 HTML 版本——无需任何配置。

抓取页面

web_fetch(url="https://example.com", extract=true, output_format="markdown")

extract=true 会运行 trafilatura(带 readability-lxml 回退)来去除导航、广告和侧边栏——你得到的是干净的正文内容,而不是原始 HTML。

提取结构化数据

web_extract(
  url="https://example.com/products",
  rules='[
    {"name": "titles", "selector": ".product h2", "multiple": true},
    {"name": "prices", "selector": ".price", "regex": "\\$([\\d.]+)", "multiple": true},
    {"name": "links", "selector": "a.product", "attribute": "href", "multiple": true}
  ]'
)

每条规则支持 selectorattributemultipleregexdefault

爬取网站

web_crawl(seed_url="https://example.com", max_depth=2, max_pages=10, concurrency=5)

每个深度级别的页面会并发抓取(由 concurrency 控制,默认 5)。爬虫默认遵守 robots.txt——被禁止的 URL 会被跳过并计入 skipped_robots。同域限制默认开启。

作为 Python 库使用

import asyncio
from webscout_mcp import Config, Fetcher, SearchEngine

async def main():
    config = Config.from_env()
    config.ensure_dirs()

    fetcher = Fetcher(config)
    result = await fetcher.fetch("https://example.com", extract=True)
    print(result.title)
    print(result.content[:500])
    await fetcher.close()

    search = SearchEngine(config)
    results = await search.search("python async", max_results=5)
    for r in results:
        print(f"{r.position}. {r.title} - {r.url} ({r.backend})")
    await search.close()

asyncio.run(main())

工作原理

  • 搜索 先尝试 Bing,然后 DuckDuckGo HTML——两者都通过直接 HTTP 抓取实现,无需 API 密钥。结果按查询词缓存。

  • 抓取 使用 httpx,带指数退避重试(所有 httpx 错误 + HTTP 5xx)、按域令牌桶限速,以及 5 MB 内容上限。

  • 内容提取 以 trafilatura 为主,readability-lxml 自动回退——与许多稍后阅读服务背后使用的库相同。

  • 缓存 使用 SQLite,带 TTL 和大小上限;旧条目自动淘汰。重复抓取和搜索零成本。

  • 爬取 是并发 BFS,支持可配置的深度、页数、并发度、同域限制和 robots.txt 合规。使用首次抓取得到的原始 HTML,避免对每个页面重复抓取。

  • 代理支持 通过配置或环境变量,将所有 HTTP/HTTPS 请求路由到代理。

  • 日志 是结构化的,可通过 WEBSCOUT_LOG_LEVEL(DEBUG/INFO/WARNING/ERROR)和 WEBSCOUT_LOG_JSON=1(JSON 输出)配置。

一切都在本地运行。你的数据不会离开你的机器。

配置

所有设置都有合理的默认值。可通过环境变量(WEBSCOUT_ 前缀)、TOML 配置文件或 CLI 标志覆盖。

配置文件

创建 ~/.config/webscout/config.toml(或 $XDG_CONFIG_HOME/webscout/config.toml):

[cache]
ttl = 7200
max_size_mb = 512

[fetch]
timeout = 15.0
max_retries = 3

[proxy]
http = "http://proxy:8080"
https = "http://proxy:8080"

[search]
max_results = 10
backends = ["bing", "duckduckgo"]

[crawler]
max_depth = 2
max_pages = 20
concurrency = 5
respect_robots = true

[logging]
level = "WARNING"
json = false

环境变量会覆盖配置文件中的值。

环境变量

变量

默认值

作用

WEBSCOUT_CACHE_DIR

~/.cache/webscout

SQLite 缓存的存放位置

WEBSCOUT_CACHE_TTL

7200

缓存条目的有效期(秒)

WEBSCOUT_CACHE_MAX_SIZE_MB

512

淘汰前的最大缓存大小

WEBSCOUT_REQUEST_TIMEOUT

15.0

HTTP 超时(秒)

WEBSCOUT_MAX_RETRIES

3

每个请求的重试次数

WEBSCOUT_RATE_LIMIT_PER_SECOND

2.0

每个域每秒最大请求数

WEBSCOUT_SEARCH_MAX_RESULTS

10

默认搜索结果数量

WEBSCOUT_SEARCH_BACKENDS

bing,duckduckgo

逗号分隔的后端顺序

WEBSCOUT_CRAWLER_MAX_DEPTH

2

默认爬取深度

WEBSCOUT_CRAWLER_MAX_PAGES

20

每次爬取的最大页数

WEBSCOUT_CRAWLER_CONCURRENCY

5

每个深度级别的并发抓取数

WEBSCOUT_RESPECT_ROBOTS

true

爬虫是否遵守 robots.txt

WEBSCOUT_EXTRACT_OUTPUT_FORMAT

markdown

默认提取输出格式

WEBSCOUT_PROXY_HTTP

(空)

HTTP 代理 URL

WEBSCOUT_PROXY_HTTPS

(空)

HTTPS 代理 URL

WEBSCOUT_LOG_LEVEL

WARNING

日志详细程度

WEBSCOUT_LOG_JSON

0

设为 1 以输出 JSON 格式日志

CLI 标志会覆盖环境变量:

webscout-mcp --cache-ttl 3600 --cache-dir /tmp/webscout serve

传输方式

# stdio (default - works with Claude Code, Cursor, etc.)
webscout-mcp

# SSE (for remote or browser-based clients)
webscout-mcp serve --transport sse --host 0.0.0.0 --port 8000

更新日志

0.3.0

  • TOML 配置文件支持:除了环境变量外,还可通过 ~/.config/webscout/config.toml 配置

  • HTTP/HTTPS 代理支持:将所有请求路由到代理

  • 双内容提取:trafilatura 为主,readability-lxml 自动回退

  • 搜索结果去重:移除重复 URL,重新编号位置

  • 区域感知搜索region 参数现在会实际传递给 Bing 和 DuckDuckGo

  • 爬虫性能优化:消除了每页的重复抓取——爬取速度约提升 2 倍

  • 更好的重试逻辑:对所有 httpx 错误和 HTTP 5xx 进行重试

  • 修复了内容类型检测:正确的 HTML/XML 检测

0.2.0

  • 多后端搜索:Bing + DuckDuckGo HTML,带自动故障转移

  • 并发爬虫,支持可配置的并行度

  • robots.txt 合规(可配置,默认开启)

  • CLI 子命令:searchfetchcrawlserve

  • 结构化日志,带控制台和 JSON 格式化器

  • 自定义异常层级,更好的错误处理

  • 新配置项:WEBSCOUT_SEARCH_BACKENDSWEBSCOUT_CRAWLER_CONCURRENCYWEBSCOUT_RESPECT_ROBOTS

0.1.0

  • 初始版本:web_search、web_fetch、web_crawl、web_extract、cache_stats、cache_clear

  • SQLite 缓存,带 TTL 和基于大小的淘汰

  • 按域令牌桶限速

  • 指数退避重试

  • trafilatura 内容提取

开发

git clone https://github.com/wxs-lang/webscout-mcp.git
cd webscout-mcp
pip install -e ".[dev]"
pytest

许可证

MIT

Install Server
A
license - permissive license
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Reliable web access for AI agents: smart HTTP, rotating proxies, and full-browser rendering.

  • Web search for AI agents — one tool across 6 engines, routed to the cheapest + cached.

  • Live web search for AI agents. $0.001/call, x402 on Base, no API key.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wxs-lang/webscout-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server