Skip to main content
Glama

Recommend Material

recommend_material

Select project requirements like strength, flexibility, heat resistance, food safety, outdoor use, ease of printing, and budget to get ranked material suggestions with explanations.

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 async handler function that receives user requirements, scores all materials using helper scoring functions, sorts by score, and returns formatted recommendations.
      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 r = scoreFlexibility(profile, requirements.flexibility);
            score += r.score;
            reasons.push(r.reason);
          }
    
          if (requirements.heat_resistance) {
            const r = scoreHeatResistance(profile, requirements.heat_resistance);
            score += r.score;
            reasons.push(r.reason);
            if (r.caveat) {
              caveats.push(r.caveat);
            }
          }
    
          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 <= pct(0.2, WEIGHTS.outdoor)) {
              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) {
            const r = scoreBudget(profile, requirements.budget);
            score += r.score;
            reasons.push(r.reason);
          }
    
          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 definition for the recommend_material tool, defining all optional requirements fields (strength, flexibility, heat_resistance, food_safe, outdoor_use, ease_of_printing, budget) with Zod enums.
    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'),
    },
  • The registerRecommendMaterial function that registers the tool named 'recommend_material' on the MCP server with its schema and handler.
    export function registerRecommendMaterial(
      server: McpServer,
      db: Database.Database,
    ): void {
      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.',
          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'),
          },
        },
        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 r = scoreFlexibility(profile, requirements.flexibility);
              score += r.score;
              reasons.push(r.reason);
            }
    
            if (requirements.heat_resistance) {
              const r = scoreHeatResistance(profile, requirements.heat_resistance);
              score += r.score;
              reasons.push(r.reason);
              if (r.caveat) {
                caveats.push(r.caveat);
              }
            }
    
            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 <= pct(0.2, WEIGHTS.outdoor)) {
                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) {
              const r = scoreBudget(profile, requirements.budget);
              score += r.score;
              reasons.push(r.reason);
            }
    
            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') }] };
        },
      );
    }
  • src/server.ts:16-16 (registration)
    Import of registerRecommendMaterial from the recommend-material module.
    import { registerRecommendMaterial } from './tools/recommend-material.js';
  • src/server.ts:49-49 (registration)
    Call to registerRecommendMaterial to wire up the tool in the server.
    registerRecommendMaterial(server, db);
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses that the output will be 'ranked material suggestions with explanations', which is transparent about the behavior. No contradictions or omissions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences front-load the purpose and usage. Every word is meaningful with no redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the single nested parameter with full schema descriptions and no output schema, the description adequately covers input expectations and output format (ranked suggestions with explanations). No critical missing info.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds natural language listing of the requirement properties, but does not provide additional meaning beyond what the schema already describes.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'recommend' and the resource '3D printing material based on project requirements', which distinguishes it from sibling tools that list, compare, or search materials.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use the tool: when you have project requirements and need a recommendation. It lists the criteria to describe, providing clear context, but does not explicitly mention when not to use it or name alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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