bos_cart_update_item
Adjust the quantity of an item in a cart. Specify the item ID and the new quantity to update.
Instructions
Update cart item quantity
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item_id | Yes | ||
| quantity | Yes |
Implementation Reference
- src/tools/bos.ts:236-239 (handler)Handler function that extracts item_id from args and sends a PUT request to /mcp/cart/items/{item_id} with the remaining data (quantity).
handler: async (args, client) => { const { item_id, ...data } = args; return client.put(`/mcp/cart/items/${item_id}`, data); }, - src/tools/bos.ts:235-235 (schema)Input schema requiring item_id (string) and quantity (number).
schema: { item_id: { type: 'string' }, quantity: { type: 'number' } }, - src/index.ts:55-76 (registration)Tool registration loop: all tools (including bos_cart_update_item via cartTools) are registered with the McpServer, converting the simple schema to Zod and invoking the handler.
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)Helper function that converts the simple schema format (used in tool definitions like bos_cart_update_item) to Zod schemas for MCP SDK validation.
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); } - src/tools/bos.ts:214-265 (registration)The cartTools array definition containing bos_cart_update_item as one of 7 cart tools. This array is exported and later spread into allTools in src/index.ts.
export const cartTools: McpTool[] = [ { name: 'bos_cart_get', description: 'Get current user cart', schema: {}, handler: async (_, client) => client.get('/mcp/cart'), }, { name: 'bos_cart_add_item', description: 'Add item to cart', schema: { product_id: { type: 'string' }, quantity: { type: 'number' }, variant_id: { type: 'string', optional: true }, notes: { type: 'string', optional: true }, }, handler: async (args, client) => client.post('/mcp/cart/items', args), }, { name: 'bos_cart_update_item', description: 'Update cart item quantity', schema: { item_id: { type: 'string' }, quantity: { type: 'number' } }, handler: async (args, client) => { const { item_id, ...data } = args; return client.put(`/mcp/cart/items/${item_id}`, data); }, }, { name: 'bos_cart_remove_item', description: 'Remove item from cart', schema: { item_id: { type: 'string' } }, handler: async (args, client) => client.delete(`/mcp/cart/items/${args.item_id}`), }, { name: 'bos_cart_clear', description: 'Clear all items from cart', schema: {}, handler: async (_, client) => client.delete('/mcp/cart'), }, { name: 'bos_cart_apply_voucher', description: 'Apply voucher code to cart', schema: { voucher_code: { type: 'string' } }, handler: async (args, client) => client.post('/mcp/cart/apply-voucher', args), }, { name: 'bos_cart_remove_voucher', description: 'Remove voucher from cart', schema: {}, handler: async (_, client) => client.delete('/mcp/cart/voucher'), }, ];