search_cpu
Find compatible CPUs by socket type, core count, and price to optimize PC builds. Sort results by budget or performance needs to streamline component selection for custom systems.
Instructions
Specialized CPU/processor search tool. Find CPUs by socket compatibility, core count, and sort by price. Best for building compatible systems or finding CPUs with specific performance characteristics.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cores | No | Number of physical CPU cores (not threads). Common values: 4, 6, 8, 10, 12, 16, 24, 32. Example: 6 for hex-core CPUs | |
| limit | No | Maximum results to return. Valid range: 1-50, default: 10. Use higher values to see more options | |
| socket | No | CPU socket type for motherboard compatibility. Intel examples: '1700' (12-14th gen), '1851' (Core Ultra). AMD examples: 'AM5' (Ryzen 7000/8000/9000), 'AM4' (older Ryzen) | |
| sort_by | No | Price sorting order. 'price_asc' = cheapest first (budget builds), 'price_desc' = most expensive first (high-end builds) |
Implementation Reference
- src/index.ts:329-430 (handler)The primary handler function executing the 'search_cpu' tool. It searches CPU products by socket and cores, applies sorting and limits, and formats results as JSON.private searchCPU(args: any) { const { socket, cores, sort_by, limit = 10 } = args; const results: any[] = []; // Find CPU category const cpuCategory = this.productData.find(cat => cat.category_name.includes('CPU') || cat.category_name.includes('處理器') ); if (!cpuCategory) { return { content: [ { type: "text", text: JSON.stringify({ error: "CPU category not found", results: [] }, null, 2), }, ], }; } // Search through all CPU subcategories for (const subcat of cpuCategory.subcategories) { for (const product of subcat.products) { let matches = true; // Filter by socket if specified if (socket) { const socketLower = socket.toLowerCase(); const subcatLower = subcat.name.toLowerCase(); const specsText = product.specs.join(' ').toLowerCase(); const rawTextLower = product.raw_text.toLowerCase(); if (!subcatLower.includes(socketLower) && !specsText.includes(socketLower) && !rawTextLower.includes(socketLower)) { matches = false; } } // Filter by cores if specified if (cores && matches) { const corePattern = new RegExp(`${cores}核`, 'i'); const specsText = product.specs.join(' '); const hasCore = corePattern.test(specsText) || corePattern.test(product.raw_text) || corePattern.test(subcat.name); if (!hasCore) { matches = false; } } if (matches) { results.push({ ...product, category_name: cpuCategory.category_name, subcategory_name: subcat.name, }); } } } // Sort results if (sort_by === 'price_asc') { results.sort((a, b) => a.price - b.price); } else if (sort_by === 'price_desc') { results.sort((a, b) => b.price - a.price); } // Apply limit const limitedResults = results.slice(0, limit); return { content: [ { type: "text", text: JSON.stringify({ total_found: results.length, showing: limitedResults.length, filters: { socket: socket || "any", cores: cores || "any", sort_by: sort_by || "none" }, results: limitedResults.map(p => ({ brand: p.brand, model: p.model, specs: p.specs, price: p.price, original_price: p.original_price, discount_amount: p.discount_amount, subcategory: p.subcategory_name, markers: p.markers, })), }, null, 2), }, ], }; }
- src/index.ts:115-140 (schema)Schema definition for the 'search_cpu' tool, specifying input parameters: socket, cores, sort_by, and limit.{ name: "search_cpu", description: "Specialized CPU/processor search tool. Find CPUs by socket compatibility, core count, and sort by price. Best for building compatible systems or finding CPUs with specific performance characteristics.", inputSchema: { type: "object", properties: { socket: { type: "string", description: "CPU socket type for motherboard compatibility. Intel examples: '1700' (12-14th gen), '1851' (Core Ultra). AMD examples: 'AM5' (Ryzen 7000/8000/9000), 'AM4' (older Ryzen)", }, cores: { type: "number", description: "Number of physical CPU cores (not threads). Common values: 4, 6, 8, 10, 12, 16, 24, 32. Example: 6 for hex-core CPUs", }, sort_by: { type: "string", enum: ["price_asc", "price_desc"], description: "Price sorting order. 'price_asc' = cheapest first (budget builds), 'price_desc' = most expensive first (high-end builds)", }, limit: { type: "number", description: "Maximum results to return. Valid range: 1-50, default: 10. Use higher values to see more options", }, }, }, },
- src/index.ts:307-308 (registration)Registration of the 'search_cpu' handler in the tool dispatch switch statement within CallToolRequestSchema handler.case "search_cpu": return this.searchCPU(args);