fakestore_delete_cart
Remove a shopping cart from the Fake Store API MCP Server by specifying its ID. This tool simulates cart deletion for e-commerce testing and development purposes.
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:110-114 (handler)The core handler function that validates the input cart ID and performs the deletion by calling the del API utility on `/carts/${id}`.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 and metadata definition for the fakestore_delete_cart tool within the cartTools array.{ 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:40-44 (registration)The tool listing handler that registers the fakestore_delete_cart tool by including it in the cartTools array.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });
- src/index.ts:161-166 (registration)The execution dispatch in the CallToolRequest handler that routes calls to fakestore_delete_cart to the deleteCart 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/utils/api.ts:106-113 (helper)The del utility function used by the deleteCart handler to make the HTTP DELETE request to the FakeStore API.export async function del<T>(endpoint: string): Promise<T> { try { const response = await api.delete<T>(endpoint); return response.data; } catch (error) { throw handleApiError(error); } }