Custom Fetch MCP

Custom Fetch MCP

Enables Claude Code users with third-party APIs to fetch web pages locally, extracting main content without relying on the official Anthropic API.

Category
Visit Server

README

Claude Custom Fetch MCP

为使用第三方 API 的 Claude Code 用户提供网页抓取能力的 MCP 服务器。

解决什么问题

Claude Code 内置的 WebFetch 工具依赖 Anthropic 官方 API 的服务端能力。当你使用第三方 API 提供商(SiliconFlow、自建网关等)时,WebFetch 无法正常工作。

本 MCP 服务器在本地发起 HTTP 请求抓取网页,不依赖任何 API 提供商,只要你的电脑能上网就能工作。

功能

  • 网页抓取:抓取网页并提取正文内容(去除广告、导航等干扰元素)
  • 智能缓存:基于 SQLite 的本地缓存,避免重复请求(默认 1 小时过期)
  • API 检测:自动检测当前 Claude Code 的 API 配置
  • 网络测试:测试到各网站的连通性

限制

  • 无法抓取需要 JavaScript 渲染的页面(如 SPA 应用、聊天界面等)
  • 无法抓取需要登录的页面

安装

1. 克隆仓库并安装依赖

git clone https://github.com/lyshrines/claude-custom-fetch-mcp
cd claude-custom-fetch-mcp
pip install -r requirements.txt
pip install truststore

2. 配置 Claude Code

在你的项目根目录(或 home 目录)创建 .mcp.json

{
  "mcpServers": {
    "custom-fetch": {
      "command": "python",
      "args": ["-m", "mcp_fetch.server"],
      "env": {
        "PYTHONPATH": "/path/to/claude-custom-fetch-mcp",
        "USERPROFILE": "C:\\Users\\YourName",
        "CACHE_TTL": "3600",
        "MAX_CACHE_SIZE_MB": "100",
        "LOG_LEVEL": "INFO"
      }
    }
  }
}

Windows 用户注意env 中需要显式设置 USERPROFILE,否则日志路径解析可能失败。

3. 启用 MCP 服务器

~/.claude/settings.json 中添加:

{
  "enabledMcpjsonServers": ["custom-fetch"]
}

重启 Claude Code,在 /mcp 中应能看到 custom-fetch 已启用。

4. 推荐:在 CLAUDE.md 中添加指令

# 联网抓取
当需要抓取网页内容时,优先使用 custom-fetch MCP 的 `fetch_url` 工具,而非内置 WebFetch(内置 WebFetch 在非官方 API 下不可用)。

提供的工具

fetch_url

抓取网页并提取内容。

参数 类型 必填 默认值 说明
url string - 要抓取的 URL
use_cache boolean true 是否使用缓存
extract_main boolean true 是否只提取正文
timeout number 15 超时时间(秒)

detect_api_provider

检测当前 Claude Code 的 API 配置,判断是否使用官方 API。

cache_stats

查看缓存统计信息。

clear_cache

清理缓存。older_than 参数指定清理多少秒前的条目,0 表示全部清理。

network_test

测试到指定网站的连通性。sites 参数传入 URL 列表。

依赖

  • Python 3.10+
  • mcp - MCP SDK
  • requests - HTTP 客户端
  • truststore - 使用系统 SSL 证书
  • readability-lxml - 正文提取
  • beautifulsoup4 - HTML 解析
  • lxml - XML/HTML 处理

许可证

MIT License

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured