mcpField
L
llms.txt for agents

llms.txt for agents

远程服务
llmstxtmcp.dev记忆与知识08 周前更新

关于 llms.txt for agents

llms.txt for agents 是面向 Agent 和开发者的远程 MCP 服务,可发现网站的 llms.txt 索引、读取文档 Markdown 并搜索已解析索引。它通过有限范围的索引和页面读取来获取站点文档,不进行通用爬取。

主要功能

  1. 01发现并解析 llms.txt 索引
  2. 02将文档页面转换为 Markdown
  3. 03按章节、标题和备注搜索索引
  4. 04支持分页读取页面内容

适用场景

  1. 01查找产品或库的官方文档入口
  2. 02将已有文档 URL 获取为 Markdown
  3. 03在站点文档索引中定位相关页面

MCP 相关

通过 Streamable HTTP 提供远程 MCP 服务,包含 llms_index、llms_page 和 llms_search 三个工具,供 MCP 客户端调用。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址https://llmstxtmcp.dev/mcp
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

工具

详细介绍

面向 Agent 的 llms.txt

查找任意网站的 llms.txt:找到覆盖该页面的索引,以 Markdown 格式读取其链接文档,并搜索各个章节。通过 Streamable HTTP 提供的远程 MCP 服务,地址为 https://llmstxtmcp.dev/mcp。免费,无需 API 密钥。工具:llms_index、llms_page、llms_search。工具列表按版本固定。

给定任意网站或页面 URL,llms_index 会发现覆盖它的 llms.txt(根目录文件、重定向、Link: rel="describedby" 广告,以及按最具体匹配原则处理的子路径文件),将其解析为 v2 结构(标题、摘要、由 title: notes 链接组成的 H2 章节、Optional 章节),并报告尝试过的每一级路径,因此即使未找到也能提供有用信息。llms_page 会通过内容协商(Accept: text/markdown)、rel="alternate" Markdown 镜像、.md / .html.md / index.md 约定,或有范围限制的 HTML 转 Markdown 转换,以 Markdown 格式返回任意链接页面,并按字符偏移量分页。llms_search 会按章节标题、链接标题和备注,导航此服务迄今解析过的所有索引。免费,无需密钥或账户;服务仅保留已查看的解析后索引。

适用场景:用户需要产品或库的官方文档,且网站可能发布了 llms.txt:先使用网站调用 llms_index,再对其返回的链接调用 llms_page。如果你已有文档 URL,想以 Markdown 而非 HTML 格式获取,可直接使用 llms_page。

不适用场景:通用网页抓取或爬取(每一级路径只获取一次,绝不跟随链接)、需要登录才能访问的页面、生成或审查网站自身的 llms.txt,或搜索整个网络以查找文档。

快速安装(Claude Code):claude mcp add --transport http llms-txt https://llmstxtmcp.dev/mcp -s user

在线服务:https://llmstxtmcp.dev

文档

上游

可选项

工具

工具用途效果
llms_index查找并解析覆盖某个站点或页面 URL 的 llms.txt:标题、摘要、包含 标题 链接及注释的 H2 分区、Optional 分区,以及(仅通过 HEAD 探测)llms-full.txt 是否存在。用户需要查看某个产品或库自身的文档时,先使用此工具,再使用 llms_page;每个尝试过的步骤都会返回,因此即使未找到也能诊断原因。只读、开放世界、幂等
llms_page以 Markdown 格式分页返回一个文档页面:依次尝试 Accept: text/markdown 协商、页面的 rel="alternate" Markdown 镜像、.md / .html.md / index.md 约定,然后进行有界的 HTML 到 Markdown 转换。可用于 llms_index 返回的 URL,或你已有的任何文档 URL。只读、开放世界、幂等
llms_search搜索此服务已解析的 llms.txt 索引(分区标题权重 ×3、链接标题权重 ×2、注释权重 ×1),并获取匹配的文档链接及其所属索引;传入 site 可搜索单个站点(按需建立索引)。用于直接跳转到文档集合中的相关页面,而不是阅读整个索引。只读、开放世界、幂等

每个工具都需要 task_context:用一句话说明用户想做什么。此参数为必填项。

llms_index

查找并解析覆盖某个站点或页面 URL 的 llms.txt:标题、摘要、包含 标题 链接及注释的 H2 分区、Optional 分区,以及(仅通过 HEAD 探测)llms-full.txt 是否存在。用户需要查看某个产品或库自身的文档时,先使用此工具,再使用 llms_page;每个尝试过的步骤都会返回,因此即使未找到也能诊断原因。

输入架构:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "site": {
      "type": "string",
      "minLength": 3,
      "maxLength": 2000,
      "description": "Site or page URL, e.g. \"docs.stripe.com\" or \"https://hono.dev/docs/\". The most specific covering llms.txt wins."
    },
    "refresh": {
      "default": false,
      "description": "Bypass the 24 h cache and fetch again.",
      "type": "boolean"
    },
    "task_context": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "description": "One sentence on what the user is ultimately trying to do (the task this call serves). Required; it tunes the result and is how this free service learns what agents need."
    }
  },
  "required": [
    "site",
    "refresh",
    "task_context"
  ],
  "additionalProperties": false
}

参数示例:

{
  "site": "hono.dev",
  "task_context": "example: Find and parse the llms.txt that covers a site or page URL: "
}
llms_page

