Skip to main content
Glama
CormickKneey

Web Fetch MCP Server

by CormickKneey
README.md
# Web Fetch MCP Server (Python)

基于 [zcaceres/fetch-mcp](https://github.com/zcaceres/fetch-mcp) 的 Python 实现,使用 FastMCP 框架。

## 功能

提供 4 个网页内容获取工具:

| 工具 | 描述 |
|------|------|
| `fetch_html` | 获取网页原始 HTML |
| `fetch_json` | 获取并解析 JSON 数据 |
| `fetch_txt` | 获取纯文本(去除 HTML 标签) |
| `fetch_markdown` | 获取网页并转换为 Markdown |

所有工具支持以下参数:
- `url` - 目标 URL(必填)
- `headers` - 自定义请求头(可选)
- `max_length` - 最大返回字符数,默认 50000(可选)
- `start_index` - 起始字符位置,默认 0(可选)

## 使用方式

### 本地运行

```bash
# 安装依赖
uv venv && source .venv/bin/activate
uv pip install -e .

# Stdio 模式
uv run python fetch_mcp_server.py

# SSE 模式(HTTP 服务)
uv run fastmcp run fetch_mcp_server.py:mcp --transport sse --port 8000
```

### Docker 运行

```bash
# 构建镜像
docker build -t web-fetch-mcp .

# 运行容器
docker run -d -p 8000:8000 --name web-fetch-mcp web-fetch-mcp

# 或使用 docker-compose
docker-compose up -d
```

## MCP 客户端配置

### Streamable HTTP 模式(Docker 默认)

```json
{
  "mcpServers": {
    "fetch": {
      "url": "http://localhost:8000/mcp"
    }
  }
}
```

### SSE 模式

```json
{
  "mcpServers": {
    "fetch": {
      "url": "http://localhost:8000/sse"
    }
  }
}
```

### Stdio 模式

```json
{
  "mcpServers": {
    "fetch": {
      "command": "python",
      "args": ["/path/to/fetch_mcp_server.py"]
    }
  }
}
```

## 环境变量

- `DEFAULT_LIMIT` - 默认最大返回字符数(默认: 50000)

## License

MIT

TDQS

A4.4/5.0

Scored across 4 tools

Disambiguation5/5

Each tool is clearly distinguished by its output format: HTML, JSON, plain text, and Markdown. There is no overlap in purpose since the format determines the correct tool to use.

Naming Consistency5/5

All tool names follow the exact same verb_noun pattern: fetch_html, fetch_json, fetch_txt, fetch_markdown. This makes the tool set highly predictable and easy to navigate.

Tool Count5/5

Four tools is well-scoped for a web fetching server, covering the most common output formats without unnecessary bloat. Each tool earns its place and there is no redundancy.

Completeness5/5

The tool surface fully covers the stated purpose of fetching web content, including raw HTML, structured JSON, readable text, and Markdown. There are no obvious dead ends or missing core operations for a fetch-only server.

Maintenance

ActivityInactive
ResponsivenessNo issues