search_ram
Find compatible RAM for PC builds or upgrades by specifying DDR generation, capacity, speed, and budget to compare available options.
Instructions
Specialized memory (RAM) search tool. Find desktop or laptop memory by DDR generation, total capacity, speed, and price. Essential for system upgrades or new builds.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | RAM generation/type. Options: 'DDR4' (older systems, cheaper), 'DDR5' (newest, faster). Must match motherboard compatibility | |
| capacity | No | Total memory capacity in GB. Common values: 8, 16, 32, 64. Example: 32 for 32GB total (can be 2x16GB or 4x8GB kit) | |
| frequency | No | Memory speed in MHz. DDR4 common: 3200, 3600. DDR5 common: 4800, 5600, 6000. Higher = better performance | |
| sort_by | No | Price sorting order. 'price_asc' = budget options first, 'price_desc' = premium/performance kits first | |
| limit | No | Maximum results to return. Valid range: 1-50, default: 10. More results = more brand choices |
Implementation Reference
- src/index.ts:537-651 (handler)The primary handler function for the 'search_ram' tool. It filters RAM products from the loaded product data based on parameters like type (DDR4/DDR5), capacity (GB), frequency (MHz), applies sorting and limiting, and returns JSON-formatted results.private searchRAM(args: any) { const { type, capacity, frequency, sort_by, limit = 10 } = args; const results: any[] = []; // Find RAM category const ramCategory = this.productData.find(cat => cat.category_name.includes('記憶體') || cat.category_name.includes('RAM') ); if (!ramCategory) { return { content: [ { type: "text", text: JSON.stringify({ error: "RAM category not found", results: [] }, null, 2), }, ], }; } // Search through all RAM subcategories for (const subcat of ramCategory.subcategories) { for (const product of subcat.products) { let matches = true; // Filter by type if specified (DDR4, DDR5) if (type && matches) { const typeLower = type.toLowerCase(); const subcatLower = subcat.name.toLowerCase(); const specsText = product.specs.join(' ').toLowerCase(); const rawTextLower = product.raw_text.toLowerCase(); if (!subcatLower.includes(typeLower) && !specsText.includes(typeLower) && !rawTextLower.includes(typeLower)) { matches = false; } } // Filter by capacity if specified if (capacity && matches) { const capPattern = new RegExp(`${capacity}GB`, 'i'); const specsText = product.specs.join(' '); const hasCapacity = capPattern.test(specsText) || capPattern.test(product.raw_text) || capPattern.test(product.model || ''); if (!hasCapacity) { matches = false; } } // Filter by frequency if specified if (frequency && matches) { const freqPattern = new RegExp(`${frequency}(?:MHz)?`, 'i'); const specsText = product.specs.join(' '); const hasFrequency = freqPattern.test(specsText) || freqPattern.test(product.raw_text); if (!hasFrequency) { matches = false; } } if (matches) { results.push({ ...product, category_name: ramCategory.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: { type: type || "any", capacity: capacity || "any", frequency: frequency || "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:167-196 (schema)The tool schema definition including name, description, and inputSchema for parameters: type, capacity, frequency, sort_by, limit. Returned by ListToolsRequestHandler.{ name: "search_ram", description: "Specialized memory (RAM) search tool. Find desktop or laptop memory by DDR generation, total capacity, speed, and price. Essential for system upgrades or new builds.", inputSchema: { type: "object", properties: { type: { type: "string", description: "RAM generation/type. Options: 'DDR4' (older systems, cheaper), 'DDR5' (newest, faster). Must match motherboard compatibility", }, capacity: { type: "number", description: "Total memory capacity in GB. Common values: 8, 16, 32, 64. Example: 32 for 32GB total (can be 2x16GB or 4x8GB kit)", }, frequency: { type: "number", description: "Memory speed in MHz. DDR4 common: 3200, 3600. DDR5 common: 4800, 5600, 6000. Higher = better performance", }, sort_by: { type: "string", enum: ["price_asc", "price_desc"], description: "Price sorting order. 'price_asc' = budget options first, 'price_desc' = premium/performance kits first", }, limit: { type: "number", description: "Maximum results to return. Valid range: 1-50, default: 10. More results = more brand choices", }, }, }, },
- src/index.ts:311-312 (registration)Registration in the CallToolRequestHandler switch statement: dispatches 'search_ram' calls to the searchRAM method.case "search_ram": return this.searchRAM(args);