Linkrot

io.github.CloudCorpRecords由 GitHub 账号 CloudCorpRecords 发布v0.1.0更新于 Nov 6, 2026

Docs link checker separating dead, moved, and bot-blocked links from healthy ones.

已验证STDIO仅桌面文件与存储开发者工具

概览

AI 生成的概览

本地 MCP 服务器,用于检查仓库 Markdown 中的链接,校验相对文件与锚点,外部链接仅标记为未检查。

可以做什么
  • 检查整个目录或单个 Markdown 文件中的链接,自动跳过 node_modules、.git 和 dist
  • 对照文件系统校验相对文件链接与标题锚点,报告缺失的目标文件和缺失的锚点
  • 返回 JSON 报告,统计文件数、链接数、死链、缺失锚点和未检查的外部链接,并给出 OK 或 FINDINGS 结论
  • 提取行内链接、图片链接和引用式定义,忽略围栏代码块中的链接
适用场景
适合在维护文档时让助手在发布前发现失效的相对链接和过期的锚点。也适合离线或隔离环境下的检查,此时不应抓取外部网址。
运行要求
以 stdio 方式在本机运行,可通过 npx 使用 npm 包,或使用 Docker 镜像。无需账号、API 密钥、环境变量或网络访问,只需提供要检查的路径。
安装前请注意
它会读取所给路径下的文件,请将该路径限定在目标仓库内。外部链接不会被抓取,只标记为未检查,因此无法确认远端页面是否可用。它只生成报告,不会修改文件。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Linkrot,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

linkrot

Docs link checker that separates failure kinds instead of calling every bad response a dead link. Relative links and anchors are verified against the filesystem. External links are classified by what actually happened: healthy, dead, moved, bot-blocked, or error. A 403 from a bot wall is not a dead link, and linkrot never reports it as one.

What it does

  • Walks a target directory for markdown files (skipping node_modules, .git, and dist) or checks a single markdown file.
  • Extracts inline links (image links count), reference-style definitions, and reference usages that resolve to a definition. Links inside fenced code blocks are ignored. Bare URLs in prose and autolinks are not extracted.
  • Checks each link by class:
    • RELATIVE-FILE: the path part is resolved relative to the markdown file. A missing target is a DEAD-RELATIVE finding (high).
    • RELATIVE-ANCHOR: the file exists but the anchor slug is not among the target file heading slugs. That is an ANCHOR-MISSING finding (medium). Slugs are built by lowercasing, stripping punctuation, and turning spaces into hyphens.
    • SAME-FILE-ANCHOR: a link like #section in the same file, checked against that file heading slugs with the same ANCHOR-MISSING rule.
    • EXTERNAL: http and https links are reported as UNCHECKED info entries in offline mode. They are counted and never fail the check.
    • MAILTO and other schemes are skipped silently and counted under skipped.

Install

bash
npx @reneturcios/linkrot check .

Or install globally:

bash
npm install -g @reneturcios/linkrot

CLI

bash
linkrot check [path] [--json]linkrot mcplinkrot --version
  • check runs the offline check on a path (default: current directory). Exit code is 0 when the verdict is OK and 1 for any other verdict. Use --json for the machine-readable report.
  • mcp starts the MCP server on stdio.
  • --version prints the version.

MCP

The MCP server exposes one tool:

  • check_links with a path argument. It returns the same JSON report as linkrot check --json.

Offline by default

Offline mode is the default and the shipped default. The core is synchronous and performs no network requests.

This is deliberate. The founding observation behind linkrot is that automated fetches routinely hit bot walls, login gates, and rate limits. A checker that fetches every external URL and treats any non-2xx response as dead will report healthy pages as broken whenever a site blocks bots. Offline mode avoids that failure entirely: it proves what can be proven locally (relative files and anchors) and reports external links honestly as UNCHECKED instead of guessing.

Link classes and status vocabulary

When an online mode checks external URLs in the future, each HTTP status maps to exactly one class:

ClassMeaning
healthy2xx, plus 3xx redirects that are not permanent moves (for example 302, 304, 307)
dead404 or 410: the page is gone
movedA redirect to a new location. Permanent redirects (301, 308) get the distinct label moved-permanent.
bot-blocked401, 403, or 429: a bot wall, auth gate, or rate limit answered. The page may be fine for a human.
error5xx and anything else: the check itself could not get a trustworthy answer

The function classifyStatus(status) implements this table and is unit tested. Keeping bot-blocked separate from dead is the point of the tool: conflating them turns every Cloudflare or login wall into a false dead-link report.

Verdict rules

  • Verdict is OK when there are no DEAD-RELATIVE and no ANCHOR-MISSING findings.
  • Verdict is FINDINGS otherwise.
  • UNCHECKED external entries never affect the verdict in offline mode.

The report counts files, links, dead, anchorsMissing, and externalUnchecked, plus per-class counts: relativeFile, relativeAnchor, sameFileAnchor, external, and skipped.

Limits

  • The offline core checks relative links and anchors only.
  • External liveness is not checked offline. External links are reported UNCHECKED, never guessed as healthy or dead. A future online mode will classify them with the vocabulary above.
  • Extraction covers inline links and reference definitions (with full and collapsed reference usages resolved). Shortcut reference links, bare URLs, and autolinks are not extracted.
  • Anchor checks apply when the link target is a markdown file. Anchors pointing into non-markdown files are not verified.
  • Heading slugs follow a simplified GitHub rule: lowercase, strip punctuation, spaces to hyphens, with duplicate headings suffixed -1, -2, and so on.

Development

bash
npm installnpm run buildnpm test

来源:README.md,提交 238fac3

工具

1

版本历史

1
  1. v0.1.0最新Oct 30, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分