抓取整个网站并用作MCP服务器
https://github.com/user-attachments/assets/ebe2d7c6-4ddc-4a37-8e1e-d80fac49d8ae
<details> <summary><bold>日语演示</bold></summary>https://github.com/user-attachments/assets/24288140-be2a-416c-9e7c-c49be056a373
</details>一次性使用(选择以下之一):
bunx sitemcp
npx sitemcp
pnpx sitemcp
全局安装(选择以下之一):
bun i -g sitemcp
npm i -g sitemcp
pnpm i -g sitemcp
sitemcp https://daisyui.com
# 或更好的并发性
sitemcp https://daisyui.com --concurrency 1
使用 -t, --tool-name-strategy 指定工具名称策略,它将作为MCP服务器名称(默认:domain)。
这将作为MCP服务器名称。
sitemcp https://vite.dev -t domain # indexOfVite / getDocumentOfVite
sitemcp https://react-tweet.vercel.app/ -t subdomain # indexOfReactTweet / getDocumentOfReactTweet
sitemcp https://ryoppippi.github.io/vite-plugin-favicons/ -t pathname # indexOfVitePluginFavicons / getDocumentOfVitePluginFavicons
使用 -l, --max-length 指定内容的最大长度,默认为 2000 字符。
这对于具有长内容的站点非常有用,例如博客或文档。
可接受的内容长度取决于您使用的MCP客户端,因此请查看您的MCP客户端文档以获取更多详细信息。
如果您有任何疑问,也欢迎提出问题。
sitemcp https://vite.dev -l 10000
使用 -m, --match 标志指定要抓取的页面:
sitemcp https://vite.dev -m "/blog/**" -m "/guide/**"
匹配模式会针对目标页面的路径名进行测试,由micromatch提供支持,您可以查看所有支持的匹配特性。
我们使用 mozilla/readability 从网页中提取可读内容,但在某些页面上可能会返回无关内容,在这种情况下,您可以指定一个CSS选择器,这样我们就知道在哪里找到可读内容:
sitemcp https://vite.dev --content-selector ".content"
您可以从您的MCP客户端执行服务器(例如Claude Desktop)。
以下是Claude Desktop的示例配置
{
"mcpServers": {
"daisy-ui": {
"command": "npx",
"args": [
"-y",
"sitemcp",
"https://daisyui.com",
"-m",
"/components/**"
]
}
}
}
sitemcp。sitemcp默认会在~/.cache/sitemcp缓存页面。您可以通过--no-cache标志禁用此功能。MIT。