CrawlForge MCP
AI 工具5 credits

generate_llms_txt

爬取站点、分析其结构,并生成符合标准的 llms.txt(及可选的 llms-full.txt)文件,用于定义 AI 模型应如何与你的内容交互。合规级别从宽松到严格可选。

使用场景

发布 AI 就绪的文档

在文档旁发布 llms.txt,让 Claude、ChatGPT 等爬虫读取清晰的准则。

AI 合规发布

使用严格合规级别,在一处统一设置训练数据、缓存和署名规则。

机器人策略生成

为你域名上特定的 AI user agent 添加自定义准则和限制。

Endpoint

POST/api/v1/tools/generate_llms_txt
Auth Required
Free 计划 1 req/s
5 credits

Parameters

重负载操作: 此工具可能爬取多达 500 个页面。它使用预留系统,因此 credits 会在任务期间被占用。
NameTypeRequiredDefaultDescription
url
stringRequired-
要为其生成 llms.txt 的网站 URL
Example: https://example.com
format
stringOptionalboth
输出格式:"both" | "llms-txt" | "llms-full-txt"
Example: both
complianceLevel
stringOptionalstandard
生成准则的合规级别:"basic" | "standard" | "strict"
Example: standard
analysisOptions
objectOptional-
网站分析选项(maxDepth 1-5、maxPages 10-500、respectRobots、detectAPIs、analyzeContent、checkSecurity)
Example: {"maxDepth": 3, "maxPages": 100, "detectAPIs": true}
outputOptions
objectOptional-
输出定制(organizationName、contactEmail、customGuidelines、customRestrictions、includeDetailed、includeAnalysis)
Example: {"organizationName": "Example Inc.", "contactEmail": "ai@example.com"}
respect_robots
booleanOptionaltrue
遵守目标站点的 robots.txt。保持 `true` 时,robots.txt 对 `CrawlForge` 禁止的路径会在抓取之前以 403 拒绝,且不扣除 credits。仅在你与目标站点另有约定时才设为 `false`——此时响应会带上一条 `warnings`,并且该覆盖会记录到你的 API key 上。`analysisOptions.respectRobots` 是别名;两者任一设为 `false` 都会关闭该检查。
Example: true

请求示例

cURL — 两种格式,标准合规

terminalBash
curl -X POST https://crawlforge.dev/api/v1/tools/generate_llms_txt \
  -H "X-API-Key: cf_test_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "format": "both",
    "complianceLevel": "standard",
    "outputOptions": {
      "organizationName": "Example Inc.",
      "contactEmail": "ai@example.com"
    }
  }'

TypeScript — 带自定义准则的严格模式

generateLlmsTxt.tsTypescript
const response = await fetch('https://crawlforge.dev/api/v1/tools/generate_llms_txt', {
  method: 'POST',
  headers: {
    'X-API-Key': process.env.CRAWLFORGE_API_KEY!,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://docs.example.com',
    format: 'both',
    complianceLevel: 'strict',
    analysisOptions: {
      maxDepth: 4,
      maxPages: 250,
      detectAPIs: true,
      analyzeContent: true,
    },
    outputOptions: {
      organizationName: 'Example Inc.',
      contactEmail: 'ai@example.com',
      customGuidelines: [
        'AI crawlers must respect robots.txt',
        'Cache responses for up to 24 hours',
      ],
      customRestrictions: [
        'No training on user-submitted content',
      ],
      includeAnalysis: true,
    },
  }),
});

const { data } = await response.json();
await fs.writeFile('public/llms.txt', data.files['llms.txt']);
await fs.writeFile('public/llms-full.txt', data.files['llms-full.txt']);

Python

generate_llms_txt.pyPython
import requests, os

response = requests.post(
    'https://crawlforge.dev/api/v1/tools/generate_llms_txt',
    headers={
        'X-API-Key': os.environ['CRAWLFORGE_API_KEY'],
        'Content-Type': 'application/json',
    },
    json={
        'url': 'https://example.com',
        'format': 'llms-txt',
        'complianceLevel': 'basic',
    },
)

