Skip to main content
Glama
op-enny
by op-enny

fakestore_get_carts

Retrieve shopping carts from the Fake Store API with options to limit results and sort them in ascending or descending order.

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, validates input parameters, constructs query params, and calls the API.
    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); }
  • Tool schema definition including name, description, and input schema for validation.
    { 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:116-122 (registration)
    Registers and dispatches the fakestore_get_carts tool call to the handler function within the MCP CallToolRequest handler.
    // Cart tools 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)
    Registers the tool schemas (including fakestore_get_carts from cartTools) for the ListToolsRequest.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...productTools, ...cartTools, ...userTools], }; });

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