Skip to main content
Glama

fakestore_get_carts

Retrieve shopping carts from the Fake Store API with options to limit results and sort by date for e-commerce testing and data management.

Instructions

Get all carts from the store. Optionally limit results and sort.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoLimit the number of carts returned
sortNoSort carts (asc or desc)

Implementation Reference

  • Core handler function that fetches all carts from the FakeStore API endpoint '/carts' with optional limit and sort parameters, including input validation.
    export async function getAllCarts(args: { limit?: number; sort?: SortOrder }): Promise<Cart[]> { const { limit, sort } = args; if (limit !== undefined) { validateLimit(limit); } if (sort !== undefined) { validateSortOrder(sort); } const params: Record<string, unknown> = {}; if (limit) params.limit = limit; if (sort) params.sort = sort; return get<Cart[]>('/carts', params); }
  • Input schema definition for the fakestore_get_carts tool, specifying optional limit (number) and sort (enum: 'asc'|'desc') parameters.
    name: 'fakestore_get_carts', description: 'Get all carts from the store. Optionally limit results and sort.', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Limit the number of carts returned', }, sort: { type: 'string', enum: ['asc', 'desc'], description: 'Sort carts (asc or desc)', }, }, }, },
  • src/index.ts:117-122 (registration)
    Tool dispatching logic in the MCP CallToolRequest handler that maps 'fakestore_get_carts' to the getAllCarts function and formats the JSON response.
    if (name === 'fakestore_get_carts') { const result = await getAllCarts(args as { limit?: number; sort?: 'asc' | 'desc' }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • src/index.ts:40-44 (registration)
    Registration of available tools list handler, which includes cartTools containing the fakestore_get_carts schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });
  • src/index.ts:19-19 (registration)
    Import statement bringing in cartTools (schemas) and getAllCarts (handler) from carts module.
    import { cartTools, getAllCarts, getCartById, getUserCarts, addCart, updateCart, deleteCart } from './tools/carts.js';

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/op-enny/mcp-server-fakestore'

If you have feedback or need assistance with the MCP directory API, please join our Discord server