Skip to main content
Glama

recommend_material

Select optimal 3D printing materials by specifying project requirements like strength, flexibility, heat resistance, and budget. Get ranked suggestions with explanations for informed material choices.

Instructions

Recommend the best 3D printing material based on project requirements. Describe what you need (strength, flexibility, heat resistance, food safety, outdoor use, ease of printing, budget) and get ranked material suggestions with explanations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requirementsYesProject requirements for material selection

Implementation Reference

  • The handler logic for the 'recommend_material' tool, which scores materials based on user requirements.
    async ({ requirements }) => {
      // Check if any requirements provided
      const hasRequirements = Object.values(requirements).some(
        (v) => v !== undefined && v !== null,
      );
      if (!hasRequirements) {
        return {
          isError: true,
          content: [
            {
              type: 'text' as const,
              text: 'Please provide at least one requirement (strength, flexibility, heat_resistance, food_safe, outdoor_use, ease_of_printing, or budget).',
            },
          ],
        };
      }
    
      const profiles = getAllMaterialProfiles(db);
      const scored: ScoredMaterial[] = profiles.map((profile) => {
        let score = 0;
        const reasons: string[] = [];
        const caveats: string[] = [];
    
        if (requirements.strength) {
          const r = scoreStrength(profile, requirements.strength);
          score += r.score;
          reasons.push(r.reason);
        }
    
        if (requirements.flexibility) {
          const flexMap: Record<string, string[]> = {
            rigid: ['low', 'none'],
            'semi-flexible': ['moderate', 'medium'],
            flexible: ['high', 'very high', 'flexible'],
          };
          const matches = flexMap[requirements.flexibility] ?? [];
          if (matches.includes(profile.flexibility.toLowerCase())) {
            score += 2;
            reasons.push(`Flexibility: ${profile.flexibility} (matches)`);
          } else {
            score -= 1;
            reasons.push(`Flexibility: ${profile.flexibility} (doesn't match ${requirements.flexibility})`);
          }
        }
    
        if (requirements.heat_resistance) {
          if (requirements.heat_resistance === 'high' && profile.enclosure_needed) {
            score += 2;
            reasons.push('High heat resistance (needs enclosure)');
          } else if (requirements.heat_resistance === 'high') {
            score -= 1;
            reasons.push('Limited heat resistance');
            caveats.push(profile.cons);
          } else {
            score += 1;
            reasons.push(`Heat resistance: suitable for ${requirements.heat_resistance} needs`);
          }
        }
    
        if (requirements.food_safe) {
          const r = scoreFoodSafe(profile);
          score += r.score;
          reasons.push(r.reason);
          if (r.score < 0) {
            caveats.push('Not suitable for food contact');
          }
        }
    
        if (requirements.outdoor_use) {
          const r = scoreOutdoor(profile);
          score += r.score;
          reasons.push(r.reason);
          if (r.score < 0) {
            caveats.push('Poor outdoor durability');
          }
        }
    
        if (requirements.ease_of_printing) {
          const r = scoreEase(profile, requirements.ease_of_printing);
          score += r.score;
          reasons.push(r.reason);
        }
    
        if (requirements.budget) {
          if (requirements.budget === 'low' && profile.difficulty === 'beginner') {
            score += 1;
            reasons.push('Budget-friendly (common beginner material)');
          } else if (requirements.budget === 'low') {
            score -= 1;
            reasons.push('May be more expensive than basic materials');
          } else {
            score += 1;
            reasons.push('Within budget range');
          }
        }
    
        return { profile, score, reasons, caveats };
      });
    
      // Sort by score descending
      scored.sort((a, b) => b.score - a.score);
    
      const lines = ['# Material Recommendations', ''];
      scored.forEach((s, i) => {
        lines.push(`${i + 1}. **${s.profile.material_name}** (score: ${s.score})`);
        for (const reason of s.reasons) {
          lines.push(`   - ${reason}`);
        }
        if (s.caveats.length > 0) {
          lines.push(`   - Caveats: ${s.caveats.join('; ')}`);
        }
        lines.push('');
      });
    
      return { content: [{ type: 'text' as const, text: lines.join('\n') }] };
    },
  • Input schema defining the parameters for the 'recommend_material' tool.
    inputSchema: {
      requirements: z.object({
        strength: z
          .enum(['low', 'medium', 'high'])
          .optional()
          .describe('Required mechanical strength'),
        flexibility: z
          .enum(['rigid', 'semi-flexible', 'flexible'])
          .optional()
          .describe('Required flexibility'),
        heat_resistance: z
          .enum(['low', 'medium', 'high'])
          .optional()
          .describe('Required heat resistance'),
        food_safe: z
          .boolean()
          .optional()
          .describe('Must be food-safe material'),
        outdoor_use: z
          .boolean()
          .optional()
          .describe('Will be used outdoors (needs UV resistance)'),
        ease_of_printing: z
          .enum(['beginner', 'intermediate', 'advanced'])
          .optional()
          .describe('Desired printing difficulty level'),
        budget: z
          .enum(['low', 'medium', 'high'])
          .optional()
          .describe('Budget constraint'),
      }).describe('Project requirements for material selection'),
    },
  • Tool registration for 'recommend_material'.
    server.registerTool(
      'recommend_material',
      {
        title: 'Recommend Material',
        description:
          'Recommend the best 3D printing material based on project requirements. Describe what you need (strength, flexibility, heat resistance, food safety, outdoor use, ease of printing, budget) and get ranked material suggestions with explanations.',

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gregario/3dprint-oracle'

If you have feedback or need assistance with the MCP directory API, please join our Discord server