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

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
NameRequiredDescriptionDefault
idYesCart ID

Implementation Reference

  • 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}`);
    }
  • 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],
      };
    });

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