wayback_snapshots
Retrieve historical snapshots of web pages from the Wayback Machine to analyze URL changes, view archived content, and track website evolution over time.
Instructions
Get Wayback Machine snapshot history for a specific URL. Returns timestamps, status codes, and direct archive links. Shows first/last seen dates.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to get snapshot history for | |
| limit | No | Maximum snapshots to return (default: 100) |
Implementation Reference
- src/wayback/index.ts:82-117 (handler)The logic for fetching wayback snapshots from the Wayback Machine API.
export async function waybackSnapshots(url: string, limit = 100): Promise<WaybackSnapshotsResult> { await limiter.acquire(); const params = new URLSearchParams({ url, output: "json", fl: "timestamp,original,statuscode,mimetype", limit: String(limit), }); const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), 30000); try { const res = await fetch(`https://web.archive.org/cdx/search/cdx?${params}`, { signal: controller.signal }); if (!res.ok) throw new Error(`Wayback CDX returned ${res.status}`); const data: string[][] = await res.json(); const rows = data.slice(1); const snapshots: WaybackSnapshot[] = rows.map((row) => ({ timestamp: row[0] ?? "", url: row[1] ?? "", statusCode: row[2] ?? "", mimeType: row[3] ?? "", archiveUrl: `https://web.archive.org/web/${row[0]}/${row[1]}`, })); const firstSeen = snapshots.length > 0 ? snapshots[0].timestamp : undefined; const lastSeen = snapshots.length > 0 ? snapshots[snapshots.length - 1].timestamp : undefined; return { url, totalSnapshots: snapshots.length, firstSeen, lastSeen, snapshots }; } finally { clearTimeout(timeout); } } - src/wayback/index.ts:20-34 (schema)Data types for the wayback snapshot results.
interface WaybackSnapshot { timestamp: string; url: string; statusCode: string; mimeType: string; archiveUrl: string; } interface WaybackSnapshotsResult { url: string; totalSnapshots: number; firstSeen?: string; lastSeen?: string; snapshots: WaybackSnapshot[]; } - src/protocol/tools.ts:393-402 (registration)Tool registration and definition for wayback_snapshots.
const waybackSnapshotsTool: ToolDef = { name: "wayback_snapshots", description: "Get Wayback Machine snapshot history for a specific URL. Returns timestamps, status codes, and direct archive links. Shows first/last seen dates.", schema: { url: z.string().describe("URL to get snapshot history for"), limit: z.number().optional().describe("Maximum snapshots to return (default: 100)"), }, execute: async (args) => json(await waybackSnapshots(args.url as string, args.limit as number | undefined)), };