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

fakestore_update_cart

Modify cart details like user ID, date, or products in a simulated e-commerce environment for testing and development purposes.

Instructions

Update an existing cart (simulation - does not persist)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesCart ID to update
userIdNoNew user ID
dateNoNew cart date
productsNoNew products array

Implementation Reference

  • Core handler function that validates the input arguments and performs the PUT request to update the cart on the FakeStore API.
    export async function updateCart(args: {
      id: number;
      userId?: number;
      date?: string;
      products?: CartProduct[];
    }): Promise<Cart> {
      const { id, userId, date, products } = args;
      validatePositiveInteger(id, 'Cart ID');
    
      const updateData: Record<string, unknown> = {};
      if (userId !== undefined) {
        validatePositiveInteger(userId, 'User ID');
        updateData.userId = userId;
      }
      if (date !== undefined) {
        validateISODate(date, 'Date');
        updateData.date = date;
      }
      if (products !== undefined) {
        validateNonEmptyArray<CartProduct>(products, 'Products');
        updateData.products = products;
      }
    
      return put<Cart>(`/carts/${id}`, updateData);
    }
  • Top-level dispatch handler in the MCP server that matches the tool name and invokes the updateCart function with typed arguments, returning the JSON stringified result.
    if (name === 'fakestore_update_cart') {
      const result = await updateCart(args as {
        id: number;
        userId?: number;
        date?: string;
        products?: Array<{ productId: number; quantity: number }>;
      });
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Tool schema definition including name, description, and inputSchema for validation in the MCP tool list.
    {
      name: 'fakestore_update_cart',
      description: 'Update an existing cart (simulation - does not persist)',
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'number',
            description: 'Cart ID to update',
          },
          userId: {
            type: 'number',
            description: 'New user ID',
          },
          date: {
            type: 'string',
            description: 'New cart date',
          },
          products: {
            type: 'array',
            description: 'New products array',
            items: {
              type: 'object',
              properties: {
                productId: {
                  type: 'number',
                  description: 'Product ID',
                },
                quantity: {
                  type: 'number',
                  description: 'Product quantity',
                },
              },
              required: ['productId', 'quantity'],
            },
          },
        },
        required: ['id'],
      },
    },
  • src/index.ts:40-44 (registration)
    Registration of all tools including cartTools (which contains fakestore_update_cart) in the MCP listTools handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [...productTools, ...cartTools, ...userTools],
      };
    });
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the critical behavioral trait that this is a simulation that 'does not persist', which is essential context not inferable from the schema. However, it lacks details on permissions, error handling, or what 'update' entails beyond the parameters.

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?

Extremely concise with a single sentence that front-loads the core purpose and includes the crucial simulation detail. Every word earns its place with zero waste or redundancy.

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?

For a mutation tool with no annotations and no output schema, the description provides minimal but critical context about the simulation nature. However, it lacks information about what happens during the update, error conditions, or return values, leaving significant gaps in understanding the tool's behavior.

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%, providing clear documentation for all 4 parameters. The description adds no additional parameter semantics beyond implying 'id' is required for an existing cart. Baseline 3 is appropriate as the 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 action ('Update') and resource ('existing cart'), making the purpose immediately understandable. It distinguishes from siblings like 'fakestore_add_cart' (create) and 'fakestore_delete_cart' (remove). However, it doesn't specify what fields can be updated beyond the simulation note.

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 explicit guidance on when to use this tool versus alternatives. While the description mentions 'existing cart' implying it requires a pre-existing cart ID, it doesn't clarify when to choose this over 'fakestore_add_cart' for modifications or how it relates to other update tools like 'fakestore_update_product'.

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