list_manufacturers
Retrieve filament manufacturers from a 3D printing database, optionally filtered by material type like PLA or PETG, to help users find suitable suppliers for their printing projects.
Instructions
List all filament manufacturers in the database, with filament counts. Optionally filter to manufacturers that produce a specific material type.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| material | No | Filter to manufacturers that produce this material type (e.g., "PLA", "PETG") |
Implementation Reference
- src/tools/list-manufacturers.ts:25-48 (handler)The handler function that executes the list_manufacturers tool logic.
async ({ material }) => { const manufacturers = listManufacturers(db, material); const lines: string[] = []; if (material) { lines.push( `${manufacturers.length} manufacturer${manufacturers.length === 1 ? '' : 's'} producing ${material}:\n`, ); } else { lines.push( `${manufacturers.length} manufacturer${manufacturers.length === 1 ? '' : 's'}:\n`, ); } lines.push('| Manufacturer | Filaments |'); lines.push('|---|---|'); for (const m of manufacturers) { lines.push(`| ${m.name} | ${m.filament_count} |`); } return { content: [{ type: 'text' as const, text: lines.join('\n') }], }; }, - src/tools/list-manufacturers.ts:6-50 (registration)Registration of the list_manufacturers tool with the MCP server.
export function registerListManufacturers( server: McpServer, db: Database.Database, ): void { server.registerTool( 'list_manufacturers', { title: 'List Manufacturers', description: 'List all filament manufacturers in the database, with filament counts. Optionally filter to manufacturers that produce a specific material type.', inputSchema: { material: z .string() .optional() .describe( 'Filter to manufacturers that produce this material type (e.g., "PLA", "PETG")', ), }, }, async ({ material }) => { const manufacturers = listManufacturers(db, material); const lines: string[] = []; if (material) { lines.push( `${manufacturers.length} manufacturer${manufacturers.length === 1 ? '' : 's'} producing ${material}:\n`, ); } else { lines.push( `${manufacturers.length} manufacturer${manufacturers.length === 1 ? '' : 's'}:\n`, ); } lines.push('| Manufacturer | Filaments |'); lines.push('|---|---|'); for (const m of manufacturers) { lines.push(`| ${m.name} | ${m.filament_count} |`); } return { content: [{ type: 'text' as const, text: lines.join('\n') }], }; }, ); } - src/data/db.ts:186-210 (helper)Database helper function that retrieves the list of manufacturers.
export function listManufacturers( db: Database.Database, materialFilter?: string, ): ManufacturerRow[] { if (materialFilter) { return db .prepare( `SELECT m.*, COUNT(f.id) AS filament_count FROM manufacturers m JOIN filaments f ON f.manufacturer_id = m.id WHERE f.material_name = ? GROUP BY m.id ORDER BY m.name`, ) .all(materialFilter) as ManufacturerRow[]; } return db .prepare( `SELECT m.*, COUNT(f.id) AS filament_count FROM manufacturers m JOIN filaments f ON f.manufacturer_id = m.id GROUP BY m.id ORDER BY m.name`, ) .all() as ManufacturerRow[];