网页存档服务

提供对互联网存档Wayback Machine的访问,用于检索历史网页快照的服务。

  • by chestnutforty
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 chestnutforty/mcp-webarchive

使用说明

MCP网络档案

MCP服务器提供对Internet Archive Wayback Machine的访问,用于检索历史网页快照。

结构

mcp-webarchive/
├── pyproject.toml          # Dependencies
├── server.py               # Server with tool definitions
├── app.py                  # FastAPI HTTP transport
├── rate_limiter.py         # Rate limiting utilities
├── rate_limits.json        # Rate limiting configuration
├── Dockerfile              # Container configuration
├── CLAUDE.md               # Documentation for AI agents
├── tests/                  # Test suite
└── README.md

快速开始

uv sync
uv run fastmcp run server.py

可用工具

get_archived_snapshot(支持回溯测试)

在指定日期或之前从Wayback Machine获取网页内容。

参数:

  • url (必填):从存档中获取的URL
  • target_date (必填):YYYY-MM-DD格式的目标日期

例子:

get_archived_snapshot(url="example.com/team", target_date="2024-06-01")

list_available_snapshots

列出日期范围内URL的可用快照。

参数:

  • url (必填):用于检查快照的URL
  • start_date (可选):YYYY-MM-DD格式的日期范围的开始
  • end_date (可选):YYYY-MM-DD格式的日期范围结束
  • limit (可选):要返回的最大快照数(默认10,最大50)

例子:

list_available_snapshots(url="example.com", start_date="2024-01-01", end_date="2024-12-31")

用例

  • 检索预测问题的历史内容
  • 验证有关组织的过去信息
  • 跟踪网站随时间的变化
  • 访问可能已被删除或更改的内容

测试

uv sync --extra test && uv run pytest

速率限制

在中配置速率限制 rate_limits.json:

{
  "max_requests_per_second": 5,
  "hard_limit": null,
  "max_wait_seconds": 120,
  "tools": {}
}

互联网档案馆没有严格的费率限制,但要求应该是合理的。

回溯测试

这 get_archived_snapshot 该工具支持使用隐藏 cutoff_date 参数。回测时,该工具可确保:

  • 仅从截止日期之前检索快照
  • 如果超过截止日期,目标日期将自动以截止日期为上限

API详细信息

此MCP使用以下Wayback Machine API:

  • 可用性API: https://archive.org/wayback/available -查找最近的快照
  • API CDX: https://web.archive.org/cdx/search/cdx -列出可用快照

不需要API密钥。