mcpField
E
exa-search

exa-search

github.com/benedictking生产力5621 次安装27 周前更新
代码仓库

关于 exa-search

exa-search 是一项技能,可根据意图选择并调用 Exa 端点,执行网页搜索、内容提取、相似页面查找、直接问答和结构化研究。它通过子技能将请求规划与 API 调用分开。

主要功能

  1. 01按意图选择 Exa 端点
  2. 02使用多种方式搜索网页
  3. 03提取结果 ID 对应的内容
  4. 04查找与指定 URL 相似的页面
  5. 05生成回答或按架构输出研究结果

适用场景

  1. 01跨网页研究某个主题
  2. 02获取搜索结果的完整内容
  3. 03查找与已知 URL 相关的页面
  4. 04获取直接答案或结构化报告

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/benedictking/exa-search --skill exa-search

安装后在 Claude Code 中输入/exa-search确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

.env.example
.gitignore
exa-api.cjs
exa-fetcher.md

详细介绍

Exa 搜索技能

触发条件与端点选择

根据用户意图选择 Exa 端点:

  • search:需要语义搜索/查找网页/研究主题
  • contents:已知结果 ID,需要提取完整内容
  • findsimilar:已知 URL,需要查找相似页面
  • answer:需要直接回答问题
  • research:需要根据给定的 output_schema 获取结构化研究输出

推荐架构(主技能 + 子技能)

此技能采用两阶段架构:

  1. 主技能(当前上下文):理解用户问题 → 选择端点 → 组装 JSON 载荷
  2. 子技能(分叉上下文):仅负责执行 HTTP 调用,避免浪费对话历史令牌

执行方法

使用 Task 工具调用 exa-fetcher 子技能,并传入命令和 JSON(stdin):

Task parameters:
- subagent_type: Bash
- description: "Call Exa API"
- prompt: cat <<'JSON' | node .claude/skills/exa-search/exa-api.cjs <search|contents|findsimilar|answer|research>
  { ...payload... }
  JSON

载荷示例

1) 搜索
cat <<'JSON' | node .claude/skills/exa-search/exa-api.cjs search
{
  "query": "Latest research in LLMs",
  "type": "auto",
  "numResults": 10,
  "category": "research paper",
  "includeDomains": [],
  "excludeDomains": [],
  "startPublishedDate": "2025-01-01",
  "endPublishedDate": "2025-12-31",
  "includeText": [],
  "excludeText": [],
  "context": true,
  "contents": {
    "text": true,
    "highlights": true,
    "summary": true
  }
}
JSON

搜索类型:

  • neural:使用嵌入进行语义搜索
  • fast:基于关键词的快速搜索
  • auto:自动选择最佳方法(默认)
  • deep:全面的深度搜索

类别:

  • company、people、research paper、news、pdf、github、tweet 等
2) 内容
cat <<'JSON' | node .claude/skills/exa-search/exa-api.cjs contents
{
  "ids": ["result-id-1", "result-id-2"],
  "text": true,
  "highlights": true,
  "summary": true
}
JSON
3) 查找相似内容
cat <<'JSON' | node .claude/skills/exa-search/exa-api.cjs findsimilar
{
  "url": "https://example.com/article",
  "numResults": 10,
  "category": "news",
  "includeDomains": [],
  "excludeDomains": [],
  "startPublishedDate": "2025-01-01",
  "contents": {
    "text": true,
    "summary": true
  }
}
JSON
4) 回答
cat <<'JSON' | node .claude/skills/exa-search/exa-api.cjs answer
{
  "query": "What is the capital of France?",
  "numResults": 5,
  "includeDomains": [],
  "excludeDomains": []
}
JSON
5) 研究
cat <<'JSON' | node .claude/skills/exa-search/exa-api.cjs research
{
  "input": "What are the latest developments in AI?",
  "model": "auto",
  "stream": false,
  "output_schema": {
    "properties": {
      "topic": {
        "type": "string",
        "description": "The main topic"
      },
      "key_findings": {
        "type": "array",
        "description": "List of key findings",
        "items": {
          "type": "string"
        }
      }
    },
    "required": ["topic"]
  },
  "citation_format": "numbered"
}
JSON

环境变量与 API 密钥

配置 API 密钥有两种方式(优先级:环境变量 > .env):

  1. 环境变量:EXA_API_KEY
  2. .env 文件:放置在 .claude/skills/exa-search/.env,可从 .env.example 复制

响应格式

所有端点均返回 JSON,包含:

  • requestId:唯一请求标识符
  • results:搜索结果数组
  • searchType:执行的搜索类型(适用于 search 端点)
  • context:便于大模型使用的上下文字符串(如有请求)
  • costDollars:详细费用明细

评论

支持 Markdown