> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/test/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/test/compute/mcpg/web-search/tavily.md).

# Tavily

Tavily是一家专注于AI搜索的公司，他们的搜索会为了LLM进行优化，以便于LLM进行数据检索。

## MCP 工具

### Search（搜索）

Tavily是一家专注于AI搜索的公司，他们的搜索会为了LLM进行优化，以便于LLM进行数据检索。

#### 参数

**Body 参数**

* `query` (string, 必需): The search query string | 示例值：`chatgpt`
* `search_depth` (string, 可选): "basic" or "advanced" | 示例值：`basic`
* `topic` (string, 可选): 搜索类别，可用选项：general, news, finance。默认为general
* `max_results` (number, 可选): 搜索结果的最大数量（0-20）。默认值为5
* `chunks_per_source` (number, 可选): 每个源的内容块数量（1-3）。仅在search\_depth为advanced时可用。默认值为3。
* `time_range` (string, 可选): 时间范围筛选，可用选项：day, week, month, year, d, w, m, y
* `start_date` (string, 可选): 筛选在此日期之后的数据 (YYYY-MM-DD)
* `end_date` (string, 可选): 筛选在此日期之前的数据 (YYYY-MM-DD)
* `include_answer` (boolean, 可选): 包括针对所提供查询的LLM生成答案。basic或true返回快速答案。advanced返回更详细的答案。默认false
* `include_raw_content` (boolean, 可选): 包括每个搜索结果的清理和解析的HTML内容。markdown或true返回以markdown格式显示的搜索结果内容。text返回结果的纯文本，可能会增加延迟。默认false
* `include_images` (boolean, 可选): 执行图片搜索并包含结果。默认：false
* `include_image_descriptions` (boolean, 可选): 当 include\_images 为 true 时，为每张图片添加描述文本。默认为 false。
* `include_favicon` (boolean, 可选): 为每个结果包含网站图标URL。默认为：false
* `include_domains` (array, 可选): 包含的域名（最多300个域名）
* `exclude_domains` (array, 可选): 排除的域名（最多150个域名）
* `country` (string, 可选): 从特定国家提升搜索结果。这将优先在搜索结果中显示所选国家的內容。topic 为 general 可用。
  * Available options: afghanistan, albania, algeria, andorra, angola, argentina, armenia, australia, austria, azerbaijan, bahamas, bahrain, bangladesh, barbados, belarus, belgium, belize, benin, bhutan, bolivia, bosnia and herzegovina, botswana, brazil, brunei, bulgaria, burkina faso, burundi, cambodia, cameroon, canada, cape verde, central african republic, chad, chile, china, colombia, comoros, congo, costa rica, croatia, cuba, cyprus, czech republic, denmark, djibouti, dominican republic, ecuador, egypt, el salvador, equatorial guinea, eritrea, estonia, ethiopia, fiji, finland, france, gabon, gambia, georgia, germany, ghana, greece, guatemala, guinea, haiti, honduras, hungary, iceland, india, indonesia, iran, iraq, ireland, israel, italy, jamaica, japan, jordan, kazakhstan, kenya, kuwait, kyrgyzstan, latvia, lebanon, lesotho, liberia, libya, liechtenstein, lithuania, luxembourg, madagascar, malawi, malaysia, maldives, mali, malta, mauritania, mauritius, mexico, moldova, monaco, mongolia, montenegro, morocco, mozambique, myanmar, namibia, nepal, netherlands, new zealand, nicaragua, niger, nigeria, north korea, north macedonia, norway, oman, pakistan, panama, papua new guinea, paraguay, peru, philippines, poland, portugal, qatar, romania, russia, rwanda, saudi arabia, senegal, serbia, singapore, slovakia, slovenia, somalia, south africa, south korea, south sudan, spain, sri lanka, sudan, sweden, switzerland, syria, taiwan, tajikistan, tanzania, thailand, togo, trinidad and tobago, tunisia, turkey, turkmenistan, uganda, ukraine, united arab emirates, united kingdom, united states, uruguay, uzbekistan, venezuela, vietnam, yemen, zambia, zimbabwe
