Wayback Machine

io.github.Mearman由 GitHub 帳號 Mearman 發布v3.7.1更新於 Oct 24, 2026

MCP server and CLI tool for interacting with the Wayback Machine without API keys

概覽

AI 產生的概覽

本機 MCP 伺服器兼 CLI,讓助理把網址存檔到網際網路檔案館的 Wayback Machine、檢索歷史快照並比較不同版本。

可以做什麼
  • 把網址存檔到 Wayback Machine,可選擇截圖、抓取外連或等待 JavaScript 執行
  • 依時間戳或最新版本取得存檔快照的內容與中繼資料
  • 透過 CDX 索引依網址樣式、日期範圍、篩選條件與分頁檢索存檔
  • 查詢某網址的存檔統計並列出可用截圖
  • 比較兩份快照並提供視覺化差異連結
  • 清除本機回應快取
適用情境
適合在網頁內容變更前留存紀錄、查看某網站在特定日期的樣貌,或查核某個網址被存檔的頻率與時間點。
執行需求
透過 npx 在本機執行,需要 Node.js 22 以上版本。不需帳號,匿名即可使用。可選擇在 WAYBACK_ACCESS_KEY 與 WAYBACK_SECRET_KEY 提供 Internet Archive S3 憑證,以提高 SPN2 速率上限。需要能連線至 Wayback Machine 介面的網路,請求速率限制約為每分鐘 15 次。
安裝前請注意
存檔操作會向網際網路檔案館寫入一筆公開快照,抓取外連時最多會存檔 100 個連結頁面。可選的 WAYBACK_ACCESS_KEY 與 WAYBACK_SECRET_KEY 屬於密鑰,請勿寫入共用設定檔。所有查詢與存檔請求都會傳送到網際網路檔案館的公開介面。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Wayback Machine,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

MCP Wayback Machine Server

[GitHub] [npm] [Release] [CI]

MCP server and CLI tool for interacting with the Internet Archive's Wayback Machine. Supports full CDX search, snapshot content retrieval, screenshot listing, snapshot comparison, and optional authentication for higher SPN2 rate limits.

[npm downloads chart, log scale] [GitHub stars chart, log scale]

Stack: TypeScript · Node.js 22+ · ES Modules · pnpm · Turbo · Zod

Getting started

Requires Node.js 22+ and pnpm.

bash
pnpm install

Optional credentials (anonymous access works, but authenticated requests get higher SPN2 rate limits):

bash
export WAYBACK_ACCESS_KEY="your-access-key"export WAYBACK_SECRET_KEY="your-secret-key"

Obtain credentials at archive.org/account/s3.php.

Build, test, and lint

bash
pnpm validate          # typecheck + lint + build + test + untested-files check (the full CI gate)pnpm check             # typecheck + lint + build onlypnpm build             # compile TypeScript to dist/pnpm test              # run unit and integration testspnpm test:coverage     # run tests with coverage (80% line/branch/function threshold)pnpm lint              # lint with ESLintpnpm lint:fix          # auto-fix lint issues

To run a single test file:

bash
node --test tests/tools/save.unit.test.ts

End-to-end tests hit the live Wayback Machine API and are opt-in:

bash
pnpm test:e2e          # sets WAYBACK_LIVE_TESTS=1 internally via turbo

pnpm validate is the gate that must pass before a release. prepublishOnly runs it automatically.

Architecture

src/bin.ts is the entry point. It detects whether it is invoked as a CLI or loaded as an MCP server and routes accordingly.

src/  bin.ts          — entry point; dispatches to CLI or MCP server  cli.ts          — Commander-based CLI implementation  server.ts       — MCP server wiring (ListTools + CallTool handlers)  contexts.ts     — shared context (rate limiter, cache, credentials)  schemas.ts      — Zod schemas for all tool inputs; single source of truth  tools/    save.ts       — save_url tool (SPN2 API)    retrieve.ts   — get_archived_url tool    search.ts     — search_archives tool (CDX API)    status.ts     — check_archive_status tool (sparkline API)    screenshots.ts — list_screenshots tool    compare.ts    — compare_snapshots tool    cache.ts      — clear_cache tool    context.ts    — injects shared context into tool handlers  utils/    http.ts       — fetch wrapper with rate limiting and Retry-After handling    cache.ts      — in-memory + disk cache with per-endpoint TTLs    rate-limit.ts — 15 req/min token bucket    validation.ts — shared Zod validation helpers

Each tool module exports a schema (consumed by ListToolsRequestSchema) and an execution function (consumed by CallToolRequestSchema). New tools need both registrations in server.ts.

Caching TTLs are intentional — do not normalise them:

ResourceTTLReason
Snapshot content24 hImmutable once captured
Availability, CDX, sparkline1 hGrows but never mutates
Save operations30 minIdempotent per URL
Save status polling30 sChanges during active jobs

