Mastra集成
Scavio以工具包的形式提供给 Mastra(TypeScript智能体框架)使用。安装 mastra-scavio,将这些工具交给任意Mastra Agent, 它便能跨Google、YouTube、Amazon、Walmart、Reddit、TikTok和Instagram进行实时搜索—一个工具包、一个API 密钥。
前提条件
- Node.js 20.9或更高版本,以及一个Mastra项目(
@mastra/core)。 - 从 dashboard.scavio.dev 获取的Scavio API密钥(新账户可获得免费积分,无需信用卡)。
安装
Bash
npm install mastra-scavio @mastra/core zod设置API密钥
Bash
export SCAVIO_API_KEY=sk_live_your_key这些工具会从环境变量中读取 SCAVIO_API_KEY。您也可以显式传入: createScavioTools({ apiKey: "sk_live_..." })。
快速开始
createScavioTools() 会以键值对象的形式返回全部Scavio工具,您可以直接将其 传给智能体:
import { Agent } from "@mastra/core/agent";
import { createScavioTools } from "mastra-scavio";
export const agent = new Agent({
id: "web-search-agent",
name: "Web Search Agent",
model: "openai/gpt-5.5",
instructions: "Search the web, shopping sites, and social platforms with Scavio.",
tools: createScavioTools(), // reads SCAVIO_API_KEY
});使用单个工具
只导入你需要的工具,而非全部工具集:
import { Agent } from "@mastra/core/agent";
import { createScavioGoogleSearchTool, createScavioRedditSearchTool } from "mastra-scavio";
export const agent = new Agent({
id: "research-agent",
model: "openai/gpt-5.5",
instructions: "Research with Google and Reddit before answering, and cite sources.",
tools: {
googleSearch: createScavioGoogleSearchTool(),
redditSearch: createScavioRedditSearchTool(),
},
});可用工具
每个工具都通过Mastra的 createTool() 创建,并返回结构化的Scavio JSON响应。
| 数据源 | 工具 |
|---|---|
scavioGoogleSearch | |
| Amazon | scavioAmazonSearch, scavioAmazonProduct |
| Walmart | scavioWalmartSearch, scavioWalmartProduct |
| YouTube | scavioYoutubeSearch, scavioYoutubeMetadata |
scavioRedditSearch, scavioRedditPost | |
| TikTok | scavioTiktokSearch, scavioTiktokProfile |
scavioInstagramSearch, scavioInstagramProfile |
通过MCP使用每个端点
若想免安装地使用完整的Scavio API(33个端点),只需将Mastra的MCP客户端指向托管的 Scavio服务器:
import { MCPClient } from "@mastra/mcp";
const mcp = new MCPClient({
id: "scavio",
servers: {
scavio: {
url: new URL("https://mcp.scavio.dev/mcp"),
requestInit: { headers: { "x-api-key": process.env.SCAVIO_API_KEY! } },
},
},
});
const tools = await mcp.listTools();积分消耗
大多数调用消耗1个积分。Reddit和Instagram消耗2个积分,当未设置 light_request 时 Google消耗2个积分。请参阅 速率限制 文档了解套餐限制,并参阅 错误 参考获取重试指导。