* `auto_parameters` (boolean, 可选): 让Tavily根据查询自动配置搜索参数。默认：false
* `exact_match` (boolean, 可选): 确保仅返回查询中包含确切引号短语的结果，忽略同义词或语义变化。在查询中用引号括住目标短语（例如 "John Smith" CEO Acme Corp）。引号内的标点通常会被忽略。

### Extract（提取网页）

从指定的URL提取和解析内容。

#### 参数

**Body 参数**

* `urls` (string|array, 必需): 要提取的URL或URL列表
* `query` (string, 可选): 用户意图，用于重新排序提取的内容块
* `chunks_per_source` (integer, 可选): 每个源返回的最大块数（1-5），仅在提供 `query` 时可用，默认：`3`
* `extract_depth` (string, 可选): 提取深度，`basic`（默认）或 `advanced`
* `include_images` (boolean, 可选): 是否在响应中包含图片列表，默认：`false`
* `include_favicon` (boolean, 可选): 是否包含每个结果的favicon URL，默认：`false`
* `format` (string, 可选): 提取内容的格式，`markdown`（默认）或 `text`
* `timeout` (number, 可选): 等待URL提取的最大时间（秒，1.0-60.0）

### MCP Cline 配置

此服务器需要通过您的 MCP 客户端进行配置。以下是不同环境下的示例：

需要替换你的租户ID和API Key（必需）

```
{
  "mcpServers": {
    "tavily": {
      "type": "streamable_http",
      "url": "https://mcp.ecn.ai/{CID}/tavily/mcp",
      "headers": {
        "Authorization": "Bearer 你的API Key"
      }
    }
  }
}
```

## API 接口

### Search（搜索）

执行搜索查询，使用 Tavily Search 进行智能搜索。

#### 请求信息

* **Method**: POST
* **Endpoint**: `/tavily/search`

#### 请求参数

**Header 参数**

* `Authorization` (string, 必需): Bearer 认证头，格式为 `Bearer {API_KEY}` | 示例值：`Bearer {{YOUR_API_KEY}}`
* `Content-Type` (string, 必需): `application/json`

**Body 参数**

