Skip to main content
Glama

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
NameRequiredDescriptionDefault
materialNoFilter to manufacturers that produce this material type (e.g., "PLA", "PETG")

Implementation Reference

  • 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') }],
      };
    },
  • 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') }],
          };
        },
      );
    }
  • 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[];

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