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

# 面向编码智能体的 Bright Data

> 用三条命令在 Claude Code、Cursor 或 Codex 中获取 Bright Data Scraper API 的结构化数据，并了解 llms.txt、智能体技能、CLI 与 MCP。

在 Claude Code、Cursor 或 Codex 中直接获取 Bright Data Scraper API 的结构化数据。把下面这段粘贴进去：

<Prompt description="Read https://docs.brightdata.com/llms.txt, then use the Bright Data Scraper API to scrape https://www.amazon.com/dp/B0FQFB8FMG and show me the title, price and rating." icon="sparkles" actions={["copy"]}>
  Read [https://docs.brightdata.com/llms.txt](https://docs.brightdata.com/llms.txt), then use the Bright Data Scraper API to scrape [https://www.amazon.com/dp/B0FQFB8FMG](https://www.amazon.com/dp/B0FQFB8FMG) and show me the title, price and rating.
</Prompt>

智能体会读取文档索引，安装所需内容并返回记录。若要自己运行同样的流程，或查看它安装了什么，请从下面开始。

## 获取第一个 Scraper API 结果

两条命令即可从 Bright Data Scraper API 获得结构化 JSON。结果与[面向开发者的快速开始](/cn/quickstart)相同，只是在终端中完成。

<Steps>
  <Step title="安装并进行身份验证">
    ```bash theme={null}
    npm i -g @brightdata/cli
    bdata login
    ```

    `bdata login` 会打开浏览器进行授权，因此您无需粘贴密钥。在 SSH 或任何无图形界面的环境中，请使用 `bdata login --device`。

    如果您的机器禁止全局安装，请改用 `npx` 运行每条命令：

    ```bash theme={null}
    npx -p @brightdata/cli bdata login
    ```

    请保留 `-p @brightdata/cli` 部分。`npx` 不会把 `bdata` 放入 PATH，因此每条命令都需要该前缀；而简写的 `npx bdata` 会解析到 npm 上另一个无关的包，而非 Bright Data CLI。
  </Step>

  <Step title="抓取一个页面">
    ```bash theme={null}
    bdata pipelines amazon_product "https://www.amazon.com/dp/B0FQFB8FMG" --pretty
    ```

    您应当看到打印出的商品 JSON。这需要 10 到 30 秒。

    ```json theme={null}
    [
      {
        "title": "Apple AirPods Pro 3 Wireless Earbuds with Active Noise Cancellation",
        "asin": "B0FQFB8FMG",
        "brand": "Apple",
        "final_price": 199.99,
        "currency": "USD",
        "rating": 4.4,
        "reviews_count": 14411
      }
    ]
    ```

    完整记录包含 67 个字段。运行 `bdata pipelines list` 可查看所有可用的 pipeline 类型。
  </Step>
</Steps>

安装[智能体技能](#如何安装-bright-data-技能)后，智能体会自行调用这些命令：

```bash theme={null}
npx skills add brightdata/skills
```

然后用自然语言提问，而不必输入 CLI 命令：

```text Prompt theme={null}
Scrape https://www.amazon.com/dp/B0FQFB8FMG and tell me the price and rating.
```

## 如何抓取其他网站

更换 pipeline 类型即可。CLI 以每个 pipeline 采集的内容命名，因此不需要查找 `dataset_id`。

```bash theme={null}
bdata pipelines linkedin_person_profile "https://www.linkedin.com/in/satyanadella" --pretty
```

| 网站                         | Pipeline 类型                                                                  |
| :------------------------- | :--------------------------------------------------------------------------- |
| 亚马逊                        | `amazon_product`、`amazon_product_reviews`、`amazon_product_search`            |
| LinkedIn                   | `linkedin_person_profile`、`linkedin_company_profile`、`linkedin_job_listings` |
| Instagram                  | `instagram_profiles`、`instagram_posts`、`instagram_reels`                     |
| TikTok                     | `tiktok_profiles`、`tiktok_posts`、`tiktok_shop`                               |
| YouTube                    | `youtube_videos`、`youtube_profiles`、`youtube_comments`                       |
| Walmart、eBay、Etsy、Best Buy | `walmart_product`、`ebay_product`、`etsy_products`、`bestbuy_products`          |

查看当前完整集合：

```bash theme={null}
bdata pipelines list
```

搜索引擎不属于 pipeline。Google、Bing 和 Yandex 结果请使用 `bdata search`，没有预构建抓取器的页面请使用 `bdata scrape`。

安装技能后，您无需自己选择类型。只需说明想要的数据，智能体会把网站匹配到对应的 pipeline：

```text Prompt theme={null}
Get me the follower count and recent posts for the Bright Data LinkedIn company page.
```

## 智能体会配置些什么

| 它为智能体提供什么                           | 方式                                              | 配置成本    |
| :---------------------------------- | :---------------------------------------------- | :------ |
| 了解该使用哪个 Bright Data 产品，以及各 API 如何工作 | [llms.txt](#如何让智能体读到全部文档)                       | 提示词中的一行 |
| 通过 Bright Data CLI 执行搜索、抓取和结构化提取    | [智能体技能](#如何安装-bright-data-技能)                   | 一条命令    |
| 在智能体的工具循环中实时调用 60+ 个网页工具            | [Bright Data MCP](#如何连接-bright-data-mcp-server) | 一条命令    |
| 在终端中驱动抓取器、zone 和远程浏览器               | [Bright Data CLI](/cn/products/cli/overview)    | 一条命令    |

它们不是互相替代的方案。参见[如何搭配使用](#技能-mcp-还是两者都用)。

## 前提条件

* 一个 [Bright Data 账户](https://www.bright.cn/?hs_signup=1\&utm_source=docs)。新账户每月获得 **5,000 个免费信用额度**，无需信用卡
* 一个具备终端访问能力的编码智能体：Claude Code、Cursor、Codex，或技能生态支持的 40+ 个智能体中的任意一个

## 如何让智能体读到全部文档

把智能体指向 `llms.txt`，这是按照 [llms.txt 标准](https://llmstxt.org)组织的 Bright Data 全部文档页面索引。每个条目都链接到页面的 `.md` 版本，因此智能体读到的是干净的 markdown，无需解析 HTML。

```text Prompt theme={null}
Read https://docs.brightdata.com/llms.txt to understand the available Bright Data
products, then help me choose the right API for scraping Amazon product pages.
```

若不想每次提示都写一遍，可以把索引保存到项目中，让每个会话都能读到：

<CodeGroup>
  ```bash Claude Code theme={null}
  mkdir -p .claude && curl -o .claude/brightdata-docs.txt https://docs.brightdata.com/llms.txt
  ```

  ```bash Cursor theme={null}
  mkdir -p .cursor/rules && curl -o .cursor/rules/brightdata.md https://docs.brightdata.com/llms.txt
  ```

  ```bash Codex theme={null}
  curl -s https://docs.brightdata.com/llms.txt >> AGENTS.md
  ```
</CodeGroup>

共发布两个文件。`llms.txt` 是索引，适合作为实时智能体会话的默认选择。`llms-full.txt` 是全部文档合并成的单个文件，面向 RAG 管道和长上下文注入，而非交互式使用。

<Tip>
  面向智能体的高效用法：先加载 `llms.txt` 了解有哪些内容，找到相关页面，再获取该页面的 `.md` URL 查看细节。在任意文档 URL 后追加 `.md` 即可得到 markdown，例如 [`/cn/products/mcp-server/overview.md`](/cn/products/mcp-server/overview.md)。
</Tip>

希望智能体实时查询文档而不是加载文件？[Docs MCP](/cn/general/docs-mcp) 将本文档以可搜索的 MCP 资源形式暴露，智能体可在自身推理循环中检索页面。它与下文的 Bright Data MCP 是两个不同的服务：Docs MCP 读取文档，Bright Data MCP 访问实时网络。

在搭建检索管道而非实时智能体会话？请使用 `llms-full.txt`，即以单个 markdown 文件形式提供的完整文档：

```python theme={null}
import httpx
from langchain.text_splitter import MarkdownTextSplitter

docs = httpx.get("https://docs.brightdata.com/llms-full.txt").text
chunks = MarkdownTextSplitter(chunk_size=1000, chunk_overlap=100).create_documents([docs])
vectorstore.add_documents(chunks)
```

<Warning>
  `llms-full.txt` 体积很大。对于实时智能体会话，请先加载 `llms.txt`，再按需获取单个 `.md` 页面，这样消耗的 token 少得多。
</Warning>

## 如何安装 Bright Data 技能

技能是定义在 `SKILL.md` 文件中的可复用指令集，为智能体内置 Bright Data API 知识以及通过 Bright Data CLI 执行操作的命令。一条命令即可安装，并自动检测您已安装的智能体：

```bash theme={null}
npx skills add brightdata/skills
```

技能直接调用 `bdata`，因此[第一步](#获取第一个-scraper-api-结果)中的全局安装是它们能够工作的前提。如果 `bdata` 不在 PATH 中，技能的 `command -v bdata` 检查会失败。

确认安装成功：

```bash theme={null}
npx skills list
```

每个已安装的技能都会单独占一行，显示其路径以及被链接到的智能体：

```text theme={null}
Project Skills

search ./.agents/skills/search Agents: Codex, Cursor
```

列表为空说明安装未生效。请重新运行 `npx skills add brightdata/skills` 并回答作用域提示。

该技能包涵盖搜索、抓取、结构化提取、SDK、代理、Scraper Studio 与 MCP 编排。您最先会用到的是：

| 技能              | 它为智能体提供什么                                                        |
| :-------------- | :--------------------------------------------------------------- |
| Search          | 以结构化 JSON 返回 Google、Bing 和 Yandex 结果。运行在 SERP API 上              |
| Scrape          | 将任意网页转为干净的 markdown，含验证码求解与 JavaScript 渲染。运行在 Web Unlocker API 上 |
| Data Feeds      | 从亚马逊、LinkedIn、Instagram、TikTok、YouTube 等站点进行结构化提取                |
| Scraper Studio  | 为没有预构建抓取器的网站构建自定义抓取器                                             |
| Bright Data MCP | 在一个集成中编排 MCP 工具                                                  |
| Best Practices  | API 选型指南、身份验证模式以及 Python 和 JavaScript 代码示例                       |

运行 `npx skills add brightdata/skills --list` 查看当前完整集合。

安装完成后，智能体会直接调用它们：

```bash theme={null}
bdata search "your query" --engine google --json --pretty
bdata scrape "https://example.com"
bdata pipelines amazon_product "https://www.amazon.com/dp/B0FQFB8FMG" --pretty
```

### 安装到指定的智能体

<Tabs>
  <Tab title="Claude Code">
    ```bash theme={null}
    npx skills add brightdata/skills -a claude-code
    ```

    技能会安装到项目中的 `.claude/skills/`，加上 `-g` 则安装到 `~/.claude/skills/`。Claude Code 会在下一个会话中发现它们。可用 `npx skills list -a claude-code` 验证。
  </Tab>

  <Tab title="Cursor">
    ```bash theme={null}
    npx skills add brightdata/skills -a cursor
    ```

    技能会安装到 `.cursor/skills/`。Cursor Composer 会自动识别。可在聊天中引用其中一个：`Use the scrape skill to extract content from https://example.com`。
  </Tab>

  <Tab title="Codex">
    ```bash theme={null}
    npx skills add brightdata/skills -a codex
    ```

    技能会安装到 `.agents/skills/`，这是 Codex 与 `AGENTS.md` 一并读取的共享位置。
  </Tab>

  <Tab title="一次安装到所有智能体">
    ```bash theme={null}
    npx skills add brightdata/skills --all

    # 非交互式，适用于 CI
    npx skills add brightdata/skills --all -y
    ```

    CLI 会自动检测您已安装的每个智能体，并把文件分发到各处。
  </Tab>

  <Tab title="其他任意智能体">
    每个技能都是纯 markdown，因此您可以把它注入任何系统提示词或 RAG 索引：

    ```bash theme={null}
    git clone https://github.com/brightdata/skills.git
    cat skills/bright-data-best-practices/SKILL.md
    ```
  </Tab>
</Tabs>

在任意命令后加上 `-g` 即可跨项目全局安装。

### 管理已安装的技能

```bash theme={null}
npx skills list      # 已安装了什么
npx skills check     # 是否有更新
npx skills update    # 更新到最新版本
npx skills remove brightdata/skills
```

技能属于[开放智能体技能生态](https://github.com/vercel-labs/skills)，可在 40+ 个编码智能体中使用。源代码，包括每个 `SKILL.md` 及其可运行脚本，位于 [github.com/brightdata/skills](https://github.com/brightdata/skills)。新技能会持续加入，欢迎 star 该仓库以便关注。

## 如何连接 Bright Data MCP Server

Bright Data MCP Server 通过 60+ 个用于搜索、抓取、结构化提取和浏览器自动化的工具，为智能体提供实时网页访问能力。它运行在 Web Unlocker API 上，因此每个请求都会处理代理轮换、反机器人挑战和验证码求解。

下面的每段配置都会把 API 密钥写入智能体的配置文件。这类文件常被提交到版本控制中，因此请像对待其他机密一样对待该密钥。若想完全避免在文件中留存长期密钥，该服务器也支持 [OAuth 2.1](/cn/products/mcp-server/remote/oauth)，由用户在浏览器中登录。

<CodeGroup>
  ```bash Claude Code theme={null}
  claude mcp add --transport sse brightdata "https://mcp.brightdata.com/sse?token=YOUR_API_KEY"
  ```

  ```json Cursor theme={null}
  {
    "mcpServers": {
      "brightdata-mcp": {
        "command": "npx",
        "args": ["-y", "@brightdata/mcp"],
        "env": {
          "API_TOKEN": "YOUR_API_KEY"
        }
      }
    }
  }
  ```

  ```bash Codex CLI theme={null}
  codex mcp add brightdata --env API_TOKEN=YOUR_API_KEY -- npx -y @brightdata/mcp
  ```
</CodeGroup>

然后用类似 `Extract the Bright Data overview section from LinkedIn` 的提示词试一下。

<Tip>
  **控制 token 用量。** 使用[工具分组](/cn/products/mcp-server/tools)只加载需要的工具，例如 `groups=ecommerce,social`，或直接指定单个工具，例如 `tools=web_data_amazon_product`。工具列表越小，上下文越小，可用请求越多。
</Tip>

它有两个版本。[远程服务器](/cn/products/mcp-server/remote/quickstart)完全托管，无需任何配置。[本地服务器](/cn/products/mcp-server/local/quickstart)可自托管，适用于本地部署或私有云。两者的说明参见 [MCP Server 概览](/cn/products/mcp-server/overview)，其他客户端参见[集成指南](/cn/products/mcp-server/integrations/overview)。

## 技能 MCP 还是两者都用

技能加 CLI 是默认组合。技能承载知识：哪个 Bright Data 产品适合当前任务、如何进行身份验证、如何处理分页和错误。CLI 负责执行。在智能体真正运行命令之前，两者都不会产生实时请求。

当智能体没有终端时，MCP Server 才是关键。它把同样的能力以工具形式暴露在智能体自身的循环中，这是托管助手或无法调用 shell 的客户端唯一可行的路径。

本页把终端访问列为前提条件，因此这里的 MCP 是可选项。当您希望在工具循环中而不是通过 shell 获得实时网页访问时，再加上它。

## 常见问题

<AccordionGroup>
  <Accordion title="我需要全局安装任何东西吗？">
    不需要。`npx skills add brightdata/skills` 和 `npx -y @brightdata/mcp` 都是按需获取的，因此没有需要维护的全局依赖。Bright Data CLI 也可以通过 npx 运行：`npx -p @brightdata/cli brightdata --version`。
  </Accordion>

  <Accordion title="MCP Server 使用同一个免费套餐吗？">
    是的。MCP Server 运行在 Web Unlocker API 上，因此从账户级[免费套餐](/cn/general/account/billing-and-pricing/free-tier)的每月 5,000 个信用额度中扣除，且来自同一个共享额度池。在团队账户中，该额度池由账户内所有用户共享。
  </Accordion>

  <Accordion title="MCP Server 需要用户名吗？">
    不需要。远程和本地 MCP Server 都只使用 API 密钥进行身份验证。形如 `brd-customer-{customer_id}-zone-{zone_name}` 的用户名用于原生代理访问，与 MCP 无关。如果第三方工具要求填写用户名，请留空。
  </Accordion>

  <Accordion title="支持哪些智能体？">
    技能可在[开放智能体技能生态](https://github.com/vercel-labs/skills)的 40+ 个智能体中使用，包括 Claude Code、Cursor 和 Codex。MCP Server 适用于任何兼容 MCP 的客户端。`llms.txt` 适用于任何能够获取 URL 的工具。
  </Accordion>

  <Accordion title="我的智能体能为没有预构建抓取器的网站构建抓取器吗？">
    可以。给它一个目标 URL 和一句描述所需字段的说明，Bright Data CLI 就会通过 Scraper Studio 生成抓取器。完整的构建、运行与自我修复循环的可复制提示词参见 [Scraper Studio 编码智能体提示词](/cn/products/scraper-studio/coding-agent-prompts)。
  </Accordion>
</AccordionGroup>

## 后续步骤

<CardGroup cols={3}>
  <Card title="选择产品" icon="compass" href="/cn/product-selector">
    将目标网站匹配到合适的 Bright Data 产品，然后直接开始第一个请求。
  </Card>

  <Card title="用提示词构建抓取器" icon="messages" href="/cn/products/scraper-studio/coding-agent-prompts">
    可复制的 Claude Code、Cursor 和 Codex 提示词，用于构建、运行并自我修复抓取器。
  </Card>

  <Card title="Bright Data CLI" icon="terminal" href="/cn/products/cli/overview">
    在终端中进行抓取、搜索、管理 zone 并控制远程浏览器。
  </Card>
</CardGroup>