* `query` (string, 必需): The search query string | 示例值：`chatgpt`
* `search_depth` (string, 可选): "basic" or "advanced" | 示例值：`basic`
* `topic` (string, 可选): 搜索类别，可用选项：general, news, finance。默认为general
* `max_results` (number, 可选): 搜索结果的最大数量（0-20）。默认值为5
* `chunks_per_source` (number, 可选): 每个源的内容块数量（1-3）。仅在search\_depth为advanced时可用。默认值为3。
* `time_range` (string, 可选): 时间范围筛选，可用选项：day, week, month, year, d, w, m, y
* `start_date` (string, 可选): 筛选在此日期之后的数据 (YYYY-MM-DD)
* `end_date` (string, 可选): 筛选在此日期之前的数据 (YYYY-MM-DD)
* `include_answer` (boolean, 可选): 包括针对所提供查询的LLM生成答案。basic或true返回快速答案。advanced返回更详细的答案。默认false
* `include_raw_content` (boolean, 可选): 包括每个搜索结果的清理和解析的HTML内容。markdown或true返回以markdown格式显示的搜索结果内容。text返回结果的纯文本，可能会增加延迟。默认false
* `include_images` (boolean, 可选): 执行图片搜索并包含结果。默认：false
* `include_image_descriptions` (boolean, 可选): 当 include\_images 为 true 时，为每张图片添加描述文本。默认为 false。
* `include_favicon` (boolean, 可选): 为每个结果包含网站图标URL。默认为：false
* `include_domains` (array, 可选): 包含的域名（最多300个域名）
* `exclude_domains` (array, 可选): 排除的域名（最多150个域名）
* `country` (string, 可选): 从特定国家提升搜索结果。这将优先在搜索结果中显示所选国家的內容。topic 为 general 可用。
  * Available options: afghanistan, albania, algeria, andorra, angola, argentina, armenia, australia, austria, azerbaijan, bahamas, bahrain, bangladesh, barbados, belarus, belgium, belize, benin, bhutan, bolivia, bosnia and herzegovina, botswana, brazil, brunei, bulgaria, burkina faso, burundi, cambodia, cameroon, canada, cape verde, central african republic, chad, chile, china, colombia, comoros, congo, costa rica, croatia, cuba, cyprus, czech republic, denmark, djibouti, dominican republic, ecuador, egypt, el salvador, equatorial guinea, eritrea, estonia, ethiopia, fiji, finland, france, gabon, gambia, georgia, germany, ghana, greece, guatemala, guinea, haiti, honduras, hungary, iceland, india, indonesia, iran, iraq, ireland, israel, italy, jamaica, japan, jordan, kazakhstan, kenya, kuwait, kyrgyzstan, latvia, lebanon, lesotho, liberia, libya, liechtenstein, lithuania, luxembourg, madagascar, malawi, malaysia, maldives, mali, malta, mauritania, mauritius, mexico, moldova, monaco, mongolia, montenegro, morocco, mozambique, myanmar, namibia, nepal, netherlands, new zealand, nicaragua, niger, nigeria, north korea, north macedonia, norway, oman, pakistan, panama, papua new guinea, paraguay, peru, philippines, poland, portugal, qatar, romania, russia, rwanda, saudi arabia, senegal, serbia, singapore, slovakia, slovenia, somalia, south africa, south korea, south sudan, spain, sri lanka, sudan, sweden, switzerland, syria, taiwan, tajikistan, tanzania, thailand, togo, trinidad and tobago, tunisia, turkey, turkmenistan, uganda, ukraine, united arab emirates, united kingdom, united states, uruguay, uzbekistan, venezuela, vietnam, yemen, zambia, zimbabwe
* `auto_parameters` (boolean, 可选): 让Tavily根据查询自动配置搜索参数。默认：false
* `exact_match` (boolean, 可选): 确保仅返回查询中包含确切引号短语的结果，忽略同义词或语义变化。在查询中用引号括住目标短语（例如 "John Smith" CEO Acme Corp）。引号内的标点通常会被忽略。

#### 返回响应

* **200 成功**
  * Content-Type：`application/json`

#### 请求示例

```
curl --location --request POST 'https://api.ecn.ai/tavily/search' \
 --header 'Content-Type: application/json' \
 --header 'Authorization: Bearer YOUR_API_KEY' \
 --data '{
  "query": "who is Leo Messi?",
  "search_depth": "basic",
  "max_results": 5,
  "include_answer": true,
  "include_images": false
}'
```

#### 响应示例

```json
{
  "query": "Who is Leo Messi?",
  "answer": "Lionel Messi, born in 1987, is an Argentine footballer widely regarded as one of the greatest players of his generation. He spent the majority of his career playing for FC Barcelona, where he won numerous domestic league titles and UEFA Champions League titles. Messi is known for his exceptional dribbling skills, vision, and goal-scoring ability. He has won multiple FIFA Ballon d'Or awards, numerous La Liga titles with Barcelona, and holds the record for most goals scored in a calendar year. In 2014, he led Argentina to the World Cup final, and in 2015, he helped Barcelona capture another treble. Despite turning 36 in June, Messi remains highly influential in the sport.",
  "images": [],
  "results": [
    {
      "title": "Lionel Messi Facts | Britannica",
      "url": "https://www.britannica.com/facts/Lionel-Messi",
      "content": "Lionel Messi, an Argentine footballer, is widely regarded as one of the greatest football players of his generation. Born in 1987, Messi spent the majority of his career playing for Barcelona, where he won numerous domestic league titles and UEFA Champions League titles. Messi is known for his exceptional dribbling skills, vision, and goal",
      "score": 0.81025416,
      "raw_content": null,
      "favicon": "https://britannica.com/favicon.png"
    }
  ],
  "response_time": 1.67,
  "auto_parameters": {
    "topic": "general",
    "search_depth": "basic"
  },
  "request_id": "123e4567-e89b-12d3-a456-426614174111"
}
```

