Skip to content

feat: add 30 specialized SerpApi tools#1

Open
galetahub wants to merge 6 commits into
mainfrom
feat/serpapi-tools
Open

feat: add 30 specialized SerpApi tools#1
galetahub wants to merge 6 commits into
mainfrom
feat/serpapi-tools

Conversation

@galetahub

Copy link
Copy Markdown
Contributor

Summary

Adds 30 specialized SerpApi tools to the plugin.
Each tool follows the same pattern: a createSerpApi<X>Tool(api, ctx) factory returning an AnyAgentTool, a per-engine ALLOWED_PARAMS security allowlist, and an extract() shaping function.

Tools

Tool Description
serpapi_amazon Search Amazon for products.
serpapi_amazon_product Fetch detailed Amazon product info by ASIN.
serpapi_autocomplete Google search autocomplete suggestions for a partial query.
serpapi_bing Web search via Bing.
serpapi_duckduckgo Web search via DuckDuckGo (organic results, knowledge graph, news).
serpapi_ebay Search eBay listings.
serpapi_ebay_product Detailed eBay product info by product ID.
serpapi_events Local events via Google Events.
serpapi_facebook_profile Fetch a public Facebook profile.
serpapi_finance Stock prices, currency rates, and crypto via Google Finance.
serpapi_flights Real flight prices and itineraries via Google Flights.
serpapi_hotels Hotels and accommodation via Google Hotels.
serpapi_immersive_product Detailed Google product info by page_token from Shopping results.
serpapi_instagram_profile Fetch a public Instagram profile.
serpapi_jobs Google Jobs search.
serpapi_lens Google Lens reverse image search.
serpapi_maps Local businesses, restaurants, and POIs via Google Maps.
serpapi_maps_reviews Reviews for a place on Google Maps.
serpapi_news Recent articles via Google News.
serpapi_scholar Academic papers, research articles, and citations via Google Scholar.
serpapi_shopping Google Shopping product search.
serpapi_trends Google Trends: interest over time, by region, related topics/queries.
serpapi_tripadvisor Destinations, hotels, restaurants, and attractions via Tripadvisor.
serpapi_walmart Walmart product listings.
serpapi_walmart_product Detailed Walmart product info by product ID.
serpapi_weather Current weather or forecast for a location via Google.
serpapi_yahoo Web search via Yahoo!.
serpapi_youtube YouTube search: videos, channels, shorts.
serpapi_youtube_transcript Fetch the transcript of a YouTube video.
serpapi_youtube_video YouTube video metadata: title, channel, views, chapters.

