断链检查器MCP服务器
一个MCP(模型上下文协议)服务器,它利用(某种技术或方法)提供链接检查功能以检测失效链接 断链检查器 图书馆。
特点/特性
- 检查单页链接扫描单个HTML页面上的所有链接,查找损坏的链接
- 检查整个网站递归地抓取并检查整个网站的所有链接
- 详细的报告,包括HTTP状态码、失效原因以及链接元数据
- 支持排除外部链接并尊重robots.txt文件
- 两种部署模式本地工作室或远程HTTP/SSE
安装
npm install部署选项
选项1:本地使用(stdio传输)
使用 index.js 用于本地Claude Desktop集成。
选项2:远程使用(HTTP/SSE传输)
使用 server.js 用于通过ngrok或类似代理服务进行远程部署。
与Claude桌面版(本地)的使用
步骤1:配置Claude桌面版
将此服务器添加到您的Claude桌面配置文件中:
MacOS(苹果电脑操作系统): ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"broken-link-checker": {
"command": "node",
"args": ["/Users/davinoishi/Documents/Projects-AI/BLC/index.js"]
}
}
}确保更新路径以匹配您的实际安装目录。
步骤2:重启Claude桌面版
更新配置后,请重启Claude Desktop以使更改生效。
第三步:使用工具
MCP服务器提供了两种主要工具:
1. check_page_links
检查单个HTML页面上的所有链接。
参数:
url(必填):要检查的页面的URLexcludeExternalLinks(可选):如果为真,则仅检查内部链接(默认:假)honorRobotExclusions(可选):如果为真,则尊重 robots.txt(默认:真)
示例:
Can you check the links on https://example.com for any broken links?2. check_site
递归地抓取并检查整个网站上的所有链接。
参数:
url(必填):要检查的网站的起始URLexcludeExternalLinks(可选):如果为真,则仅检查内部链接(默认:假)honorRobotExclusions(可选):如果为真,则遵守 robots.txt(默认值:真)maxSocketsPerHost(可选):每个主机的最大并发请求数(默认值:1)
示例:
Can you crawl https://example.com and check all pages for broken links?使用HTTP/SSE传输进行远程部署
对于远程部署(例如,在VPS上部署并通过ngrok连接),请使用HTTP/SSE服务器:
步骤1:启动HTTP服务器
# Start the HTTP/SSE server (default port 3000)
npm run start:http
# Or specify a custom port
PORT=8080 npm run start:http服务器将在(指定时间/条件下)启动 http://localhost:3000 (或您指定的端口)。
步骤2:使用ngrok(或其他替代工具)进行暴露(或公开访问)
# Install ngrok if you haven't already
npm install -g ngrok
# Expose your local server
ngrok http 3000ngrok 将为您提供一个类似这样的公共 URL: https://abc123.ngrok.io
步骤3:配置Claude Desktop以进行远程连接
更新您的Claude桌面配置以使用HTTP/SSE传输:
MacOS(苹果电脑操作系统): ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"broken-link-checker": {
"url": "https://your-ngrok-url.ngrok.io/sse"
}
}
}替换 your-ngrok-url.ngrok.io 使用你实际的ngrok URL。
步骤4:测试连接
- 检查健康状态端点:
https://your-ngrok-url.ngrok.io/health - 重启Claude桌面版
- 请Claude检查网页上的链接
环境变量
您可以使用环境变量来配置服务器:
# Copy the example environment file
cp .env.example .env
# Edit .env with your settings
PORT=3000
HOST=0.0.0.0生产部署
对于生产环境部署,请考虑:
- 使用进程管理器 (PM2, systemd):
npm install -g pm2
pm2 start server.js --name broken-link-checker-mcp
pm2 save
pm2 startup- 使用反向代理 (nginx, Caddy) 用于 HTTPS
- 添加身份验证 如果公开曝光
- 监控日志和资源使用情况
输出格式
这两个工具都返回具有以下结构的JSON:
{
"summary": {
"totalLinks": 100,
"brokenLinks": 5,
"workingLinks": 95
},
"brokenLinks": [
{
"url": "https://example.com/broken-page",
"base": "https://example.com",
"broken": true,
"brokenReason": "HTTP_404",
"http": {
"statusCode": 404
}
}
]
}发展
主要服务器代码位于 index.js服务器使用:
@modelcontextprotocol/sdk用于MCP协议实现broken-link-checker用于链接检查功能
许可证
麻省理工学院(MIT)
