🚀 快速安装

复制以下命令并运行,立即安装此 Skill:

npx @anthropic-ai/skills install tavily-ai/skills/search

💡 提示:需要 Node.js 和 NPM

搜索技能

搜索网络并获取针对大型语言模型消费优化的相关结果。

身份验证

该脚本通过 Tavily 模型上下文协议服务器使用 OAuth。无需手动设置 – 首次运行时,它将:

  1. 检查 ~/.mcp-auth/ 中是否存在现有令牌
  2. 如果未找到,将自动打开你的浏览器进行 OAuth 身份验证

注意: 你必须有一个现有的 Tavily 账户。OAuth 流程仅支持登录——无法通过此流程创建账户。如果你没有账户,请先在 tavily.com 注册。

替代方案:应用程序编程接口密钥

如果你更愿意使用应用程序编程接口密钥,可以在 https://tavily.com 获取一个,并将其添加到 ~/.claude/settings.json

{
  "env": {
    "TAVILY_API_KEY": "tvly-你的-api-密钥"
  }
}

快速开始

使用脚本

./scripts/search.sh '<json>'

示例:

# 基础搜索
./scripts/search.sh '{"query": "python async patterns"}'

# 带选项
./scripts/search.sh '{"query": "React hooks tutorial", "max_results": 10}'

# 带过滤条件的高级搜索
./scripts/search.sh '{"query": "AI news", "time_range": "week", "max_results": 10}'

# 按域名过滤的搜索
./scripts/search.sh '{"query": "machine learning", "include_domains": ["arxiv.org", "github.com"], "search_depth": "advanced"}'

基础搜索

curl --request POST \
  --url https://api.tavily.com/search \
  --header "Authorization: Bearer $TAVILY_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "query": "latest developments in quantum computing",
    "max_results": 5
  }'

高级搜索

curl --request POST \
  --url https://api.tavily.com/search \
  --header "Authorization: Bearer $TAVILY_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "query": "machine learning best practices",
    "max_results": 10,
    "search_depth": "advanced",
    "include_domains": ["arxiv.org", "github.com"]
  }'

应用程序编程接口参考

端点

POST https://api.tavily.com/search

请求头

Authorization Bearer <TAVILY_API_KEY>
Content-Type application/json

请求体

字段 类型 默认值 描述
query 字符串 必需 搜索查询(保持在 400 字符以内)
max_results 整数 10 最大结果数(0-20)
search_depth 字符串 "basic" ultra-fastfastbasicadvanced
topic 字符串 "general" 搜索主题(目前仅支持 general)
time_range 字符串 null dayweekmonthyear
start_date 字符串 null 返回此日期之后的结果(YYYY-MM-DD
end_date 字符串 null 返回此日期之前的结果(YYYY-MM-DD
include_domains 数组 [] 要包含的域名(最多 300 个)
exclude_domains 数组 [] 要排除的域名(最多 150 个)
country 字符串 null 提升特定国家/地区的结果(仅限 general 主题)
include_raw_content 布尔值 false 包含完整页面内容
include_images 布尔值 false 包含图片结果
include_image_descriptions 布尔值 false 包含图片描述
include_favicon 布尔值 false 为每个结果包含网站图标网址

响应格式

{
  "query": "latest developments in quantum computing",
  "results": [
    {
      "title": "页面标题",
      "url": "https://example.com/page",
      "content": "提取的文本片段...",
      "score": 0.85
    }
  ],
  "response_time": 1.2
}

搜索深度

深度 延迟 相关性 内容类型
ultra-fast 最低 较低 自然语言处理摘要
fast 良好 片段
basic 中等 自然语言处理摘要
advanced 较高 最高 片段

何时使用每种深度:

  • ultra-fast:实时聊天、自动补全
  • fast:需要片段但延迟重要
  • basic:通用目的,均衡
  • advanced:精度重要(默认推荐)

示例

按域名过滤的搜索

curl --request POST \
  --url https://api.tavily.com/search \
  --header "Authorization: Bearer $TAVILY_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "query": "Python async best practices",
    "include_domains": ["docs.python.org", "realpython.com", "github.com"],
    "search_depth": "advanced"
  }'

包含完整内容的搜索

curl --request POST \
  --url https://api.tavily.com/search \
  --header "Authorization: Bearer $TAVILY_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "query": "React hooks tutorial",
    "max_results": 3,
    "include_raw_content": true
  }'

提示

  • 保持查询在 400 字符以内 – 把它看作搜索查询,而不是提示词
  • 将复杂查询分解为子查询 – 比一个庞大查询效果更好
  • 使用 include_domains 专注于可信来源
  • 使用 time_range 获取最新信息
  • score(0-1)过滤 以获得相关性最高的结果

📄 原始文档

完整文档(英文):

https://skills.sh/tavily-ai/skills/search

💡 提示:点击上方链接查看 skills.sh 原始英文文档,方便对照翻译。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。