返回市场
链接生成器-mcp

链接生成器-mcp

作者:JustinBeckwith2 星标更新:2025-11-24

项目介绍

Linkinator MCP 服务器

npm 版本 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 全局安装该包,可以简化配置:

{
  8"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 检查任何网页或本地文件中的链接。以下是一些示例提示:

基础链接检查

检查 https://example.com 上的所有链接

递归扫描

递归扫描 https://example.com 并检查同一域内的所有链接

本地文件检查

检查 /path/to/my/documentation/index.html 中的链接

高级选项

使用以下选项检查 https://example.com:
- 在所有页面上递归
- 检查CSS中的URL
- 验证锚片段
- 跳过指向google.com和facebook.com的链接
- 设置10秒超时

可用选项

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 扫描结果:https://example.com

概要:
  状态:✓ 通过 / ✗ 失败
  总链接数:150
  正常:145
  断链:5
  跳过:0

断链:

  状态 404:
    - https://example.com/missing-page
      发现于:https://example.com/index.html
    - https://example.com/old-blog-post
      发现于:https://example.com/blog.html

  状态 500:
    - https://api.example.com/endpoint
      发现于: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

端口已被占用

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

使用端口 9000 检查 /path/to/files

贡献

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

许可证

MIT

相关项目

作者

Justin Beckwith justin.beckwith@gmail.com

致谢

使用 Model Context Protocol SDK 构建。