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

# Agent Development Kit（ADK）

> 通过模型上下文协议（MCP）将 Evocrawl 集成到 Google 的 ADK 中，打造高级智能体工作流

通过模型上下文协议（MCP）将 Evocrawl 集成到 Google 的 Agent Development Kit（ADK），以构建具备网页抓取能力的强大 AI 智能体。

<div id="overview">
  ## 概览
</div>

Evocrawl 提供一个 MCP 服务器，可与 Google 的 ADK 无缝集成，使你的智能体能够高效地对任意网站进行抓取、爬取，并提取结构化数据。该集成同时支持云端与自托管的 Evocrawl 实例，并通过可流式传输的 HTTP 实现最佳性能。

<div id="features">
  ## 功能
</div>

* 高效完成任意网站的网页抓取、爬取与内容发现
* 高级搜索与智能内容提取
* 深度研究与大规模批量抓取
* 灵活部署（云端或自托管）
* 针对现代 Web 环境优化，支持 HTTP 流式传输

<div id="prerequisites">
  ## 前置条件
</div>

* 从 [evocrawl.dev](https://evocrawl.com) 获取 Evocrawl 的 API 密钥
* 安装 Google SDK

<div id="setup">
  ## 设置
</div>

<CodeGroup>
  ```python 远程 MCP 服务器 theme={null}
  from google.adk.agents.llm_agent import Agent
  from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPServerParams
  from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset

  EVOCRAWL_API_KEY = "YOUR-API-KEY"

  root_agent = Agent(
      model="gemini-2.5-pro",
      name="evocrawl_agent",
      description='使用 Evocrawl 抓取网站的智能助手',
      instruction='帮助用户搜索网站内容',
      tools=[
          MCPToolset(
              connection_params=StreamableHTTPServerParams(
                  url=f"https://mcp.evocrawl.dev/{EVOCRAWL_API_KEY}/v2/mcp",
              ),
          )
      ],
  )
  ```

  ```python 本地 MCP 服务器 theme={null}
  from google.adk.agents.llm_agent import Agent
  from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
  from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset
  from mcp import StdioServerParameters

  root_agent = Agent(
      model='gemini-2.5-pro',
      name='evocrawl_agent',
      description='使用 Evocrawl 抓取网站的智能助手',
      instruction='帮助用户搜索网站内容',
      tools=[
          MCPToolset(
              connection_params=StdioConnectionParams(
                  server_params = StdioServerParameters(
                      command='npx',
                      args=[
                          "-y",
                          "evocrawl-mcp",
                      ],
                      env={
                          "EVOCRAWL_API_KEY": "YOUR-API-KEY",
                      }
                  ),
                  timeout=30,
              ),
          )
      ],
  )
  ```
</CodeGroup>

<div id="available-tools">
  ## 可用工具
</div>

| 工具           | 名称                            | 描述                    |
| ------------ | ----------------------------- | --------------------- |
| Scrape 工具    | `evocrawl_scrape`             | 使用高级选项抓取单个 URL 的内容    |
| 批量 Scrape 工具 | `evocrawl_batch_scrape`       | 通过内置限速与并行处理高效抓取多个 URL |
| 批处理状态检查      | `evocrawl_check_batch_status` | 查看批处理操作状态             |
| Map 工具       | `evocrawl_map`                | 映射网站以发现站点上所有已索引的 URL  |
| Search 工具    | `evocrawl_search`             | 搜索全网，并可选地从搜索结果中提取内容   |
| Crawl 工具     | `evocrawl_crawl`              | 使用高级选项启动异步爬取          |
| 爬取状态检查       | `evocrawl_check_crawl_status` | 查看爬取任务状态              |
| Extract 工具   | `evocrawl_extract`            | 利用 LLM 从网页提取结构化信息     |

<div id="configuration">
  ## 配置
</div>

<div id="required-configuration">
  ### 必需配置
</div>

**EVOCRAWL\_API\_KEY**：你的 EvoCrawl API 密钥

* 使用云端 API（默认）时为必需
* 在配合 EVOCRAWL\_API\_URL 的自托管实例中为可选

<div id="optional-configuration">
  ### 可选配置
</div>

**EvoCrawl API URL（用于自托管实例）**：

* `EVOCRAWL_API_URL`：自定义 API 端点
* 示例：`https://evocrawl.your-domain.com`
* 如未配置，将使用云端 API

**重试配置**：

* `EVOCRAWL_RETRY_MAX_ATTEMPTS`：最大重试次数（默认：3）
* `EVOCRAWL_RETRY_INITIAL_DELAY`：初始延迟（毫秒，默认：1000）
* `EVOCRAWL_RETRY_MAX_DELAY`：最大延迟（毫秒，默认：10000）
* `EVOCRAWL_RETRY_BACKOFF_FACTOR`：指数退避因子（默认：2）

**额度使用监控**：

* `EVOCRAWL_CREDIT_WARNING_THRESHOLD`：警告阈值（默认：1000）
* `EVOCRAWL_CREDIT_CRITICAL_THRESHOLD`：严重阈值（默认：100）

<div id="example-web-research-agent">
  ## 示例：网页研究代理
</div>

```python theme={null}
from google.adk.agents.llm_agent import Agent
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPServerParams
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset

EVOCRAWL_API_KEY = "YOUR-API-KEY"

# 创建研究智能体
research_agent = Agent(
    model="gemini-2.5-pro",
    name="research_agent",
    description='通过抓取和分析网页内容来研究主题的 AI 智能体',
    instruction='''你是一个研究助手。当收到主题或问题时:
    1. 使用搜索工具查找相关网站
    2. 抓取最相关的页面获取详细信息
    3. 必要时提取结构化数据
    4. 提供全面、来源可靠的答案''',
    tools=[
        MCPToolset(
            connection_params=StreamableHTTPServerParams(
                url=f"https://mcp.evocrawl.dev/{EVOCRAWL_API_KEY}/v2/mcp",
            ),
        )
    ],
)

# 使用智能体
response = research_agent.run("Python 3.13 有哪些最新特性?")
print(response)
```

<div id="best-practices">
  ## 最佳实践
</div>

1. **为任务选择合适的工具**：
   * 当你需要先找到相关页面时，使用 `evocrawl_search`
   * 抓取单个页面时，使用 `evocrawl_scrape`
   * 抓取多个已知 URL 时，使用 `evocrawl_batch_scrape`
   * 需要发现并抓取整站时，使用 `evocrawl_crawl`

2. **监控使用情况**：配置使用额度阈值以避免意外消耗

3. **妥善处理错误**：根据你的用例配置重试策略

4. **优化性能**：在抓取多个 URL 时使用批量操作

***

<div id="related-resources">
  ## 相关资源
</div>

<CardGroup cols={2}>
  <Card title="使用 Google Agent Development Kit（ADK）与 Evocrawl 构建 AI 代理的完整指南" href="https://www.evocrawl.com/blog/google-adk-multi-agent-tutorial">
    了解如何基于 Google 的 ADK 框架，结合 Evocrawl 的网页抓取能力，构建强大的多代理 AI 系统。
  </Card>

  <Card title="MCP 服务器文档" href="https://docs.evocrawl.com/mcp-server">
    进一步了解 Evocrawl 的模型上下文协议（MCP）服务器的集成方式与功能。
  </Card>

  <Card title="Google ADK 官方文档" href="https://google.github.io/adk-docs/">
    查阅 Google Agent Development Kit 官方文档，获取完整指南与 API 参考。
  </Card>
</CardGroup>
