List Materials
list_materialsList all 3D printing material types from the database, including PLA, PETG, ABS, TPU, and Nylon, with filament counts and typical print settings.
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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/list-materials.ts:5-42 (handler)The registerListMaterials function registers the 'list_materials' tool on the MCP server. The handler (lines 16-41) invokes listMaterials(db), sorts results by filament count descending, and formats them into a markdown table as text output.
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/tools/list-materials.ts:11-15 (schema)The tool schema defines 'title' and 'description' metadata, with no input parameters. It states the tool lists material types with filament counts and print settings.
{ 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.', }, - src/server.ts:46-46 (registration)The tool is registered on the server in createServer() by calling registerListMaterials(server, db).
registerListMaterials(server, db); - src/data/db.ts:248-258 (helper)The listMaterials function in db.ts is the data access layer. It queries the database joining 'materials' with 'filaments' to get each material's filament count, returning MaterialRow objects sorted by name.
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[]; } - src/data/db.ts:239-246 (schema)The MaterialRow interface defines the shape of data returned by the helper: id, name, density, extruder_temp, bed_temp, and filament_count.
export interface MaterialRow { id: number; name: string; density: number | null; extruder_temp: number | null; bed_temp: number | null; filament_count: number; }