bos_inventory_update
Adjust product inventory by setting, adding, or subtracting stock quantities. Record a reason for each inventory change to maintain accurate records.
Instructions
Update inventory stock
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | ||
| quantity | Yes | ||
| type | Yes | ||
| reason | No |
Implementation Reference
- src/tools/bos.ts:423-423 (handler)The handler function for bos_inventory_update that sends a POST request to /mcp/inventory/update with the args (product_id, quantity, type, reason).
handler: async (args, client) => client.post('/mcp/inventory/update', args), - src/tools/bos.ts:417-422 (schema)Input schema for bos_inventory_update: requires product_id (string), quantity (number), type (one of 'set', 'add', 'subtract'), and optional reason (string).
schema: { product_id: { type: 'string' }, quantity: { type: 'number' }, type: { type: 'string', enum: ['set', 'add', 'subtract'] }, reason: { type: 'string', optional: true }, }, - src/tools/bos.ts:397-431 (registration)The tool 'bos_inventory_update' is defined as part of the inventoryTools array in src/tools/bos.ts (lines 414-424). It is then exported and registered into the MCP server in src/index.ts, src/http.ts, and src/stdio.ts.
export const inventoryTools: McpTool[] = [ { name: 'bos_inventory_list', description: 'List inventory stock across all products', schema: { page: { type: 'number', optional: true }, page_size: { type: 'number', optional: true }, warehouse_id: { type: 'string', optional: true }, }, handler: async (args, client) => client.get('/mcp/inventory', args), }, { name: 'bos_inventory_check', description: 'Check stock quantity for a product', schema: { product_id: { type: 'string' } }, handler: async (args, client) => client.get(`/mcp/inventory/check/${args.product_id}`), }, { name: 'bos_inventory_update', description: 'Update inventory stock', schema: { product_id: { type: 'string' }, quantity: { type: 'number' }, type: { type: 'string', enum: ['set', 'add', 'subtract'] }, reason: { type: 'string', optional: true }, }, handler: async (args, client) => client.post('/mcp/inventory/update', args), }, { name: 'bos_inventory_low_stock', description: 'Get products with low stock alerts', schema: { threshold: { type: 'number', optional: true } }, handler: async (args, client) => client.get('/mcp/inventory/low-stock', args), }, ]; - src/index.ts:55-76 (registration)Registration loop in src/index.ts that registers all tools (including bos_inventory_update) with the MCP server via server.tool().
for (const tool of allTools) { const zodSchema = toZodSchema(tool.schema); server.tool( tool.name, tool.description, zodSchema.shape, async (args: any) => { try { const result = await tool.handler(args, client); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], }; } catch (error: any) { return { content: [{ type: 'text' as const, text: JSON.stringify({ error: error.message || 'Unknown error' }) }], isError: true, }; } } ); } - src/tools/index.ts:21-62 (helper)The toZodSchema helper converts the simple schema definition (e.g., type: 'string', enum: [...], optional: true) into a Zod schema used for validation at registration.
export function toZodSchema(schema: Record<string, any>): z.ZodObject<any> { const shape: Record<string, z.ZodTypeAny> = {}; for (const [key, def] of Object.entries(schema)) { let field: z.ZodTypeAny; switch (def.type) { case 'number': field = z.number(); break; case 'boolean': field = z.boolean(); break; case 'array': field = z.array(z.any()); break; case 'object': field = z.record(z.any()); break; case 'string': default: if (def.enum) { field = z.enum(def.enum); } else { field = z.string(); } break; } if (def.description) { field = field.describe(def.description); } if (def.optional) { field = field.optional(); } shape[key] = field; } return z.object(shape); }