data = response.json()['data']
with open('public/llms.txt', 'w') as f:
    f.write(data['files']['llms.txt'])

响应示例

200 OK4.1s
{
"success": true,
"data": {
"url": "https://example.com",
"llms_txt": "# Example Inc.\n\n> Tools for building things.\n\n## Docs\n\n- [Quickstart](https://example.com/docs/quickstart): Get started in five minutes\n",
"llms_full_txt": "# Example Inc.\n\n## Quickstart\n\nURL: https://example.com/docs/quickstart\n\nGet started in five minutes...",
"pages_analyzed": 12,
"pages": [
{
"url": "https://example.com",
"title": "Example Inc."
},
{
"url": "https://example.com/docs/quickstart",
"title": "Quickstart"
}
],
"compliance": {
"robots_txt_found": true,
"disallow_count": 3
},
"api_endpoints_detected": [
"https://example.com/api/v1"
],
"clamps_applied": [
"maxPages clamped from 100 to 25"
],
"generated_at": "2026-08-26T14:30:00.000Z"
},
"credits_used": 5,
"credits_remaining": 995,
"processing_time": 4100
}
Field Descriptions
data.llms_txt生成的 llms.txt。除非 `format` 设为 llms-full-txt,否则都会出现。
data.llms_full_txt内联了每个已分析页面正文的 llms.txt。仅当 `format` 为 both 或 llms-full-txt 时出现。
data.pages_analyzed根页面加上所有成功抓取的页面。
data.pages进入输出结果的页面,每个都附带标题。
data.compliance.robots_txt_found是否取得了 robots.txt;disallow_count 表示其中包含多少条 Disallow 规则。
data.api_endpoints_detected在已抓取 HTML 中识别出的至多 10 个疑似 API 的 URL。这是基于路径的启发式判断,并非经过验证的 API 清单。
data.clamps_applied当您请求的上限为适配无服务器预算而被下调时给出的可读说明。未发生下调时为空。
data.generated_at本次生成的 ISO 8601 时间戳。

错误处理

被 robots.txt 拦截(403 Forbidden)

目标站点的 robots.txt 对 CrawlForge 禁止了该路径。若你与目标站点另有约定,可设置 respect_robots: false 予以覆盖——该覆盖会记录到你的 API key 上。该覆盖不适用于列入 CrawlForge 永久排除名单的主机——无论 respect_robots 取何值,这类主机一律被拒绝。只有目标 URL 会返回 403:分析过程中发现的、被 robots.txt 禁止的页面会被排除在分析之外,并计入 warnings。

credit 费用

5 credits
每次请求 5 credits
无论爬虫访问多少页面,均固定 5 credits。

提示: 当你只需要在生成准则前获取 URL 清单时,可搭配 map_site(2 credits)使用。

相关工具

map_site
在生成 llms.txt 前发现 URL(2 credits)
crawl_deep
带内容提取的深度 BFS 爬取(4 credits)
准备好发布 AI 交互准则了吗?免费注册,获取 1,000 credits。

页脚

CrawlForge MCP

面向 AI Agent 的企业级网页抓取。29 个专业 MCP 工具,专为构建智能系统的现代开发者而设计。

产品

  • 功能
  • Playground
  • 价格
  • 应用场景
  • 集成
  • 替代方案
  • 更新日志

资源

  • 快速上手
  • API 参考
  • 模板
  • 指南
  • 博客
  • 术语表
  • 常见问题
  • 网站地图

开发者

  • MCP 协议
  • Claude Desktop
  • Cursor IDE
  • LangChain
  • LlamaIndex

公司

  • 关于我们
  • 联系我们
  • 隐私政策
  • 服务条款
  • 可接受使用政策
  • Cookie

保持更新

获取新工具和新功能的最新动态。

基于 Next.js 和 MCP 协议构建

© 2025-2026 CrawlForge。保留所有权利。