> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raydium.io/llms.txt
> Use this file to discover all available pages before exploring further.

# AI 集成

> 将 Raydium 文档接入你的编码 AI 或 LLM 工作流 — MCP 服务器、llms.txt 索引、逐页复制以及预构建的上下文文件。

<Info>
  **本页内容由 AI 自动翻译，所有内容以英文版本为准。**

  [查看英文版 →](/sdk-api/ai-integration)
</Info>

<Info>
  这些文档既为人类设计，也为 AI 工具设计。如果你在构建编码 AI（Claude Code、Cursor、Windsurf、Continue 等）或在文档上运行 RAG，下面的接口可以让你直接接入 Raydium 文档，无需自定义爬虫。
</Info>

## 可用的接口

| 接口                     | URL 模式                                                                       | 使用场景                                                           |
| ---------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------- |
| **MCP 服务器**            | `https://docs.raydium.io/mcp`                                                | 你希望 AI 编辑器（Claude Code、Cursor、Windsurf 等）能够原生查询并引用 Raydium 文档。 |
| **`llms.txt` 索引**      | `https://docs.raydium.io/llms.txt`                                           | 你在构建 RAG 管道，需要每个页面的扁平索引。                                       |
| **`llms-full.txt` 内容** | `https://docs.raydium.io/llms-full.txt`                                      | 你需要完整的文档集合作为单个连接的文件，用于离线索引。                                    |
| **逐页复制菜单**             | 每个内容页顶部的「复制页面」按钮                                                             | 你要将一个页面粘贴到与 LLM 的对话中。                                          |
| **逐页深层链接**             | `查看为 Markdown`、`在 ChatGPT 中打开`、`在 Claude 中打开`、`在 Cursor 中打开`、`在 VS Code 中打开` | 从文档页面一键切换到你选择的工具。                                              |

「复制页面」按钮和深层链接菜单位于每个页面的右上角（页面标题旁边）。两者都由文档平台的上下文菜单支持。

## MCP 服务器

MCP（模型上下文协议）服务器允许 AI 客户端将 Raydium 文档作为工具进行查询。配置完成后，你的 AI 可以询问「在 Raydium 文档中搜索 `addLiquidity` 参数」，并获得引用的权威答案。

### Claude Code

```bash theme={null}
claude mcp add --transport http raydium-docs https://docs.raydium.io/mcp
```

添加后，要求 Claude Code「在 Raydium 文档中搜索 X」，它将使用该工具。

### Cursor

添加到你的 Cursor 设置（`Cmd/Ctrl + ,` → MCP）：

```json theme={null}
{
  "mcpServers": {
    "raydium-docs": {
      "url": "https://docs.raydium.io/mcp"
    }
  }
}
```

### Windsurf、Continue、通用客户端

任何与 MCP 兼容的客户端都可以指向 `https://docs.raydium.io/mcp`。如果你的客户端需要清单文件，它位于 `https://docs.raydium.io/mcp/.well-known/mcp.json`。

### 服务器暴露的功能

Raydium 文档 MCP 服务器暴露一个主要工具 `search_docs(query: string)`，它返回查询的最高排名段落及其规范 URL。AI 负责引用它使用的 URL；我们不进行按 AI 的追踪或速率限制。

## 用于 RAG 的 `llms.txt`

`llms.txt` 是一个新兴的「机器可读文档索引」标准。Raydium 提供：

* `https://docs.raydium.io/llms.txt` — 每个页面的扁平列表，包括标题和一行摘要，按章节组织。
* `https://docs.raydium.io/llms-full.txt` — 每个页面的完整 Markdown 内容，连接在一起，页面边界以标题形式保留。

`full` 版本在每次文档部署时重新生成。定期拉取（每天一次足够）或按需获取。

```bash theme={null}
# 将完整的文档集合放入你的 RAG 摄取管道。
curl -sSL https://docs.raydium.io/llms-full.txt -o raydium-docs.md
```

## 逐页切换菜单

每个内容页都有一个上下文菜单（右上角，标题旁边），包含以下一键操作：

* **复制** — 将页面作为纯 Markdown 复制。
* **查看为 Markdown** — 在新标签页中打开源 `.md` 文件，以便保存。
* **在 ChatGPT / Claude / Perplexity 中打开** — 将页面内容预加载到指定工具的聊天提示中。
* **在 Cursor / VS Code 中打开** — 在指定编辑器中打开包含页面内容的缓冲区。

