webfetch plus
超时安全的MCP服务器取代了Claude Code的内置WebFetch。
问题
Claude Code的内置WebFetch没有超时。当子代理呼叫时 WebFetch和fetch永远不会完成,子代理永远挂起 父代理没有恢复路径。235个子代理日志分析 显示75%的挂起子代理在WebFetch呼叫中死亡。
特性
- 硬超时(默认30秒)可防止代理挂起
- 通过defuddle进行HTML内容提取和markdown转换
- 基于磁盘的缓存,带有HTTP条件验证(ETag/If Modified Since)
- 内容类型分支(HTML、文本、JSON、XML、二进制)
- HTTP到HTTPS自动升级
- 跨主机重定向检测和报告
- 自动遵循相同的主机重定向(最多5跳)
- 仅返回元数据和文件路径,从不内联内容
- 项目或全局范围的CLI安装和卸载
安装
快速
npx webfetch-plus install这将注册MCP服务器,添加PreToolUse挂钩以阻止 内置WebFetch,并在您的 项目的Claude代码配置。
手册
将以下内容添加到您的 .mcp.json:
{
"mcpServers": {
"webfetch-plus": {
"command": "npx",
"args": ["-y", "webfetch-plus"],
"env": { "NODE_OPTIONS": "--use-system-ca" }
}
}
}全局安装
要为所有项目安装(用户级配置):
npx webfetch-plus install --scope global卸载
npx webfetch-plus uninstall对于全局范围,添加 --scope global.
配置
参数
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
| url | string | yes | - | 要获取的url。HTTP已自动升级为HTTPS。 |
| prompt | string | no | - | 获取的上下文(出于兼容性考虑接受,当前未使用)。 |
| timeout_seconds | number | no | 30 | 硬超时(秒)。 |
缓存位置
缓存的响应存储在 ~/.claude/webfetch-plus/cache/.每个 条目包含原始响应、转换后的markdown(用于HTML),以及 一 meta.json 使用ETag、Last Modified和获取时间戳的文件。
用法
该工具返回元数据和文件路径。它从不包括页面 内容内联。典型的回答如下:
URL: https://example.com/docs/api
Status: 200
Content-Type: text/html
Title: API Documentation
Files:
markdown: ~/.claude/webfetch-plus/cache/example.com//content.md
raw: ~/.claude/webfetch-plus/cache/example.com//raw.html
Size: 45.2 KB (markdown) | 128.7 KB (raw)
Fetched: 2026-04-02T14:30:00Z
Source: fresh出现错误时,工具将返回 isError: true 原因如下:
Error fetching https://example.com/unreachable
Reason: Timeout after 30 seconds报告的跨主机重定向不包括以下内容:
Redirect detected (cross-host):
From: https://old.example.com/docs
To: https://new.example.com/docs
Make a new request with the redirect URL to fetch the content.发展
git clone https://github.com/mfassaie/webfetch-plus.git
cd webfetch-plus
pnpm install
pnpm build
pnpm test
pnpm lint