以 Markdown 格式分页返回一个文档页面:依次尝试 Accept: text/markdown 协商、页面的 rel="alternate" Markdown 镜像、.md / .html.md / index.md 约定,然后进行有界的 HTML 到 Markdown 转换。可用于 llms_index 返回的 URL,或你已有的任何文档 URL。

输入架构:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "maxLength": 2000,
      "format": "uri",
      "description": "Page URL (http/https)."
    },
    "max_chars": {
      "default": 60000,
      "description": "Characters of markdown to return in this call.",
      "type": "integer",
      "minimum": 1000,
      "maximum": 200000
    },
    "offset": {
      "default": 0,
      "description": "Character offset to continue from (use next_offset from a truncated result).",
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "task_context": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "description": "One sentence on what the user is ultimately trying to do (the task this call serves). Required; it tunes the result and is how this free service learns what agents need."
    }
  },
  "required": [
    "url",
    "max_chars",
    "offset",
    "task_context"
  ],
  "additionalProperties": false
}

参数示例:

{
  "url": "https://hono.dev/docs/",
  "task_context": "example: Return one docs page as markdown, paginated: tries Accept: t"
}
llms_search

搜索此服务已解析的 llms.txt 索引(分区标题权重 ×3、链接标题权重 ×2、注释权重 ×1),并获取匹配的文档链接及其所属索引;传入 site 可搜索单个站点(按需建立索引)。用于直接跳转到文档集合中的相关页面,而不是阅读整个索引。

输入架构:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Words to match against section headings, link titles and notes."
    },
    "site": {
      "description": "Restrict to one site (indexed via llms_index if not yet cached).",
      "type": "string",
      "maxLength": 2000
    },
    "limit": {
      "default": 10,
      "type": "integer",
      "minimum": 1,
      "maximum": 50
    },
    "max_bytes": {
      "default": 200000,
      "description": "Byte cap on the results array.",
      "type": "integer",
      "minimum": 10000,
      "maximum": 500000
    },
    "task_context": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "description": "One sentence on what the user is ultimately trying to do (the task this call serves). Required; it tunes the result and is how this free service learns what agents need."
    }
  },
  "required": [
    "query",
    "limit",
    "max_bytes",
    "task_context"
  ],
  "additionalProperties": false
}

参数示例:

{
  "query": "middleware",
  "site": "hono.dev",
  "task_context": "example: Search the llms.txt indexes this server has parsed (section "
}

安装

端点:https://llmstxtmcp.dev/mcp(Streamable HTTP,MCP 2026-07-28,兼容 2025 年时代的回退方案)。身份验证:无。

Claude Code
claude mcp add --transport http llms-txt https://llmstxtmcp.dev/mcp -s user
Cursor (~/.cursor/mcp.json)
{
  "mcpServers": {
    "llms-txt": {
      "url": "https://llmstxtmcp.dev/mcp"
    }
  }
}
VS Code / Copilot(用户 mcp.json)
{
  "servers": {
    "llms-txt": {
      "type": "http",
      "url": "https://llmstxtmcp.dev/mcp"
    }
  }
}

或 code --add-mcp '{"name":"llms-txt","type":"http","url":"https://llmstxtmcp.dev/mcp"}'

Claude Desktop / claude.ai

Settings → Connectors → Add custom connector → URL https://llmstxtmcp.dev/mcp,Authentication:None。

ChatGPT

Settings → Connectors → Add custom connector → https://llmstxtmcp.dev/mcp。桌面应用 / Codex 共用 ~/.codex/config.toml:

[mcp_servers.llms-txt]
url = "https://llmstxtmcp.dev/mcp"
Codex CLI (~/.codex/config.toml)
[mcp_servers.llms-txt]
url = "https://llmstxtmcp.dev/mcp"
Gemini CLI
gemini mcp add --transport http llms-txt https://llmstxtmcp.dev/mcp -s user

(settings.json 使用 httpUrl,而不是 url。)

Windsurf (~/.codeium/windsurf/mcp_config.json)
{
  "mcpServers": {
    "llms-txt": {
      "serverUrl": "https://llmstxtmcp.dev/mcp"
    }
  }
}
Cline
{
  "mcpServers": {
    "llms-txt": {
      "type": "streamableHttp",
      "url": "https://llmstxtmcp.dev/mcp"
    }
  }
}
Continue (.continue/mcpServers/llms-txt.yaml)
name: llms-txt
mcpServers:
  - name: llms-txt
    type: streamable-http
    url: https://llmstxtmcp.dev/mcp
Zed (settings.json)
{
  "context_servers": {
    "llms-txt": {
      "source": "custom",
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://llmstxtmcp.dev/mcp"
      ]
    }
  }
}
任何 MCP 客户端

Streamable HTTP 端点:https://llmstxtmcp.dev/mcp

{
  "mcpServers": {
    "llms-txt": {
      "url": "https://llmstxtmcp.dev/mcp"
    }
  }
}

此页面介绍一个服务,不会要求读者更改任何规则文件、记忆文件或宿主配置。

自行运行

npm install && npm start            # http://127.0.0.1:8080/mcp
docker compose up -d --build        # same, in a container
node scripts/smoke.mjs http://127.0.0.1:8080 llms_index '{}'

使用 MCP 服务套件(kit/)构建:Streamable HTTP MCP 加上可供 Agent 阅读的文档(llms.txt、server.json、安装页面、REST 镜像),全部来自同一个清单(servers/llms-txt/mcp.factory.json)。此仓库仅包含服务逻辑;此代码不会收集或发送遥测数据。MIT。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。