/** * Search Tool */ import { getPayloadClient } from '../client.js'; export async function searchTool(args: any) { if (!args.query) { throw new Error('Search query is required'); } try { const client = await getPayloadClient(); const response = await client.search.list({ query: args.query, collections: args.collections, limit: args.limit || 20, }); return { success: true, data: response, query: args.query, message: `Found ${response.docs?.length || 0} results`, }; } catch (error: any) { throw new Error(`Search failed: ${error.message}`); } }