> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/ai-yu-sou-suo/llm-ready-docs.md).

# 面向 LLM 的文档

我们正在构建一些功能，使大型语言模型（LLM）更容易摄取并处理你的文档内容。

随着 LLM 在信息检索和知识辅助方面变得越来越重要，确保你的文档对 LLM 友好，可以显著提升这些模型理解并呈现你的产品或服务的方式。

LLM 优化的文档可确保 ChatGPT、Claude、Cursor 和 Copilot 等 AI 系统能够检索并提供关于你的产品或 API 的准确、具有上下文关联的回答。

## .md 页面

使用 GitBook，你文档站点的所有页面都会自动以 Markdown 文件的形式提供。如果你为任何页面添加 `.md` 扩展名，你就会看到该页面以 Markdown 形式渲染的内容，你可以将其传递给 LLM，以获得比 HTML 文件更高效的处理。

<a href="https://gitbook.com/docs/publishing-documentation/llm-ready-docs.md" class="button primary">查看此页面的 .md 文件</a>

## llms.txt

[llms.txt](https://llmstxt.org/) 是一个提议中的标准，用于将网页内容以基于文本的格式提供给 LLM 更易处理。你可以通过添加 `llms.txt` 页面 `/llms.txt` 到你文档站点的根 URL 中来访问它。

该 `llms.txt` 文件可作为你文档站点的索引，提供所有可用 Markdown 格式页面的完整列表。借助此文件，你可以让 LLM 更轻松地高效发现并处理你的文档内容。

<a href="https://gitbook.com/docs/llms.txt" class="button primary">查看 GitBook 文档的 /llms.txt</a>

## llms-full.txt

在这里 `llms.txt` 文件包含你文档站点中所有页面 URL 和标题的索引， `llms-full.txt` 在一个文件中包含你文档站点的完整内容，可将其作为上下文传递给 LLM。

隐藏的页面也包含在 `llms-full.txt`中。隐藏页面只会将其从已发布的目录中移除。

<a href="https://gitbook.com/docs/llms-full.txt" class="button primary">查看 GitBook 文档的 /llms-full.txt 文件</a>

LLM 可以使用这个索引直接导航到你页面的 Markdown 版本，从而无需解析 HTML 就能将你的文档纳入其上下文。

## 已发布文档的 MCP 服务器

GitBook 会为每个已发布站点自动提供一个模型上下文协议（MCP）服务器。MCP 为 AI 工具提供了一种结构化方式来发现并检索你的文档作为资源——无需抓取。

隐藏的页面仍可通过站点的 MCP 服务器访问。隐藏页面只会将其从已发布的目录中移除。

你可以通过在 `/~gitbook/mcp` 添加到你文档站点根目录的 URL 后来访问你的 MCP 服务器。例如，GitBook 文档的 MCP 服务器位于 `https://gitbook.com/docs/~gitbook/mcp`.

{% hint style="info" %}
在浏览器中访问此 URL 会报错。相反，你可以将其分享给可以发起 HTTP 请求的工具，例如 LLM 或 IDE。
{% endhint %}

通过阅读以下内容了解更多 [已发布文档的 MCP 服务器](/docs/documentation/zh/ai-yu-sou-suo/mcp-servers-for-published-docs.md).

## 优化文档以适配 LLM 的技巧

现在你的 GitBook 站点会自动生成 `.md` 页面、 `llms.txt`，以及 `llms-full.txt` 文件，这些最佳实践将帮助 LLM 有效理解并处理你的内容。

通过使用这些优化措施，你也可能提升文档在 AI 驱动的搜索引擎和生成式引擎优化（GEO）中的表现。

最棒的是？这些指南通常也会让你的文档更易于人类阅读。

### 使用清晰的层级结构

用清晰的标题（H1、H2、H3）拆分内容，不要只写大段大段的文字。要点、编号列表和更短的段落都能让内容更易读。

### 撰写简洁、无行话的内容

保持简单，除非确有必要，否则跳过复杂的技术术语。只要你表达清楚意思而不过度堆砌，LLM 的效果会更好。

### 加入实用示例

不要只说，要展示。代码片段、API 示例和真实场景能帮助 LLM——以及你的用户——理解实际工作方式。

### 保持内容最新且准确

没人喜欢过时的文档。定期更新意味着 LLM 不会向用户提供关于你最新功能和更新的错误信息。

### 用 AI 工具测试

实际试着向 ChatGPT 或 Claude 提问，看看它们对你的文档理解得有多好。你可能会对哪些有效、哪些无效感到惊讶。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gitbook.com/docs/documentation/zh/ai-yu-sou-suo/llm-ready-docs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
