mcpField
L
Linkinator

Linkinator

本地服务
github.com/JustinBeckwith开发工具32 周前更新

关于 Linkinator

Linkinator 是基于 linkinator 检查网站和本地文件链接的 MCP 服务,适用于 AI 助手和文档团队,并支持递归抓取及检查 HTML、CSS 和 Markdown。

主要功能

  1. 01扫描网站和本地文件
  2. 02递归抓取同域链接
  3. 03检查 HTML、CSS 和 Markdown
  4. 04验证 URL 片段
  5. 05配置重试、超时和 SSL
  6. 06报告失效链接及状态码

适用场景

  1. 01查找网站中的失效链接
  2. 02检查本地文档链接
  3. 03验证 CSS URL 和页面锚点

MCP 相关

通过 `scan_page` 工具向 MCP 客户端提供链接检查功能,并支持基于 linkinator 命令行选项的配置。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"linkinator": {
"command": "npx",
"args": [
"-y",
"linkinator-mcp"
]
}
}
}
启动命令npx -y linkinator-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmlinkinator-mcp1.0.3

工具

1

收录的工具列表 · 更新于 3 周前

参数类型必填说明
pathstring是要扫描的 URL 或本地文件路径
concurrencynumber否同时建立的连接数(默认值:100)
portnumber否本地扫描的服务器端口(默认使用随机端口)
timeoutnumber否请求超时时间(毫秒)(0 = 无超时)
recurseboolean否在同一域名下递归跟踪链接
serverRootstring否服务器启动时使用的自定义磁盘位置
directoryListingboolean否自动提供目录索引文件
cleanUrlsboolean否启用无扩展名链接解析(例如:/about → /about.html)
markdownboolean否解析并扫描 Markdown 文件
checkCssboolean否提取并验证 CSS 属性中的 URL
checkFragmentsboolean否验证 URL 锚点标识符
linksToSkiparray否要排除的 URL 模式(正则表达式字符串)
userAgentstring否自定义 User-Agent 请求头
retryboolean否使用 retry-after 标头重试 HTTP 429 响应
retryErrorsboolean否重试 5xx 错误
retryErrorsCountnumber否重试次数上限
retryErrorsJitternumber否重试之间的随机延迟(毫秒)
allowInsecureCertsboolean否接受无效的 SSL 证书

详细介绍

Linkinator MCP 服务

npm version CI Biome codecov

linkinator-mcp

一个使用 linkinator 提供链接检查功能的模型上下文协议(MCP)服务。它可以让 Claude 等 AI 助手扫描网页和本地文件,查找失效链接。

功能

  • 全面检查链接:扫描网站和本地文件,查找失效链接
  • 递归爬取:跟踪同一域名内的链接
  • 多种内容类型:检查 HTML、CSS 和 Markdown 文件中的链接
  • 片段验证:验证锚点链接和 URL 片段
  • 灵活配置:提供超时、重试、SSL 等丰富选项
  • 详细报告:获取状态码、按错误类型分组的失效链接以及父页面信息

快速设置(自动)

最快捷的入门方式是使用 install-mcp 工具,它会自动为 Claude Desktop、Claude Code、Cursor、Cline 和其他 MCP 客户端配置 linkinator-mcp:

npx install-mcp linkinator-mcp --client claude

该工具会自动处理所有配置。安装后请重启 Claude 客户端。

手动配置

如果希望手动配置服务,可以直接编辑 MCP 客户端的配置文件。

Claude Code
macOS/Linux

编辑 ~/.config/claude-code/config.json:

{
  "mcpServers": {
    "linkinator": {
      "command": "npx",
      "args": ["linkinator-mcp"]
    }
  }
}
Windows

编辑 %APPDATA%\claude-code\config.json:

{
  "mcpServers": {
    "linkinator": {
      "command": "npx",
      "args": ["linkinator-mcp"]
    }
  }
}
替代方案:全局安装

