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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/list-materials.ts:16-41 (handler)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') }], }; }, - src/tools/list-materials.ts:5-43 (registration)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') }], }; }, ); } - src/data/db.ts:222-232 (helper)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[]; }