update_stock
Update product inventory quantities in the art supply store system after receiving shipments, sales, or physical counts. Records stock changes with reason codes for accurate inventory tracking.
Instructions
Update inventory quantity after receiving shipment or doing physical count. Records the change in the system.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| quantity | Yes | New quantity amount | |
| reason | Yes | Reason for update (received, sold, damaged, count) | |
| sku | Yes | Product SKU to update |
Implementation Reference
- src/index.ts:610-630 (handler)The core handler logic for the 'update_stock' tool. It validates the SKU, updates the quantity in the mock inventory database, calculates the delta, records the reason, and returns a detailed confirmation message with reorder level status.case 'update_stock': { const sku = String(args?.sku || ''); const quantity = Number(args?.quantity || 0); const reason = String(args?.reason || 'manual update'); const item = storeData.inventory.find(i => i.id === sku); if (!item) { return { content: [{ type: 'text', text: `❌ Product ${sku} not found` }] }; } const oldQty = item.quantity; item.quantity = quantity; const diff = quantity - oldQty; return { content: [{ type: 'text', text: `✅ Stock updated for ${item.name}\n- Previous: ${oldQty} units\n- New: ${quantity} units\n- Change: ${diff > 0 ? '+' : ''}${diff} units\n- Reason: ${reason}\n- ${quantity <= item.reorderLevel ? '⚠️ Now below reorder level!' : 'Stock level OK'}` }] }; }
- src/index.ts:89-101 (schema)The tool schema definition, including name, description, and input validation schema specifying required parameters: sku (string), quantity (number), and reason (string). This is used for tool listing and input validation in MCP.{ name: 'update_stock', description: 'Update inventory quantity after receiving shipment or doing physical count. Records the change in the system.', inputSchema: { type: 'object', properties: { sku: { type: 'string', description: 'Product SKU to update' }, quantity: { type: 'number', description: 'New quantity amount' }, reason: { type: 'string', description: 'Reason for update (received, sold, damaged, count)' }, }, required: ['sku', 'quantity', 'reason'], }, },
- src/index.ts:516-518 (registration)Registers the 'update_stock' tool (included in the 'tools' array) for discovery via the ListToolsRequestHandler in the MCP server.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/dashboard.ts:37-37 (registration)Mock tool registration in the dashboard server for displaying available tools in the web UI (not the actual MCP implementation).{ name: 'update_stock', description: 'Update inventory quantities', category: 'Inventory Management' },