如果希望先使用 npm install -g linkinator-mcp 全局安装软件包,可以简化配置:

{
  "mcpServers": {
    "linkinator": {
      "command": "linkinator-mcp"
    }
  }
}
Claude Desktop
macOS/Linux

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "linkinator": {
      "command": "npx",
      "args": ["linkinator-mcp"]
    }
  }
}
Windows

编辑 %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "linkinator": {
      "command": "npx",
      "args": ["linkinator-mcp"]
    }
  }
}
重启客户端

更新配置后,请重启 Claude 客户端,使更改生效。

使用示例

配置完成后,可以让 Claude 检查任意网页或本地文件中的链接。以下是一些提示词示例:

基本链接检查
Check all the links on https://example.com
递归扫描
Scan https://example.com recursively and check all links on the same domain
本地文件检查
Check the links in /path/to/my/documentation/index.html
高级选项
Check https://example.com with the following options:
- Recurse through all pages
- Check CSS for URLs
- Validate anchor fragments
- Skip links to google.com and facebook.com
- Use a 10 second timeout

可用选项

scan_page 工具支持 linkinator 的所有 CLI 选项:

必填项
  • path(字符串):要扫描的 URL 或本地文件路径
连接设置
  • concurrency(数字):同时建立的连接数(默认值:100)
  • port(数字):用于本地扫描的服务端口(默认使用随机端口)
  • timeout(数字):请求超时时间,单位为毫秒(0 = 不超时)
爬取行为
  • recurse(布尔值):递归跟踪同一域名内的链接
  • serverRoot(字符串):服务启动时使用的自定义磁盘位置
  • directoryListing(布尔值):自动提供目录索引文件
  • cleanUrls(布尔值):启用不带扩展名的链接解析(例如,/about → /about.html)
内容解析
  • markdown(布尔值):解析并扫描 markdown 文件
  • checkCss(布尔值):提取并验证 CSS 属性中的 URL
  • checkFragments(布尔值):验证 URL 锚点标识符
筛选与自定义
  • linksToSkip(字符串数组):要排除的 URL 模式(正则表达式字符串)
  • userAgent(字符串):自定义用户代理标头
重试逻辑
  • retry(布尔值):收到带有 retry-after 标头的 HTTP 429 响应时重试
  • retryErrors(布尔值):遇到 5xx 错误时重试
  • retryErrorsCount(数字):重试次数上限
  • retryErrorsJitter(数字):重试之间的随机延迟(毫秒)
SSL 与安全性
  • allowInsecureCerts(布尔值):接受无效的 SSL 证书

输出格式

该工具会返回格式化报告,显示:

Linkinator Scan Results for: https://example.com

Summary:
  Status: ✓ PASSED / ✗ FAILED
  Total Links: 150
  OK: 145
  Broken: 5
  Skipped: 0

Broken Links:

  Status 404:
    - https://example.com/missing-page
      Found on: https://example.com/index.html
    - https://example.com/old-blog-post
      Found on: https://example.com/blog.html

  Status 500:
    - https://api.example.com/endpoint
      Found on: https://example.com/docs.html

故障排除

Claude Code 中未显示服务
  1. 检查 config.json 中的路径是否为绝对路径,而非相对路径
  2. 确认构建目录存在:ls /path/to/linkinator-mcp/build/index.js
  3. 检查 Claude Code 日志中的错误
  4. 确保 Node.js 位于 PATH 中
权限错误

如果在 macOS/Linux 上遇到权限错误:

chmod +x /path/to/linkinator-mcp/build/index.js
端口已被占用

如果扫描本地文件时遇到端口错误,请尝试指定端口:

Check /path/to/files with port 9000

参与贡献

欢迎贡献!请参阅 CONTRIBUTING.md,了解如何开始。

许可证

MIT

相关项目

作者

Justin Beckwith [email protected]

致谢

基于 Model Context Protocol SDK 构建。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。