FetchV2 MCP服务器
](https://pypi.org/project/fetchv2-mcp-server/)   
用于web内容获取和提取的模型上下文协议(MCP)服务器。
此MCP服务器提供用于获取网页、提取干净内容的工具 编织,并发现批处理链接。
特性
- 获取网页:从任何URL提取干净的markdown内容
- 批量抓取:在单个请求中最多获取10个URL
- 链接发现:查找并过滤任何网页上的链接
- llms.txt支持:解析和获取LLM友好的文档索引
- 智能提取:Trafilatura删除样板(导航栏、广告、页脚)
- Robots.txt合规性:通过优雅的超时处理来尊重robots.txt
- 分页支持:使用以下方式处理大页面
start_index参数
先决条件
- 安装
uv从 星体 - 使用以下命令安装Python 3.10或更高版本
uv python install 3.10
安装
或者在MCP客户端中手动配置:
{
"mcpServers": {
"fetchv2": {
"command": "uvx",
"args": ["fetchv2-mcp-server@latest"],
"disabled": false,
"autoApprove": []
}
}
}配置文件位置:
- 克劳德桌面(macOS):
~/Library/Application Support/Claude/claude_desktop_config.json - 克劳德桌面(Windows):
%APPDATA%\Claude\claude_desktop_config.json - 帆板运动:
~/.codeium/windsurf/mcp_config.json - 基罗:
.kiro/settings/mcp.json在您的项目中
从PyPI安装
# Using uv
uv add fetchv2-mcp-server
# Using pip
pip install fetchv2-mcp-server基本用法
尝试的示例提示:
- “从以下位置获取文档 ``"
- “查找上的所有链接 `` 包含“教程”
- “阅读这三页并总结差异:
[url1, url2, url3]"
可用工具
获取
获取网页并提取其主要内容作为干净的标记。
fetch(url: str, max_length: int = 5000, start_index: int = 0) -> str| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
url | str | 必填 | 要获取的网页URL |
max_length | int | 5000 | 返回的最大字符数 |
start_index | int | 0 | 分页的字符偏移量 |
get_raw_html | bool | false | 跳过提取,返回原始HTML |
include_metadata | bool | true | 包括标题、作者、日期 |
include_tables | bool | true | 在markdown中保留表 |
include_links | bool | false | 保留超链接 |
bypass_robots_txt | bool | false | 跳过robots.txt检查 |
fetch_batch
在单个请求中获取多个网页。
fetch_batch(urls: list[str], max_length_per_url: int = 2000) -> str| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
urls | list\[str\] | 必填 | URL列表(最多10个) |
max_length_per_url | int | 2000 | 每个URL的字符限制 |
get_raw_html | bool | false | 跳过所有URL的提取 |
发现链接
使用可选过滤功能发现网页上的所有链接。
discover_links(url: str, filter_pattern: str = "") -> str| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
url | str | 必填 | 要扫描的网页URL |
filter_pattern | str | “” | Regex用于过滤链接(例如。, /docs/) |
fetch_llms_txt
获取并解析 llms.txt 查找LLM友好文档的文件。
fetch_llms_txt(url: str, include_content: bool = False) -> str| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
url | str | 必填 | 指向llms.txt文件的URL |
include_content | bool | false | 同时获取所有链接页面的内容 |
max_length_per_url | int | 2000 | 当include_content=True时,每页最大字符数 |
⚠️ 重要提示: 默认情况下,只获取llms.txt索引——链接的markdown文件是 非 下载到上下文。集 include_content=True 显式获取所有链接的页面。例子:
# DEFAULT: Only fetches the index (lightweight, ~1KB)
fetch_llms_txt(url="https://docs.example.com/llms.txt")
# Returns: title + list of links with descriptions
# EXPLICIT: Fetches index + all linked .md files (can be large)
fetch_llms_txt(url="https://docs.example.com/llms.txt", include_content=True)
# Returns: structure + content of all linked pages注: 相对URL(例如。, /docs/guide.md)自动解析为绝对URL。
工作流示例
第一步: 查找相关文档页面
discover_links(url="https://docs.example.com/", filter_pattern="/guide/")第二步: 批量获取您需要的页面
fetch_batch(urls=["https://docs.example.com/guide/intro", "https://docs.example.com/guide/setup"])鼓励
- fetch_手册 -用户发起的获取绕过robots.txt
- 研究主题 -通过获取多个相关URL来研究主题
发展
# Clone and install
git clone https://github.com/praveenc/fetchv2-mcp-server.git
cd fetchv2-mcp-server
uv sync --dev
source .venv/bin/activate
# Run tests
uv run pytest
# Run with MCP Inspector
mcp dev src/fetchv2_mcp_server/server.py
# Linting and type checking
uv run ruff check .
uv run pyright许可证
麻省理工学院-见 许可证 了解详情。
贡献
欢迎投稿!请看 贡献.md 作为指导方针。
支持
对于问题和疑问,请使用 .