Changes

  • src/tools/*.ts — 30 tool implementations + barrel (src/tools/index.ts).
  • src/utils.ts — shared resolveToolConfig / readBooleanArg tool helpers.
  • index.ts — register all 30 tools alongside the web search provider.
  • openclaw.plugin.json — declare all 30 ids in contracts.tools.
  • skills/serpapi/SKILL.md — per-tool parameter and usage docs.
  • README.md — updated tool list.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the SerpApi OpenClaw plugin from just a web_search provider to a broader suite of specialized SerpApi-backed tools, and wires them into the plugin contract/registration and documentation.

Changes:

  • Adds shared tool helpers (resolveToolConfig, readBooleanArg) to support consistent runtime config resolution and boolean argument parsing.
  • Introduces 30 specialized SerpApi tools (plus a barrel export) and registers them in the plugin entrypoint.
  • Updates plugin contracts and user-facing documentation (README + SerpApi skill docs) to reflect the new tool surface area.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils.ts Adds shared helpers for tool config resolution and boolean argument parsing.
src/tools/amazon.ts Adds serpapi_amazon tool implementation.
src/tools/amazon-product.ts Adds serpapi_amazon_product tool implementation.
src/tools/autocomplete.ts Adds serpapi_autocomplete tool implementation.
src/tools/bing.ts Adds serpapi_bing tool implementation.
src/tools/duckduckgo.ts Adds serpapi_duckduckgo tool implementation.
src/tools/ebay.ts Adds serpapi_ebay tool implementation.
src/tools/ebay-product.ts Adds serpapi_ebay_product tool implementation.
src/tools/events.ts Adds serpapi_events tool implementation.
src/tools/facebook-profile.ts Adds serpapi_facebook_profile tool implementation.
src/tools/finance.ts Adds serpapi_finance tool implementation.
src/tools/flights.ts Adds serpapi_flights tool implementation.
src/tools/hotels.ts Adds serpapi_hotels tool implementation.
src/tools/immersive-product.ts Adds serpapi_immersive_product tool implementation.
src/tools/instagram-profile.ts Adds serpapi_instagram_profile tool implementation.
src/tools/jobs.ts Adds serpapi_jobs tool implementation.
src/tools/lens.ts Adds serpapi_lens tool implementation.
src/tools/maps.ts Adds serpapi_maps tool implementation.
src/tools/maps-reviews.ts Adds serpapi_maps_reviews tool implementation.
src/tools/news.ts Adds serpapi_news tool implementation.
src/tools/scholar.ts Adds serpapi_scholar tool implementation.
src/tools/shopping.ts Adds serpapi_shopping tool implementation.
src/tools/trends.ts Adds serpapi_trends tool implementation.
src/tools/tripadvisor.ts Adds serpapi_tripadvisor tool implementation.
src/tools/walmart.ts Adds serpapi_walmart tool implementation.
src/tools/walmart-product.ts Adds serpapi_walmart_product tool implementation.
src/tools/weather.ts Adds serpapi_weather tool implementation.
src/tools/yahoo.ts Adds serpapi_yahoo tool implementation.
src/tools/youtube.ts Adds serpapi_youtube tool implementation.
src/tools/youtube-video.ts Adds serpapi_youtube_video tool implementation.
src/tools/youtube-transcript.ts Adds serpapi_youtube_transcript tool implementation.
src/tools/index.ts Adds barrel exports for all specialized tools.
index.ts Registers the 30 specialized tools in the plugin entrypoint.
openclaw.plugin.json Declares the tool IDs under contracts.tools and updates plugin metadata.
skills/serpapi/SKILL.md Expands skill documentation with per-tool parameters and usage guidance.
README.md Updates README to reflect the additional specialized tools and docs link.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skills/serpapi/SKILL.md
Comment thread openclaw.plugin.json Outdated
"id": "serpapi",
"name": "SerpApi Search",
"description": "Web search provider backed by SerpApi (Google Light, with 100+ engines). Specialized SerpApi tools follow in subsequent releases.",
"description": "Web search provider plus specialized SerpApi tools for news, flights, hotels, maps, shopping, YouTube, scholar, finance, events, and 100+ search engines.",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the entrypoint description now matches the manifest

Comment thread index.ts Outdated
Comment on lines +42 to +43
description:
"Web search provider backed by SerpApi (Google Light). Specialized SerpApi tools for news, flights, hotels, maps, shopping, YouTube, scholar, finance, and more follow in subsequent releases.",
"Web search provider plus specialized SerpApi tools for news, flights, hotels, maps, shopping, YouTube, scholar, finance, events, and 100+ search engines.",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@galetahub galetahub self-assigned this Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.

Comment thread src/tools/hotels.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 6 comments.

Comment thread src/tools/youtube.ts
Comment on lines +1 to +16
import type { AnyAgentTool } from "openclaw/plugin-sdk/plugin-entry";
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-runtime";
import { jsonResult, readStringParam } from "openclaw/plugin-sdk/provider-web-search";
import { callSerpApi } from "../serpapi-client.js";
import { type SerpApiToolCtx, resolveToolConfig } from "../utils.js";

const ALLOWED_PARAMS = ["search_query", "hl", "sp", "zero_trace"] as const;

function extract(raw: Record<string, unknown>): Record<string, unknown> {
return {
engine: "youtube",
channel_results: raw.channel_results ?? [],
video_results: raw.video_results ?? [],
shorts_results: raw.shorts_results ?? [],
};
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. We're intentionally not wrapping these fields with wrapWebContent for now.

The engine youtube returns the raw SerpApi result objects as structured JSON.

Comment thread src/tools/flights.ts
Comment on lines +64 to +83
execute: async (_toolCallId: string, args: Record<string, unknown>, signal?: AbortSignal) => {
const cfg = resolveToolConfig(api, ctx);
const raw = await callSerpApi({
cfg,
engine: "google_flights",
allowedParams: ALLOWED_PARAMS,
params: {
departure_id: readStringParam(args, "departure_id", { required: true }),
arrival_id: readStringParam(args, "arrival_id", { required: true }),
outbound_date: readStringParam(args, "outbound_date", { required: true }),
return_date: readStringParam(args, "return_date") ?? undefined,
type: readStringParam(args, "type") ?? undefined,
adults: readNumberParam(args, "adults", { integer: true }) ?? undefined,
currency: readStringParam(args, "currency") ?? undefined,
gl: readStringParam(args, "gl") ?? undefined,
},
signal,
});
return jsonResult(extract(raw));
},
Comment thread src/tools/news.ts
Comment on lines +3 to +7
import {
jsonResult,
readNumberParam,
readStringParam,
} from "openclaw/plugin-sdk/provider-web-search";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. We're intentionally not wrapping these fields with wrapWebContent for now.

The engine google_news returns the raw SerpApi result objects as structured JSON.

Comment thread src/tools/news.ts
Comment on lines +23 to +34
function extract(raw: Record<string, unknown>, maxCount: number): Record<string, unknown> {
const results = Array.isArray(raw.news_results)
? (raw.news_results as unknown[]).slice(0, maxCount)
: [];
return {
engine: "google_news",
results,
menu_links: raw.menu_links ?? [],
related_topics: raw.related_topics ?? [],
related_publications: raw.related_publications ?? [],
};
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. We're intentionally not wrapping these fields with wrapWebContent for now.

The engine google_news returns the raw SerpApi result objects as structured JSON.

Comment thread src/tools/scholar.ts
Comment on lines +3 to +7
import {
jsonResult,
readNumberParam,
readStringParam,
} from "openclaw/plugin-sdk/provider-web-search";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. We're intentionally not wrapping these fields with wrapWebContent for now.

The engine google_scholar returns the raw SerpApi result objects as structured JSON.

Comment thread src/tools/scholar.ts
Comment on lines +26 to +35
function extract(raw: Record<string, unknown>, maxCount: number): Record<string, unknown> {
const results = Array.isArray(raw.organic_results)
? (raw.organic_results as unknown[]).slice(0, maxCount)
: [];
return {
engine: "google_scholar",
results,
related_searches: raw.related_searches ?? [],
};
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. We're intentionally not wrapping these fields with wrapWebContent for now.

The engine google_scholar returns the raw SerpApi result objects as structured JSON.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 4 comments.

Comment thread src/tools/trends.ts
Comment on lines +65 to +68
cat: {
type: "string",
description: "Search category ID (default: 0 = all categories).",
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread src/tools/trends.ts Outdated
Comment thread src/tools/hotels.ts
Comment thread src/tools/flights.ts Outdated
Comment on lines +74 to +78
return_date: readStringParam(args, "return_date") ?? undefined,
type: readStringParam(args, "type") ?? undefined,
adults: readNumberParam(args, "adults", { integer: true }) ?? undefined,
currency: readStringParam(args, "currency") ?? undefined,
gl: readStringParam(args, "gl") ?? undefined,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The currency param now defaults to USD.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 6 comments.

Comment thread src/tools/trends.ts Outdated
Comment thread src/tools/maps-reviews.ts
Comment on lines +117 to +123
const nextPageToken = readStringParam(args, "next_page_token");
const num = readNumberParam(args, "num", { integer: true }) ?? undefined;
if (num !== undefined && !nextPageToken && !topicId && !query) {
throw new Error(
"serpapi_maps_reviews: num cannot be used on the initial page without next_page_token, topic_id, or query",
);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread src/tools/duckduckgo.ts
const cfg = resolveToolConfig(api, ctx);
const searchAssist = readBooleanArg(args, "search_assist");
const searchAssistParam = searchAssist === true ? "true" : undefined;
const m = readNumberParam(args, "m", { integer: true });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread src/tools/bing.ts
mkt: mkt ?? undefined,
cc: cc ?? undefined,
location: readStringParam(args, "location") ?? undefined,
safeSearch: readStringParam(args, "safeSearch") ?? undefined,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread src/tools/tripadvisor.ts Outdated
Comment thread src/tools/lens.ts
allowedParams: ALLOWED_PARAMS,
params: {
url: readStringParam(args, "url", { required: true }),
type: readStringParam(args, "type") ?? undefined,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.

Comment thread src/tools/amazon.ts
Comment on lines +53 to +61
enum: [
"relevanceblender",
"relevanceblender",
"price-asc-rank",
"price-desc-rank",
"review-rank",
"date-desc-rank",
"exact-aware-popularity-rank",
],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.

Comment thread src/tools/yahoo.ts
Comment on lines +35 to +38
engine: "yahoo",
results: organicResults,
related_searches: raw.related_searches ?? null,
serpapi_pagination: raw.serpapi_pagination ?? null,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants