search_products
Search for computer components by keyword, category, or price range to find matching products. Use this tool to explore a wide range of options when building or upgrading a PC with CoolPC MCP Server.
Instructions
General search across all computer components. Use this for broad searches or when component type is uncertain. For specific components, use dedicated search tools (search_cpu, search_gpu, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Filter by product category. Examples: 'CPU', 'GPU', 'RAM', 'SSD', 'MB' (motherboard). Leave empty to search all categories | |
| keyword | Yes | Search keyword - can be brand name (Intel, AMD, NVIDIA), model number, or specifications. Examples: 'Intel', 'RTX', '32GB', 'B650' | |
| limit | No | Maximum number of results to return. Valid range: 1-100, default: 10 | |
| max_price | No | Maximum price in TWD. Example: 20000 for products under NT$20,000 | |
| min_price | No | Minimum price in TWD. Example: 5000 for products above NT$5,000 |
Implementation Reference
- src/index.ts:893-960 (handler)The handler function that implements the core logic for searching products. It iterates through all product categories and subcategories, matches products based on keyword in brand/model/specs/raw_text, applies price filters, limits results, and returns JSON-formatted results.private searchProducts(args: any) { const { keyword, category, min_price, max_price, limit = 10 } = args; const results: any[] = []; for (const cat of this.productData) { if (category && !cat.category_name.toLowerCase().includes(category.toLowerCase())) { continue; } for (const subcat of cat.subcategories) { for (const product of subcat.products) { const searchText = `${product.brand} ${product.model} ${product.specs.join(" ")} ${product.raw_text}`.toLowerCase(); if (!searchText.includes(keyword.toLowerCase())) { continue; } if (min_price && product.price < min_price) { continue; } if (max_price && product.price > max_price) { continue; } results.push({ ...product, category_name: cat.category_name, subcategory_name: subcat.name, }); if (results.length >= limit) { break; } } if (results.length >= limit) { break; } } if (results.length >= limit) { break; } } return { content: [ { type: "text", text: JSON.stringify({ total_found: results.length, results: results.map(p => ({ brand: p.brand, model: p.model, specs: p.specs, price: p.price, original_price: p.original_price, discount_amount: p.discount_amount, category: p.category_name, subcategory: p.subcategory_name, markers: p.markers, })), }, null, 2), }, ], }; }
- src/index.ts:88-113 (schema)Input schema defining the parameters for the search_products tool: keyword (required), category, min_price, max_price, limit.inputSchema: { type: "object", properties: { keyword: { type: "string", description: "Search keyword - can be brand name (Intel, AMD, NVIDIA), model number, or specifications. Examples: 'Intel', 'RTX', '32GB', 'B650'", }, category: { type: "string", description: "Filter by product category. Examples: 'CPU', 'GPU', 'RAM', 'SSD', 'MB' (motherboard). Leave empty to search all categories", }, min_price: { type: "number", description: "Minimum price in TWD. Example: 5000 for products above NT$5,000", }, max_price: { type: "number", description: "Maximum price in TWD. Example: 20000 for products under NT$20,000", }, limit: { type: "number", description: "Maximum number of results to return. Valid range: 1-100, default: 10", }, }, required: ["keyword"], },
- src/index.ts:85-114 (registration)The tool object registration in the ListTools response, including name, description, and input schema.{ name: "search_products", description: "General search across all computer components. Use this for broad searches or when component type is uncertain. For specific components, use dedicated search tools (search_cpu, search_gpu, etc.)", inputSchema: { type: "object", properties: { keyword: { type: "string", description: "Search keyword - can be brand name (Intel, AMD, NVIDIA), model number, or specifications. Examples: 'Intel', 'RTX', '32GB', 'B650'", }, category: { type: "string", description: "Filter by product category. Examples: 'CPU', 'GPU', 'RAM', 'SSD', 'MB' (motherboard). Leave empty to search all categories", }, min_price: { type: "number", description: "Minimum price in TWD. Example: 5000 for products above NT$5,000", }, max_price: { type: "number", description: "Maximum price in TWD. Example: 20000 for products under NT$20,000", }, limit: { type: "number", description: "Maximum number of results to return. Valid range: 1-100, default: 10", }, }, required: ["keyword"], }, },
- src/index.ts:304-306 (helper)Dispatcher switch case in CallToolRequestHandler that routes calls to the searchProducts handler.switch (name) { case "search_products": return this.searchProducts(args);