fakestore_delete_cart
Remove a shopping cart from the Fake Store API simulation by specifying its ID. This action clears cart data for testing and demo purposes without persisting changes.
Instructions
Delete a cart (simulation - does not persist)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Cart ID to delete |
Implementation Reference
- src/tools/carts.ts:107-114 (handler)The deleteCart function that executes the core logic of the fakestore_delete_cart tool: validates the cart ID and performs a DELETE request to /carts/{id} via the del API utility./** * Delete a cart (simulation) */ export async function deleteCart(args: { id: number }): Promise<Cart> { const { id } = args; validatePositiveInteger(id, 'Cart ID'); return del<Cart>(`/carts/${id}`); }
- src/tools/carts.ts:242-255 (schema)The input schema definition for the fakestore_delete_cart tool within the cartTools array, defining the required 'id' number parameter.{ name: 'fakestore_delete_cart', description: 'Delete a cart (simulation - does not persist)', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Cart ID to delete', }, }, required: ['id'], }, },
- src/index.ts:161-166 (registration)Tool registration in the MCP CallToolRequestHandler: checks tool name and invokes the deleteCart handler function.if (name === 'fakestore_delete_cart') { const result = await deleteCart(args as { id: number }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/index.ts:40-44 (registration)Registration of tool list including cartTools (which contains fakestore_delete_cart schema) in the ListToolsRequestHandler.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });
- src/index.ts:19-19 (registration)Import statement bringing in the deleteCart handler and cartTools (schema) from carts.ts.import { cartTools, getAllCarts, getCartById, getUserCarts, addCart, updateCart, deleteCart } from './tools/carts.js';