这是一个基于 TypeScript 的 MCP 服务器,可借助 UseScraper API 实现网页抓取功能。它仅暴露了一个名为 'scrape' 的工具,却能以多种格式从网页中提取内容。
scrape:用于从网页中提取内容。
url(必填):待抓取网页的 URL。format(可选):保存内容的格式,支持 text、html、markdown,默认格式为 markdown。advanced_proxy(可选):可使用高级代理来规避反爬虫检测,默认值为 false。extract_object(可选):用于指定要提取的数据对象。若要为 Claude Desktop 自动安装 UseScraper,可通过 Smithery 执行以下命令:
npx -y @smithery/cli install usescraper-server --client claude
git clone https://github.com/your-repo/usescraper-server.git
cd usescraper-server
npm install
npm run build
若要与 Claude Desktop 配合使用,需添加服务器配置:
~/Library/Application Support/Claude/claude_desktop_config.json。%APPDATA%/Claude/claude_desktop_config.json%。{
"mcpServers": {
"usescraper-server": {
"command": "node",
"args": ["/path/to/usescraper-server/build/index.js"],
"env": {
"USESCRAPER_API_KEY": "your-api-key-here"
}
}
}
}
请将 /path/to/usescraper-server 替换为服务器的实际路径,并将 your-api-key-here 替换为你的 UseScraper API 密钥。
完成配置后,可通过 MCP 接口使用 'scrape' 工具,示例如下:
{
"name": "scrape",
"arguments": {
"url": "https://example.com",
"format": "markdown"
}
}
若要进行带有自动重建的功能开发,可执行以下命令:
npm run watch
由于 MCP 服务器通过标准输入输出进行通信,调试可能存在一定挑战。我们推荐使用 MCP Inspector,可通过以下包脚本运行:
npm run inspector
Inspector 会提供一个 URL,你可在浏览器中访问该 URL 来使用调试工具。