Skip to main content
Glama

list_materials

Retrieve available 3D printing material types like PLA, PETG, and ABS with filament counts and typical print settings from a comprehensive database.

Instructions

List all material types available in the database (PLA, PETG, ABS, TPU, Nylon, etc.) with filament counts and typical print settings. No inputs required.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool handler logic for 'list_materials', which fetches material data and formats it as a markdown table.
    async () => {
      const materials = listMaterials(db);
    
      // Sort by count descending
      materials.sort((a, b) => b.filament_count - a.filament_count);
    
      const lines: string[] = [];
      lines.push(
        `${materials.length} material type${materials.length === 1 ? '' : 's'}:\n`,
      );
    
      lines.push('| Material | Filaments | Density | Extruder Temp | Bed Temp |');
      lines.push('|---|---|---|---|---|');
      for (const m of materials) {
        const density = m.density != null ? `${m.density} g/cm³` : '-';
        const extruder = m.extruder_temp != null ? `${m.extruder_temp}°C` : '-';
        const bed = m.bed_temp != null ? `${m.bed_temp}°C` : '-';
        lines.push(
          `| ${m.name} | ${m.filament_count} | ${density} | ${extruder} | ${bed} |`,
        );
      }
    
      return {
        content: [{ type: 'text' as const, text: lines.join('\n') }],
      };
    },
  • Registration function for the 'list_materials' tool within the MCP server.
    export function registerListMaterials(
      server: McpServer,
      db: Database.Database,
    ): void {
      server.registerTool(
        'list_materials',
        {
          title: 'List Materials',
          description:
            'List all material types available in the database (PLA, PETG, ABS, TPU, Nylon, etc.) with filament counts and typical print settings. No inputs required.',
        },
        async () => {
          const materials = listMaterials(db);
    
          // Sort by count descending
          materials.sort((a, b) => b.filament_count - a.filament_count);
    
          const lines: string[] = [];
          lines.push(
            `${materials.length} material type${materials.length === 1 ? '' : 's'}:\n`,
          );
    
          lines.push('| Material | Filaments | Density | Extruder Temp | Bed Temp |');
          lines.push('|---|---|---|---|---|');
          for (const m of materials) {
            const density = m.density != null ? `${m.density} g/cm³` : '-';
            const extruder = m.extruder_temp != null ? `${m.extruder_temp}°C` : '-';
            const bed = m.bed_temp != null ? `${m.bed_temp}°C` : '-';
            lines.push(
              `| ${m.name} | ${m.filament_count} | ${density} | ${extruder} | ${bed} |`,
            );
          }
    
          return {
            content: [{ type: 'text' as const, text: lines.join('\n') }],
          };
        },
      );
    }
  • The underlying database query function used by the 'list_materials' tool to fetch material information.
    export function listMaterials(db: Database.Database): MaterialRow[] {
      return db
        .prepare(
          `SELECT mat.*, COUNT(f.id) AS filament_count
           FROM materials mat
           JOIN filaments f ON f.material_id = mat.id
           GROUP BY mat.id
           ORDER BY mat.name`,
        )
        .all() as MaterialRow[];
    }

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