search_google_images
Search Google Images through the SearchAPI MCP Server to find relevant pictures with titles, thumbnails, and source links using a query.
Instructions
Performs a Google image search using SearchAPI.site. Requires a search query and your SearchAPI.site API key. Returns formatted image search results including titles, thumbnails, and source links.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The image search query to perform | |
| limit | No | Maximum number of results to return (1-100) | |
| offset | No | Offset for pagination | |
| sort | No | Sort order (e.g., "date:d" for newest first) | |
| from_date | No | Start date for filtering results (format: YYYY-MM-DD) | |
| to_date | No | End date for filtering results (format: YYYY-MM-DD) |
Implementation Reference
- src/tools/searchapi.tool.ts:62-98 (handler)The main handler function for the 'search_google_images' MCP tool. It processes input arguments, calls the searchApiController.googleImageSearch, and returns formatted content or error for the MCP protocol.async function handleGoogleImageSearch(args: GoogleImageSearchToolArgsType) { const methodLogger = Logger.forContext( 'tools/searchapi.tool.ts', 'handleGoogleImageSearch', ); methodLogger.debug( `Performing Google image search for query: ${args.query}`, ); try { // Map tool arguments to controller options const controllerOptions = { query: args.query, }; // Call the controller with the mapped options const result = await searchApiController.googleImageSearch(controllerOptions); methodLogger.debug(`Got the response from the controller`, result); // Format the response for the MCP tool return { content: [ { type: 'text' as const, text: result.content, }, ], }; } catch (error) { methodLogger.error( `Error performing Google image search for query: ${args.query}`, error, ); return formatErrorForMcpTool(error); } }
- src/tools/searchapi.types.ts:43-65 (schema)Zod schema defining the input arguments for the search_google_images tool, used in the MCP tool registration.export const GoogleImageSearchToolArgs = z.object({ query: z.string().describe('The image search query to perform'), // apiKey: z.string().optional().describe('Your SearchAPI.site API key'), limit: z .number() .min(1) .max(100) .optional() .describe('Maximum number of results to return (1-100)'), offset: z.number().min(0).optional().describe('Offset for pagination'), sort: z .string() .optional() .describe('Sort order (e.g., "date:d" for newest first)'), from_date: z .string() .optional() .describe('Start date for filtering results (format: YYYY-MM-DD)'), to_date: z .string() .optional() .describe('End date for filtering results (format: YYYY-MM-DD)'), });
- src/tools/searchapi.tool.ts:170-179 (registration)MCP server registration of the 'search_google_images' tool, specifying name, description, input schema, and handler function.// Register Google image search tool server.tool( 'search_google_images', `Performs a Google image search using SearchAPI.site. Requires a search query and your SearchAPI.site API key. Returns formatted image search results including titles, thumbnails, and source links. `, GoogleImageSearchToolArgs.shape, handleGoogleImageSearch, );