Conventions

  • TypeScript strict mode with noUncheckedIndexedAccess and exactOptionalPropertyTypes — no any, no as assertions.
  • ES Modules throughout — "type": "module" in package.json. Always use .ts extensions in relative imports (rewritten to .js at build time via rewriteRelativeImportExtensions).
  • Zod is the single source of truth for all tool input shapes. schemas.ts defines them; zodToJsonSchema derives the MCP-compatible JSON Schema.
  • Prettier formats all TypeScript: 4-space indent, double quotes, trailing commas (es5), 80-char print width, LF line endings.
  • Conventional commits are enforced by commitlint. Allowed scopes: retrieve, save, search, status, fetch, http, validation, cli, build, release, ci, deps. Commit messages must use British English.
  • Test colocation: unit tests in tests/tools/*.unit.test.ts and tests/utils/*.unit.test.ts; integration tests in tests/*.integration.test.ts. Use the Node.js built-in test runner — no Jest or Vitest.
  • erasableSyntaxOnly: true — no TypeScript syntax that cannot be stripped without transformation (no enum, no decorators, no namespace).

Gotchas

  • pnpm validate before pushing. CI runs check + test + coverage + untested-files. pnpm validate replicates this locally via Turbo.
  • Turbo caches aggressively. If you change a config file that Turbo doesn't track as an input, cached task results may be stale. Clear with pnpm turbo run <task> --force if results look wrong.
  • WAYBACK_LIVE_TESTS must be set to run test:e2e. The Turbo config passes it through via globalPassThroughEnv; don't set it in .env files — export it in your shell before running.
  • Coverage excludes src/contexts.ts, src/cli.ts, src/bin.ts, and src/tools/context.ts — these are wiring/entry-point files. The 80% threshold applies to the remaining surface.
  • Rate limiting is 15 req/min across all Wayback Machine API calls, with automatic Retry-After handling for 429 responses. Tests that mock HTTP must respect this — don't call real endpoints from unit tests.
  • noUncheckedIndexedAccess means Record<string, T> lookups return T | undefined. Never fall back to ?? default — narrow explicitly or restructure to a concrete type.
  • Node version is pinned in .tool-versions. CI tests against Node 22, 24, and 26. Do not use Node APIs that aren't available in 22.

Contributing

Commits follow Conventional Commits and are lint-checked by commitlint on PRs. PRs target main; CI must pass (check, test, coverage). Releases are fully automated via semantic-release on push to main.

After release, alias packages (wayback-machine-mcp, mcp-internet-archive, internet-archive-mcp, @mearman/mcp-wayback-machine) are published automatically by CI — do not publish these manually.

Installation

As an MCP server

CLI shorthand

Claude Code (MCP):

bash
claude mcp add wayback-machine -- npx -y mcp-wayback-machine

Claude Code (plugin marketplace):

bash
/plugin marketplace add https://github.com/Mearman/mcp-wayback-machine.git/plugin install mcp-wayback-machine@mcp-wayback-machine

OpenAI Codex:

bash
codex mcp add wayback-machine -- npx -y mcp-wayback-machine

To include optional credentials:

bash
claude mcp add wayback-machine --env WAYBACK_ACCESS_KEY=xxx --env WAYBACK_SECRET_KEY=xxx -- npx -y mcp-wayback-machine
Manual configuration

Add to the appropriate config file:

json
{  "wayback-machine": {    "command": "npx",    "args": ["-y", "mcp-wayback-machine"],    "env": {      "WAYBACK_ACCESS_KEY": "your-access-key",      "WAYBACK_SECRET_KEY": "your-secret-key"    }  }}
HarnessConfig fileConfig key
Claude Code.mcp.json (project) / ~/.claude.json (user)mcpServers
Codex~/.codex/config.toml[mcp_servers.wayback-machine]
Gemini CLI~/.gemini/settings.jsonmcpServers
Crush.crush.json / ~/.config/crush/crush.jsonmcp
Cline.cline/mcp.jsonmcpServers
Cursor.cursor/mcp.jsonmcpServers
Zed~/.config/zed/settings.jsoncontext_servers
Claude Desktop~/Library/Application Support/Claude/claude_desktop_config.jsonmcpServers

The env block is optional — the server works anonymously without credentials.

As a CLI tool

bash
npx mcp-wayback-machine save https://example.com

Or install globally:

bash
npm install -g mcp-wayback-machinewayback save https://example.com

As a Cloudflare Worker

Deploy the MCP server as a stateless Cloudflare Worker. Runs on the free tier with no paid bindings — all persistent state uses the Cache API which has no published daily limits.

bash
pnpm add -D wranglerwrangler deploy

The Worker uses the SDK's StreamableHTTPServerTransport in stateless mode (no session IDs), so each request is independent and cold starts are handled gracefully.

Environment variables (set via wrangler secret put):

VariableRequiredPurpose
WAYBACK_ACCESS_KEYNoFallback IA S3 credentials for higher SPN2 rate limits
WAYBACK_SECRET_KEYNoFallback IA S3 credentials
MCP_AUTH_TOKENNoBearer token for client authentication

When MCP_AUTH_TOKEN is set, clients must send Authorization: Bearer <token>. When absent, the Worker accepts unauthenticated requests.

Per-request credentials. Clients can pass their own IA S3 credentials on each request via HTTP headers, overriding the server's environment variables:

X-Archive-Access-Key: <your-access-key>X-Archive-Secret-Key: <your-secret-key>

This lets multiple users share a single Worker deployment while each using their own credentials for higher SPN2 rate limits. When both headers are present, they take precedence over WAYBACK_ACCESS_KEY/WAYBACK_SECRET_KEY. When absent, the Worker falls back to its environment variables.

Worker-specific files are excluded from the main tsconfig.json and type-checked separately via tsconfig.worker.json (which adds @cloudflare/workers-types).

Architecture. The stdio and Worker deployments share the same tool logic through pluggable interfaces:

ComponentStdioWorker
CachingDiskCacheBackend (OS cache dir)CacheApiBackend (caches.open())
Rate limitingInMemoryRateLimiterCacheApiRateLimiter
AuthNoneStaticTokenAuthProvider (optional)
CredentialsEnvironment variablesRequest headers, then environment variables

Quick examples

Archive https://example.com to the Wayback MachineFind all archived snapshots of https://example.com from 2023What's the earliest archived version of https://example.com?Compare the oldest and newest snapshots of https://example.comCheck how many times https://example.com has been archived

Tools

save_url

Archive a URL to the Wayback Machine using the SPN2 API.

Parameters
ParameterRequiredDescription
urlYesThe URL to archive
captureScreenshotNoCapture a screenshot as a PNG image
captureOutlinksNoAlso archive up to 100 outlinked pages
ifNotArchivedWithinNoSkip if archived within timeframe, e.g. "30d"
jsBehaviorTimeoutNoRun JavaScript for N seconds before capturing (max 30)
forceGetNoUse simple HTTP GET instead of browser rendering
delayWbAvailabilityNoDelay indexing ~12 hours to reduce server load

get_archived_url

Retrieve an archived snapshot's content and metadata.

Parameters
ParameterRequiredDescription
urlYesThe URL to retrieve
timestampNoSpecific timestamp (YYYYMMDDhhmmss) or "latest"
modifierNoURL modifier: id_ (raw), im_ (screenshot), js_ (JS), cs_ (CSS)

search_archives

Search the CDX API for archived versions of a URL.

Parameters
ParameterRequiredDescription
urlYesThe URL pattern to search for
matchTypeNoexact, prefix, host, or domain
fromNoStart date (YYYYMMDD or YYYY-MM-DD)
toNoEnd date (YYYYMMDD or YYYY-MM-DD)
limitNoMaximum results (default 10)
offsetNoSkip the first N results
collapseNoCollapse duplicates, e.g. "timestamp:8" (per hour), "digest"
filterNoFilter by field regex, e.g. ["statuscode:200", "!mimetype:image.*"]
resolveRevisitsNoResolve warc/revisit entries to original metadata
showDupeCountNoShow duplicate count per capture
pageNoPage number for pagination
pageSizeNoResults per page

check_archive_status

Check archival statistics for a URL — capture counts, yearly breakdowns, and first/last capture dates.

Parameters
ParameterRequiredDescription
urlYesThe URL to check

list_screenshots

List available screenshots for a URL.

Parameters
ParameterRequiredDescription
urlYesThe URL to find screenshots for
limitNoMaximum results (default 10)

compare_snapshots

Compare two archived snapshots of a URL. Fetches the raw content of both and provides a visual diff URL.

Parameters
ParameterRequiredDescription
urlYesThe URL to compare snapshots for
timestampANoFirst timestamp. Defaults to oldest available.
timestampBNoSecond timestamp. Defaults to newest available.

clear_cache

Clear all cached API responses. Use when fresh data is needed or after saving a new URL.

CLI usage

bash
wayback save https://example.comwayback get https://example.comwayback get https://example.com --timestamp 20231225120000wayback search https://example.com --from 2023-01-01 --to 2023-12-31 --limit 20wayback status https://example.comwayback screenshots https://example.comwayback compare https://example.comwayback compare https://example.com --timestamp-a 20230101000000 --timestamp-b 20240101000000

References

License

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.

[CC BY-NC-SA 4.0]

來源:README.md,提交 1f8ef8e

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v3.7.1最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。