VOOZH about

URL: https://glama.ai/mcp/servers/modelcontextprotocol/fetch?locale=zh-CN

⇱ Fetch MCP 服务器 by modelcontextprotocol | Glama


Fetch MCP 服务器

一个提供网页内容抓取功能的模型上下文协议 (MCP) 服务器。此服务器使 LLM 能够检索和处理网页内容,并将 HTML 转换为 Markdown 以便更轻松地阅读。

[!CAUTION] 此服务器可以访问本地/内部 IP 地址,可能存在安全风险。在使用此 MCP 服务器时请务必小心,以确保不会泄露任何敏感数据。

fetch 工具会截断响应,但通过使用 start_index 参数,您可以指定从何处开始提取内容。这允许模型分块读取网页,直到找到所需的信息。

可用工具

  • fetch - 从互联网抓取 URL 并将其内容提取为 Markdown。

    • url (字符串,必需): 要抓取的 URL

    • max_length (整数,可选): 返回的最大字符数(默认值:5000)

    • start_index (整数,可选): 从该字符索引开始提取内容(默认值:0)

    • raw (布尔值,可选): 获取原始内容而不进行 Markdown 转换(默认值:false)

提示词 (Prompts)

  • fetch

    • 抓取 URL 并将其内容提取为 Markdown

    • 参数:

      • url (字符串,必需): 要抓取的 URL

安装

可选:安装 node.js,这将使 fetch 服务器使用更健壮的 HTML 简化器。

使用 uv (推荐)

使用 uv 时无需特殊安装。我们将使用 uvx 直接运行 mcp-server-fetch

使用 PIP

或者,您可以通过 pip 安装 mcp-server-fetch

pip install mcp-server-fetch

安装完成后,您可以将其作为脚本运行:

python -m mcp_server_fetch

Related MCP server: Fetch MCP Server

配置

为 Claude.app 配置

添加到您的 Claude 设置中:

{
 "mcpServers": {
 "fetch": {
 "command": "uvx",
 "args": ["mcp-server-fetch"]
 }
 }
}
{
 "mcpServers": {
 "fetch": {
 "command": "docker",
 "args": ["run", "-i", "--rm", "mcp/fetch"]
 }
 }
}
{
 "mcpServers": {
 "fetch": {
 "command": "python",
 "args": ["-m", "mcp_server_fetch"]
 }
 }
}

为 VS Code 配置

如需快速安装,请使用下方的一键安装按钮...

👁 Install with UV in VS Code
👁 Install with UV in VS Code Insiders

👁 Install with Docker in VS Code
👁 Install with Docker in VS Code Insiders

对于手动安装,请将以下 JSON 块添加到 VS Code 的用户设置 (JSON) 文件中。您可以通过按 Ctrl + Shift + P 并输入 Preferences: Open User Settings (JSON) 来执行此操作。

或者,您可以将其添加到工作区中名为 .vscode/mcp.json 的文件中。这将允许您与他人共享配置。

请注意,使用 mcp.json 文件时需要 mcp 键。

{
 "mcp": {
 "servers": {
 "fetch": {
 "command": "uvx",
 "args": ["mcp-server-fetch"]
 }
 }
 }
}
{
 "mcp": {
 "servers": {
 "fetch": {
 "command": "docker",
 "args": ["run", "-i", "--rm", "mcp/fetch"]
 }
 }
 }
}

自定义 - robots.txt

默认情况下,如果请求来自模型(通过工具),服务器将遵守网站的 robots.txt 文件;但如果请求是由用户发起的(通过提示词),则不会遵守。可以通过在配置的 args 列表中添加参数 --ignore-robots-txt 来禁用此行为。

自定义 - User-agent

默认情况下,根据请求是来自模型(通过工具)还是由用户发起(通过提示词),服务器将使用以下 User-agent:

ModelContextProtocol/1.0 (Autonomous; +https://github.com/modelcontextprotocol/servers)

ModelContextProtocol/1.0 (User-Specified; +https://github.com/modelcontextprotocol/servers)

可以通过在配置的 args 列表中添加参数 --user-agent=YourUserAgent 来进行自定义。

自定义 - 代理

可以通过使用 --proxy-url 参数将服务器配置为使用代理。

Windows 配置

如果您在 Windows 上遇到超时问题,可能需要设置 PYTHONIOENCODING 环境变量以确保正确的字符编码:

{
 "mcpServers": {
 "fetch": {
 "command": "uvx",
 "args": ["mcp-server-fetch"],
 "env": {
 "PYTHONIOENCODING": "utf-8"
 }
 }
 }
}
{
 "mcpServers": {
 "fetch": {
 "command": "python",
 "args": ["-m", "mcp_server_fetch"],
 "env": {
 "PYTHONIOENCODING": "utf-8"
 }
 }
 }
}

这解决了可能导致服务器在 Windows 系统上超时的字符编码问题。

调试

您可以使用 MCP 检查器来调试服务器。对于 uvx 安装:

npx @modelcontextprotocol/inspector uvx mcp-server-fetch

或者,如果您已将包安装在特定目录中或正在对其进行开发:

cd path/to/servers/src/fetch
npx @modelcontextprotocol/inspector uv run mcp-server-fetch

贡献

我们鼓励贡献以帮助扩展和改进 mcp-server-fetch。无论您是想添加新工具、增强现有功能还是改进文档,您的投入都非常有价值。

有关其他 MCP 服务器和实现模式的示例,请参阅: https://github.com/modelcontextprotocol/servers

欢迎提交 Pull Request!请随时贡献新想法、错误修复或增强功能,使 mcp-server-fetch 变得更加强大和有用。

许可证

mcp-server-fetch 采用 MIT 许可证授权。这意味着您可以自由使用、修改和分发该软件,但需遵守 MIT 许可证的条款和条件。有关更多详细信息,请参阅项目仓库中的 LICENSE 文件。

A
license - permissive license
A
quality
B
maintenance

Maintenance

Maintainers
18dResponse time
5wRelease cycle
7Releases (12mo)
Commit activity
Issues opened vs closed

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Tools

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/modelcontextprotocol/fetch'

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