create_ingredient
Add new ingredients or products to Inflow inventory system by providing product details like name, SKU, and description for inventory management.
Instructions
Create a new ingredient/product in Inflow inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| additionalFields | No | Any additional product fields | |
| description | No | Product description | |
| isActive | No | Active status (default: true) | |
| name | Yes | Product name | |
| productId | Yes | UUID for the new product (generate with crypto.randomUUID()) | |
| sku | No | SKU code |
Implementation Reference
- src/handlers/product-handlers.js:110-135 (handler)Main handler function for creating an ingredient/product. Validates required fields (productId, name), constructs the product object, and delegates to InflowClient.upsertProduct for the API call.async createProduct(client, args) { if (!args.productId) { return { success: false, error: 'productId is required (generate a UUID)' }; } if (!args.name) { return { success: false, error: 'name is required' }; } const product = { productId: args.productId, name: args.name, sku: args.sku, description: args.description, isActive: args.isActive !== undefined ? args.isActive : true, ...args.additionalFields }; return await client.upsertProduct(product); },
- index.js:158-165 (schema)Zod input schema defining parameters for the create_ingredient tool: productId (required UUID), name (required), and optional fields like sku, description, isActive, additionalFields.inputSchema: { productId: z.string().describe('UUID for the new product (generate with crypto.randomUUID())'), name: z.string().describe('Product name'), sku: z.string().optional().describe('SKU code'), description: z.string().optional().describe('Product description'), isActive: z.boolean().optional().describe('Active status (default: true)'), additionalFields: z.record(z.any()).optional().describe('Any additional product fields') }
- index.js:154-178 (registration)Registers the 'create_ingredient' MCP tool with the server, providing description, input schema, and a thin async handler that calls productHandlers.createProduct and formats the response.server.registerTool( 'create_ingredient', { description: 'Create a new ingredient/product in Inflow inventory', inputSchema: { productId: z.string().describe('UUID for the new product (generate with crypto.randomUUID())'), name: z.string().describe('Product name'), sku: z.string().optional().describe('SKU code'), description: z.string().optional().describe('Product description'), isActive: z.boolean().optional().describe('Active status (default: true)'), additionalFields: z.record(z.any()).optional().describe('Any additional product fields') } }, async (args) => { const result = await productHandlers.createProduct(inflowClient, args); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; } );
- src/inflow-client.js:123-144 (helper)Supporting utility in InflowClient that performs the HTTP PUT request to the Inflow API endpoint for creating or updating a product/ingredient, with error handling.async upsertProduct(product) { try { if (!product.productId) { return { success: false, error: 'productId is required for upsert' }; } const response = await this.client.put( `/${this.config.companyId}/products`, product ); return { success: true, data: response.data }; } catch (error) { return this._handleError(error, 'upsertProduct'); } }