docslurp
允许Claude Code访问任何文档。始终保持最新状态,从未产生过幻觉。
这是什么?
docslurp抓取文档网站,将内容分块,生成嵌入,并创建MCP服务器。将其连接到Claude Code,Claude可以在帮助您构建的同时获取最新文档。这样,您就可以使用当前的API,而不是训练数据中的任何内容。
快速开始
# Install globally
npm install -g docslurp
# Set your API keys
export OPENAI_API_KEY=sk-...
# Create an MCP server from docs (use --playwright or --firecrawl for JS-rendered sites)
docslurp https://docs.example.com --name my-docs
# Install the generated server's dependencies
cd ~/.docslurp/servers/my-docs && npm install
# Add to Claude Code
claude mcp add my-docs -- node ~/.docslurp/servers/my-docs/index.js就是这样。Claude现在可以实时访问文档,同时帮助您构建。
运作原理
- 爬行 -docslurp通过内部链接从您的文档网站获取页面
- 块 -长页面被分割成更小的部分(重叠以保持上下文)
- 嵌入 -使用OpenAI的嵌入API将每个区块转换为向量
- 商店 -所有内容都会进入支持向量搜索的SQLite数据库
- 生成 -创建了一个可以搜索这些矢量的MCP服务器
生成的服务器有三个工具:
search-查找相关段落ask-通过源引用获取答案sources-查看索引了哪些页面
命令
| 命令 | 它的作用 |
|---|---|
docslurp --name | 从文档站点创建MCP服务器 |
docslurp add --to | 向现有服务器添加更多文档 |
docslurp update | 重新抓取并刷新所有来源 |
docslurp sources | 列出所有来源及其统计数据 |
docslurp list | 显示所有服务器 |
docslurp remove | 删除服务器 |
docslurp connect | 打印命令以将其添加到Claude代码中 |
选项
对于 create 和 add:
--name, -n Name for the server (required for create)
--to, -t Server to add to (required for add)
--depth, -d How many links deep to crawl (default: 3)
--max-pages, -m Maximum pages to crawl (default: 100)
--firecrawl, -f Use Firecrawl API for JS-rendered sites (fast, 500 page limit on free tier)
--playwright, -p Use Playwright for JS-rendered sites (slower but free, no limits)
--force Skip duplicate check, add as new source (add only)
--continue Resume an interrupted crawl (add only)对于 update:
--url, -u Only update a specific source URL
--depth, -d How many links deep to crawl (default: 3)
--max-pages, -m Maximum pages to crawl (default: 100)
--firecrawl, -f Use Firecrawl for JS-rendered sites
--playwright, -p Use Playwright for JS-rendered sites需求
您需要一个OpenAI API密钥来生成嵌入:
export OPENAI_API_KEY=sk-...生成的服务器在运行时也使用此键进行搜索查询。
创建服务器后,在使用之前安装其依赖项:
cd ~/.docslurp/servers/ && npm installJavaScript渲染网站
一些文档网站(如Salesforce、Notion等)使用JavaScript加载内容。默认的爬虫程序不会拾取这些。您有两个选择:
选项1:剧作家(免费,无限制)
Playwright运行一个真正的浏览器来渲染页面。它速度较慢,但完全免费,没有页面限制:
docslurp https://developer.salesforce.com/docs --name sf-docs --playwright注意:第一次运行将下载浏览器二进制文件(~150MB)。
选项2:Firecrawl(快速、基于API)
Firecrawl速度更快,但需要API密钥,并且在自由层上有500页的限制:
export FIRECRAWL_API_KEY=fc-...
docslurp https://developer.salesforce.com/docs --name sf-docs --firecrawl获取API密钥:https://firecrawl.dev.
东西住的地方
服务器存储在 ~/.docslurp/servers/.每个都有:
index.js-MCP服务器vectors.db-带嵌入的SQLite数据库config.json-关于爬网的元数据package.json-依赖关系(运行npm install此处为使用前)
例子
# Index React docs (static site, default crawler works fine)
docslurp https://react.dev/learn --name react-docs
# Index Salesforce docs with Playwright (free, no limits)
docslurp https://developer.salesforce.com/docs --name sf-docs --playwright
# Index Salesforce docs with Firecrawl (faster but has page limits)
docslurp https://developer.salesforce.com/docs --name sf-docs --firecrawl
# Index with more depth
docslurp https://docs.myproject.dev --name myproject --depth 5
# Limit pages for a smaller index
docslurp https://docs.python.org/3/tutorial --name python-tutorial --max-pages 50组合多个文档源
您可以将来自不同站点的文档合并到单个服务器中:
# Create server with first doc source
docslurp https://docs.stripe.com --name payment-apis
# Add more sources to the same server
docslurp add https://www.twilio.com/docs --to payment-apis
docslurp add https://docs.plaid.com --to payment-apis现在搜索 payment-apis 将同时访问所有三个文档源。
自动重复数据删除:如果您添加了一个已经存在的URL,docslurp将更新它,而不是创建重复的URL:
# This updates the existing source instead of duplicating
docslurp add https://docs.stripe.com --to payment-apis
# Use --force to add as a new source anyway
docslurp add https://docs.stripe.com --to payment-apis --force更新文档
当文档发生更改时,请重新抓取以获取最新内容:
# Update all sources for a server
docslurp update my-docs
# Update just one specific source
docslurp update my-docs --url https://docs.example.com
# See what sources exist
docslurp sources my-docs这 sources 命令显示每个源的页数和添加时间:
Sources for my-docs:
ID URL Pages Chunks Added
────────────────────────────────────────────────────────────────────────────────
1 https://docs.stripe.com 42 215 1/15/2026
2 https://www.twilio.com/docs 38 189 1/20/2026
────────────────────────────────────────────────────────────────────────────────
Total: 2 source(s)局限性
- 速率限制尚未配置,因此非常大的站点可能需要一段时间
- 目前仅支持OpenAI嵌入
发展
# Clone it
git clone https://github.com/jamesagudo/docslurp.git
cd docslurp
# Install dependencies
npm install
# Build
npm run build
# Link for local testing
cd packages/cli && npm link
# If you get "permission denied" after rebuilding, clear the shell hash:
hash -r许可证
麻省理工学院
