fakestore_get_cart
Retrieve specific shopping cart details by ID to view items, quantities, and totals for e-commerce testing and data management.
Instructions
Get a single cart by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Cart ID |
Implementation Reference
- src/index.ts:124-129 (handler)Executes the 'fakestore_get_cart' tool by calling getCartById with the input arguments and formatting the result as a JSON text response.if (name === 'fakestore_get_cart') { const result = await getCartById(args as { id: number }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/tools/carts.ts:138-151 (schema)Defines the input schema for 'fakestore_get_cart' tool, requiring a positive integer 'id'.{ 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:40-44 (registration)Registers the 'fakestore_get_cart' tool (via cartTools) in the MCP server's listTools response.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });
- src/tools/carts.ts:32-36 (helper)Helper function that performs input validation and API call to retrieve a single cart by ID.export async function getCartById(args: { id: number }): Promise<Cart> { const { id } = args; validatePositiveInteger(id, 'Cart ID'); return get<Cart>(`/carts/${id}`); }