> ## 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 文件整合到你的編碼代理或 LLM 工作流中 — MCP 伺服器、llms.txt 索引、逐頁複製，以及預先構建的上下文檔案。

<Info>
  **本頁內容由 AI 自動翻譯，所有內容以英文版本為準。**

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

<Info>
  這份文件不僅供人類閱讀，也設計供 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 文件視為工具進行查詢。配置後，你的代理可以詢問「在 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。代理負責引用它使用的 URL；我們不跟蹤或按代理進行速率限制。

## 用於 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 時，這是正確的服務。

## 為編碼代理預先構建的上下文檔案

如果你正在整合 Raydium，並希望代理從一開始就具有正確的基線知識，請將這些檔案放入你的項目中：

### `.cursorrules` / `.windsurfrules` / 代理系統提示

```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）— 或粘貼到代理的系統提示中。確切的檔案名稱和位置因工具版本而異，如果工具未自動拾取該檔案，請檢查工具的設定文件。

### 固定上下文列表

對於接受「始終包含」頁面列表的編碼代理，此列表是大多數 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 輸出不是權威的。** 模型在幻覺程序位址、指令名稱和帳戶列表方面驚人地容易出錯。在信任代理生成的交易前，始終根據文件和 IDL 進行驗證。
* **版本偏移。** SDK v2 預發佈 1.0；根據較舊版本訓練的代理可能會發出無法針對你固定版本編譯的代碼。在代理的系統提示中包含固定的 SDK 版本。

## 參考資料

* [`sdk-api/typescript-sdk`](/zh-Hant/sdk-api/typescript-sdk) — 主要 SDK 參考。
* [`sdk-api/trade-api`](/zh-Hant/sdk-api/trade-api) — 伺服器構建的交換交易，非常適合代理友好的整合。
* [`reference/program-addresses`](/zh-Hant/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 文件部署。
