Skip to main content
Glama
baskcart

W3Ship MCP Server

by baskcart

add_item

Add products to a shopping cart using public key identification. Specify cart ID and item details to manage your order.

Instructions

Add an item to an existing shopping cart. Uses W3SHIP_PUBLIC_KEY as cartId if not provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cartIdYesPublic key ID of the cart. Optional if W3SHIP_PUBLIC_KEY is set.
itemYes

Implementation Reference

  • The handler logic for the 'add_item' tool. It retrieves the cart from valkeyService, adds the item to the cart's item list, and saves the updated cart back.
    case 'add_item': {
        const cartId = (args?.cartId as string) || CONFIGURED_KEY;
        if (!cartId) {
            return { content: [{ type: 'text', text: 'Error: No cart ID. Set W3SHIP_PUBLIC_KEY or provide a cartId.' }], isError: true };
        }
        const itemArg = args?.item as any;
        const cart = await valkeyService.getCart(cartId);
        if (!cart) {
            return { content: [{ type: 'text', text: `Error: Cart not found: ${cartId}` }], isError: true };
        }
        const cartItem = { id: Math.random().toString(36).substring(7), ...itemArg };
        cart.cartItem = cart.cartItem || [];
        cart.cartItem.push(cartItem);
        await valkeyService.saveCart(cart);
        return { content: [{ type: 'text', text: `Item added successfully to cart ${cartId}` }] };
    }
  • The input schema definition for the 'add_item' tool, defining the required cartId and item structure.
        name: 'add_item',
        description: 'Add an item to an existing shopping cart. Uses W3SHIP_PUBLIC_KEY as cartId if not provided.',
        inputSchema: {
            type: 'object',
            properties: {
                cartId: { type: 'string', description: 'Public key ID of the cart. Optional if W3SHIP_PUBLIC_KEY is set.' },
                item: {
                    type: 'object',
                    properties: {
                        productOffering: {
                            type: 'object',
                            properties: {
                                id: { type: 'string' },
                                name: { type: 'string' },
                            },
                            required: ['id'],
                        },
                        quantity: {
                            type: 'object',
                            properties: {
                                amount: { type: 'number' },
                            },
                            required: ['amount'],
                        },
                    },
                    required: ['productOffering'],
                },
            },
            required: ['cartId', 'item'],
        },
    },
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the environment variable fallback behavior (W3SHIP_PUBLIC_KEY), which is valuable operational context. However, it omits other critical behavioral traits like idempotency, error cases (e.g., cart not found), or side effects beyond the addition itself.

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?

Two sentences total. The first establishes purpose; the second explains the optional cartId behavior. Every sentence earns its place with no redundancy or filler, efficiently front-loading the essential 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 the complex nested object structure for 'item', lack of output schema, and absence of annotations, the description provides minimal viable context. It covers the primary action and cartId resolution, but leaves significant gaps regarding the item payload structure and return 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 coverage is 50% (cartId described in schema, item is not). The description adds the specific environment variable name (W3SHIP_PUBLIC_KEY) for the cartId parameter, clarifying the fallback mechanism. However, it fails to compensate for the undocumented 'item' parameter structure, leaving the nested productOffering and quantity objects unexplained.

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

Purpose5/5

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

The description explicitly states 'Add an item to an existing shopping cart' with a specific verb (add) and resource (item). The word 'existing' effectively distinguishes this from the sibling create_cart tool, making the scope unambiguous.

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

Usage Guidelines3/5

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

The description implies usage constraints by specifying 'existing shopping cart' (suggesting the cart must already exist), and explains the W3SHIP_PUBLIC_KEY fallback mechanism. However, it lacks explicit guidance on when to use create_cart instead, or prerequisites like cart existence validation.

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/baskcart/w3ship-mcp-server'

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