### Extract（提取网页）

从指定的URL提取和解析内容。

#### 请求信息

* **Method**: POST
* **Endpoint**: `/tavily/extract`

#### 请求参数

**Header 参数**

* `Authorization` (string, 必需): Bearer 认证头，格式为 `Bearer {API_KEY}` | 示例值：`Bearer YOUR_API_KEY`
* `Content-Type` (string, 必需): `application/json`

**Body 参数**

* `urls` (string|array, 必需): 要提取的URL或URL列表 | 示例值：`"https://en.wikipedia.org/wiki/Artificial_intelligence"` 或 `["https://en.wikipedia.org/wiki/Artificial_intelligence"]`
* `query` (string, 可选): 用户意图，用于重新排序提取的内容块。提供后，块会根据与此查询的相关性重新排序
* `chunks_per_source` (integer, 可选): 每个源返回的最大块数（1-5），仅在提供 `query` 时可用，默认：`3`。块是直接从源中提取的短内容片段（每个最多500个字符），将出现在 `raw_content` 字段中，格式为：`<chunk 1> [...] <chunk 2> [...] <chunk 3>`
* `extract_depth` (string, 可选): 提取深度，`basic`（默认）或 `advanced`（检索更多数据包括表格和嵌入内容，但可能增加延迟）
* `include_images` (boolean, 可选): 是否在响应中包含从URL提取的图片列表，默认：`false`
* `include_favicon` (boolean, 可选): 是否包含每个结果的favicon URL，默认：`false`
* `format` (string, 可选): 提取的网页内容格式，`markdown`（默认，返回markdown格式）或 `text`（返回纯文本，可能增加延迟）
* `timeout` (number, 可选): 等待URL提取的最大时间（秒），必须在1.0-60.0秒之间。如果未指定，将根据 `extract_depth` 应用默认超时：basic提取为10秒，advanced提取为30秒

#### 返回响应

* **200 成功**
  * Content-Type：`application/json`

#### 请求示例

```
curl --location --request POST 'https://api.ecn.ai/tavily/extract' \
 --header 'Content-Type: application/json' \
 --header 'Authorization: Bearer YOUR_API_KEY' \
 --data '{
  "urls": [
    "https://en.wikipedia.org/wiki/Artificial_intelligence",
    "https://en.wikipedia.org/wiki/Machine_learning",
    "https://en.wikipedia.org/wiki/Data_science",
    "https://en.wikipedia.org/wiki/Quantum_computing"
  ],
  "query": "machine learning algorithms",
  "chunks_per_source": 3,
  "extract_depth": "basic",
  "include_images": false,
  "include_favicon": true,
  "format": "markdown"
}'
```

#### 响应示例

```json
{
  "results": [
    {
      "url": "https://en.wikipedia.org/wiki/Artificial_intelligence",
      "raw_content": "Jump to content\nMain menu\nSearch\nAppearance\nDonate\nCreate account\nLog in\nPersonal tools\n        Photograph your local culture, help Wikipedia and win!...",
      "images": [],
      "favicon": "https://en.wikipedia.org/static/favicon/wikipedia.ico"
    }
  ],
  "failed_results": [],
  "response_time": 0.02,
  "usage": {
    "credits": 1
  },
  "request_id": "123e4567-e89b-12d3-a456-426614174111"
}
```


---

# 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:

```
GET https://docs.console.zenlayer.com/test/compute/mcpg/web-search/tavily.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