当你想在不设置 MCP 的情况下向模型提出关于单个页面的问题时，这是合适的接口。

## 为编码 AI 预构建的上下文文件

如果你在集成 Raydium 并希望 AI 从一开始就拥有正确的基础知识，将这些文件放入你的项目：

### `.cursorrules` / `.windsurfrules` / AI 系统提示

```text theme={null}
You are integrating with Raydium, a Solana DeFi protocol with five product
surfaces: AMM v4, CPMM, CLMM, Farm, and LaunchLab. Authoritative docs live
at docs.raydium.io. The official SDK is `@raydium-io/raydium-sdk-v2` (pin
the version you've verified against). For server-built swaps, prefer the
Trade API at transaction-v1.raydium.io. Always:

- Pass a `Connection` and `cluster` that match.
- Keep all amounts as `BN` instances; never call `.toNumber()` on amounts.
- Pre-fund the user's wallet for ATA creation rent.
- Pass an explicit `computeBudgetConfig` for any tx that may compete in
  high-volume windows.
- Re-fetch `poolInfo` immediately before high-value transactions; cached
  state goes stale.

When uncertain about an instruction's accounts list, defer to
`docs.raydium.io/products/<product>/accounts` and the on-chain IDL.
```

另存为 `.cursorrules`（Cursor）、`.windsurfrules`（Windsurf）或 `CLAUDE.md`（Claude Code），或粘贴到你的 AI 系统提示中。具体的文件名和位置因工具版本而异，如果自动选取失败，请检查你的工具设置文档。

### 固定上下文列表

对于接受「始终包含」页面列表的编码 AI，此列表是大多数 Raydium 集成所需的最小有用上下文：

```text theme={null}
https://docs.raydium.io/sdk-api/typescript-sdk
https://docs.raydium.io/sdk-api/trade-api
https://docs.raydium.io/products/cpmm/instructions
https://docs.raydium.io/products/clmm/instructions
https://docs.raydium.io/integration-guides/priority-fee-tuning
https://docs.raydium.io/reference/program-addresses
https://docs.raydium.io/reference/error-codes
```

根据你集成的产品进行调整。

## 索引配方

如果你在构建自己的 RAG 并不想使用 `llms-full.txt`，这是规范的配方：

```ts theme={null}
import { fetch } from "undici";

const INDEX_URL = "https://docs.raydium.io/llms.txt";
const BASE      = "https://docs.raydium.io";

const index    = await (await fetch(INDEX_URL)).text();
const pageUrls = [...index.matchAll(/^- \[(.+?)\]\((.+?)\)/gm)].map(m => m[2]);

for (const path of pageUrls) {
  const md = await (await fetch(`${BASE}${path}.md`)).text();
  // ingest md into your vector store, keyed by path
}
```

每个页面都在其规范路径上提供，附加 `.md` 后缀（例如 `/sdk-api/typescript-sdk` → `/sdk-api/typescript-sdk.md`）。

## 注意事项

* **不要将私密状态粘贴到提示中。** MCP 服务器只了解公开文档中的内容。钱包密钥、RPC 凭证和类似的密钥不应进入 AI 上下文。
* **AI 输出不是权威的。** 模型有些轻率地幻觉程序地址、指令名称和账户列表。在信任 AI 生成的交易之前，始终针对文档和 IDL 进行验证。
* **版本漂移。** SDK v2 是 pre-1.0；在较旧版本上训练的 AI 可能会生成针对你的固定版本无法编译的代码。在 AI 的系统提示中包含固定的 SDK 版本。

## 相关资源

* [`sdk-api/typescript-sdk`](/zh/sdk-api/typescript-sdk) — 主要的 SDK 参考。
* [`sdk-api/trade-api`](/zh/sdk-api/trade-api) — 服务器构建的交换交易，适合对 AI 友好的集成。
* [`reference/program-addresses`](/zh/reference/program-addresses) — 已验证的程序 ID。
* [Model Context Protocol](https://modelcontextprotocol.io) — 上游 MCP 规范。
* [`llms.txt` 提案](https://llmstxt.org) — 关于索引标准的背景。

来源：

* [Mintlify MCP 和 llms.txt 支持](https://mintlify.com/docs/ai/llms)。
* Raydium 文档部署。
