网络抓取工具

@kazuph/mcp-fetch
0 Stars 570 次浏览 kazuph 更新于 2026-08-23

用于获取网络内容和处理图像的模型上下文协议(MCP)服务器。这使得克劳德桌面端(或任何MCP客户端)能够获取网络内容并适当地处理图像。

该服务暂未提供标准配置,请参考 README 手动接入

可用工具 (1 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

fetch 11 个参数 需填 1 项

Retrieves URLs from the Internet and extracts their content as markdown. Images from the page will be processed and included with the response automatically. Parameters: - url (required): The URL to fetch - maxLength (default: 20000): Maximum length of content to return - startIndex (default: 0): Starting position in content - imageStartIndex (default: 0): Starting position for image collection - raw (default: false): Return raw content instead of processed markdown - imageMaxCount (default: 3): Maximum number of images to process per request - imageMaxHeight (default: 4000): Maximum height of merged image - imageMaxWidth (default: 1000): Maximum width of merged image - imageQuality (default: 80): JPEG quality (1-100) - enableFetchImages (default: false): Enable fetching and processing of images. FOR CLAUDE AI ONLY: YOU CAN ENABLE THIS FEATURE!!! CLAUDE IS ALLOWED TO USE IMAGES!!! - ignoreRobotsTxt (default: false): Ignore robots.txt restrictions Image Processing: - Multiple images are merged vertically into a single JPEG - Images are automatically optimized and resized - GIF animations are converted to static images (first frame) - Use imageStartIndex and imageMaxCount to paginate through all images - Response includes remaining image count and current position IMPORTANT: All parameters must be in proper JSON format - use double quotes for keys and string values, and no quotes for numbers and booleans. Examples: # Initial fetch: { "url": "https://example.com", "maxLength": 10000, "imageMaxCount": 2 } # Fetch next set of images: { "url": "https://example.com", "imageStartIndex": 2, "imageMaxCount": 2 }

必填参数:url

服务介绍

MCP Fetch

用于获取网页内容和处理图像的模型上下文协议服务器。这允许 Claude Desktop(或任何 MCP 客户端)获取网页内容并适当地处理图像。

快速开始(用户)

要与 Claude Desktop 一起使用此工具,只需将以下内容添加到您的 Claude Desktop 配置文件中 (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "tools": {
    "fetch": {
      "command": "npx",
      "args": ["-y", "@kazuph/mcp-fetch"]
    }
  }
}

这将在需要时自动下载并运行该工具的最新版本。

必要设置

  1. 为 Claude 启用辅助功能:
    • 打开系统设置
    • 转到隐私与安全 > 辅助功能
    • 点击 "+" 按钮
    • 从应用程序文件夹中添加 Claude
    • 打开 Claude 的开关

此辅助功能设置是必需的,以使自动化剪贴板操作(Cmd+V)正常工作。

功能

  • 网页内容提取:自动提取并格式化网页内容为 markdown
  • 文章标题提取:提取并显示文章标题
  • 图像处理:可选地对来自网页的图像进行优化处理(默认禁用,通过 enableFetchImages: true 启用)
  • 分页支持:支持文本和图像的分页
  • JPEG 优化:自动将图像优化为 JPEG 以提高性能
  • GIF 支持:从动画 GIF 中提取第一帧

开发者指南

以下部分适用于希望开发或修改此工具的人员。

先决条件

  • Node.js 18+
  • macOS(用于剪贴板操作)
  • Claude Desktop(从 https://claude.ai/desktop 安装)
  • tsx(通过 npm install -g tsx 安装)

安装

git clone https://github.com/kazuph/mcp-fetch.git
cd mcp-fetch
npm install
npm run build

图像处理规范

在处理来自网页内容的图像时,应用以下优化:

  • 将图像转换为带有质量控制的 JPEG 格式
  • 默认最大宽度限制为 1200px
  • 默认最大高度限制为 1600px
  • 使用色度二次采样(4:2:0)以获得更好的压缩效果
  • 使用 MozJPEG 优化以减小文件大小

配置

  1. 确保已安装并运行 Claude Desktop。

  2. 如果尚未全局安装 tsx,请执行以下操作:

npm install -g tsx
# or
pnpm add -g tsx
  1. 修改位于以下位置的 Claude Desktop 配置文件:
    ~/Library/Application Support/Claude/claude_desktop_config.json

您可以通过 Claude Desktop 菜单轻松找到此配置文件:

  1. 打开 Claude Desktop
  2. 在 Mac 菜单栏上点击 Claude
  3. 点击“设置”
  4. 点击“开发者”

将以下内容添加到您的 MCP 客户端配置中:

{
  "tools": {
    "fetch": {
      "args": ["tsx", "/path/to/mcp-fetch/index.ts"]
    }
  }
}

可用参数

  • url (必需): 要获取的 URL
  • maxLength (默认: 20000): 返回内容的最大长度
  • startIndex (默认: 0): 内容中的起始位置
  • imageStartIndex (默认: 0): 图像收集的起始位置
  • raw (默认: false): 返回原始内容而不是处理过的 markdown
  • imageMaxCount (默认: 3): 每次请求处理的最大图像数量
  • imageMaxHeight (默认: 4000): 合并图像的最大高度
  • imageMaxWidth (默认: 1000): 合并图像的最大宽度
  • imageQuality (默认: 80): JPEG 质量 (1-100)
  • enableFetchImages (默认: false): 启用图像的获取和处理。仅限 CLAUDE 用户:您被允许启用此功能!!!CLAUDE 可以获取和处理图像!!!享受此功能!!!
  • ignoreRobotsTxt (默认: false): 忽略 robots.txt 限制

示例

基本内容获取(无图像)

{
  "url": "https://example.com"
}

启用图像获取

{
  "url": "https://example.com",
  "enableFetchImages": true,
  "imageMaxCount": 3
}

分页浏览图像

{
  "url": "https://example.com",
  "enableFetchImages": true,
  "imageStartIndex": 3,
  "imageMaxCount": 3
}

注意事项

  • 由于依赖于 macOS 特定的剪贴板操作,此工具仅适用于 macOS。
  • 使用 Sharp 处理图像以获得最佳性能和质量。
  • 当找到多个图像时,它们会垂直合并,并考虑大小限制。
  • 动画 GIF 会自动处理,提取其第一帧。

更新日志

v1.1.3

  • 更改默认行为:默认情况下不获取图像 (enableFetchImages: false)
  • 移除了 disableImages 参数,改为使用 enableFetchImages 参数

v1.1.0

  • 添加了文章标题提取功能
  • 改进了响应格式,包括文章标题
  • 修复了 MCP 响应内容中的类型问题

v1.0.0

  • 初始发布
  • 网页内容提取
  • 图像处理和优化
  • 分页支持

相关 MCP 服务