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

fakestore_add_cart

Add a cart with user ID, date, and products to simulate e-commerce transactions for testing and demos.

Instructions

Add a new cart (simulation - does not persist)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdYesUser ID who owns the cart
dateYesCart date in ISO format (e.g., 2024-01-01)
productsYesArray of products in the cart

Implementation Reference

  • The addCart function implements the core logic for the fakestore_add_cart tool: validates inputs (userId, date, products), checks each product's productId and quantity, then posts to the FakeStore API to simulate adding a cart.
    export async function addCart(args: {
      userId: number;
      date: string;
      products: CartProduct[];
    }): Promise<Cart> {
      const { userId, date, products } = args;
    
      validatePositiveInteger(userId, 'User ID');
      validateISODate(date, 'Date');
      validateNonEmptyArray<CartProduct>(products, 'Products');
    
      // Validate each product in the cart
      products.forEach((product, index) => {
        if (typeof product.productId !== 'number' || product.productId <= 0) {
          throw new Error(`Product ${index + 1}: productId must be a positive number`);
        }
        if (typeof product.quantity !== 'number' || product.quantity <= 0) {
          throw new Error(`Product ${index + 1}: quantity must be a positive number`);
        }
      });
    
      return post<Cart>('/carts', {
        userId,
        date,
        products,
      });
    }
  • Input schema definition for fakestore_add_cart tool within the cartTools array, specifying required properties: userId (number), date (ISO string), products (array of {productId, quantity}).
    {
      name: 'fakestore_add_cart',
      description: 'Add a new cart (simulation - does not persist)',
      inputSchema: {
        type: 'object',
        properties: {
          userId: {
            type: 'number',
            description: 'User ID who owns the cart',
          },
          date: {
            type: 'string',
            description: 'Cart date in ISO format (e.g., 2024-01-01)',
          },
          products: {
            type: 'array',
            description: 'Array of products in the cart',
            items: {
              type: 'object',
              properties: {
                productId: {
                  type: 'number',
                  description: 'Product ID',
                },
                quantity: {
                  type: 'number',
                  description: 'Product quantity',
                },
              },
              required: ['productId', 'quantity'],
            },
          },
        },
        required: ['userId', 'date', 'products'],
      },
    },
  • src/index.ts:138-147 (registration)
    MCP server registration: In the CallToolRequestSchema handler, checks if name === 'fakestore_add_cart' and invokes addCart with cast arguments, returning JSON-stringified result.
    if (name === 'fakestore_add_cart') {
      const result = await addCart(args as {
        userId: number;
        date: string;
        products: Array<{ productId: number; quantity: number }>;
      });
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • src/index.ts:42-42 (registration)
    Tool list registration: In ListToolsRequestSchema handler, includes cartTools (containing fakestore_add_cart schema) in the returned tools list.
    tools: [...productTools, ...cartTools, ...userTools],
  • src/index.ts:19-19 (registration)
    Imports the addCart handler function and cartTools (with schema) from carts.ts into the main MCP server index.
    import { cartTools, getAllCarts, getCartById, getUserCarts, addCart, updateCart, deleteCart } from './tools/carts.js';
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses a key behavioral trait: 'simulation - does not persist,' indicating it's a non-persistent operation, which is valuable context. However, it lacks details on error handling, response format, or side effects, leaving gaps in behavioral understanding.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence that front-loads the core action and includes a critical behavioral note. Every word earns its place, with no redundant or unnecessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a mutation tool. It covers the simulation aspect but lacks details on return values, error conditions, or interaction with other tools. It's minimally adequate but has clear gaps in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all three parameters. The description adds no additional meaning beyond what the schema provides, such as explaining relationships between parameters or usage examples. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Add') and resource ('a new cart'), making the purpose evident. However, it does not explicitly differentiate from sibling tools like 'fakestore_update_cart' or 'fakestore_get_cart', which would require mentioning it's for creation rather than modification or retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It does not mention prerequisites, such as needing an existing user ID, or contrast with other cart-related tools like 'fakestore_update_cart' for modifications or 'fakestore_get_cart' for retrieval.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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