fakestore_get_cart
Retrieve a specific shopping cart by its ID from the Fake Store API to view items, quantities, and totals for e-commerce testing or demonstration purposes.
Instructions
Get a single cart by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Cart ID |
Implementation Reference
- src/tools/carts.ts:32-36 (handler)Handler function that executes the core logic of fetching a single cart by ID from the Fake Store API, including input validation.export async function getCartById(args: { id: number }): Promise<Cart> { const { id } = args; validatePositiveInteger(id, 'Cart ID'); return get<Cart>(`/carts/${id}`); }
- src/tools/carts.ts:138-151 (schema)Input schema definition for the fakestore_get_cart tool, specifying the required 'id' parameter.{ name: 'fakestore_get_cart', description: 'Get a single cart by its ID', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Cart ID', }, }, required: ['id'], }, },
- src/index.ts:124-129 (registration)Registration and dispatch logic in the main CallToolRequest handler that matches the tool name and invokes the getCartById handler.if (name === 'fakestore_get_cart') { const result = await getCartById(args as { id: number }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/index.ts:40-44 (registration)Tool listing handler that includes cartTools (containing the fakestore_get_cart schema) in the list of available tools.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });