create_cart
Create a TMF663 shopping cart for anonymous ordering, linking public key identity to physical address without requiring personal information.
Instructions
Create a new TMF663 shopping cart. If W3SHIP_PUBLIC_KEY is configured, it is used automatically — no id required. Otherwise provide an SLH-DSA or ECDSA public key (hex).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Public key (hex). Optional if W3SHIP_PUBLIC_KEY env var is set. | |
| customer | No |
Implementation Reference
- src/index.ts:408-426 (handler)The handler implementation for the 'create_cart' tool in src/index.ts. It validates the provided public key (or uses the configured one) and saves a new cart to the valkeyService.
case 'create_cart': { const id = (args?.id as string) || CONFIGURED_KEY; if (!id) { return { content: [{ type: 'text', text: 'Error: No public key provided. Either set W3SHIP_PUBLIC_KEY in your MCP config, provide an id parameter, or call generate_demo_key first.' }], isError: true, }; } const keyType = getKeyType(id); if (!keyType) { return { content: [{ type: 'text', text: 'Error: Invalid public key. Must be SLH-DSA (64 bytes hex) or ECDSA (33/65 bytes hex).' }], isError: true, }; } const cart = { id, keyType, customer: args?.customer as any, cartItem: [] }; await valkeyService.saveCart(cart as any); return { content: [{ type: 'text', text: `Cart created successfully (${keyType}): ${id}` }] }; } - src/index.ts:64-80 (registration)Tool registration for 'create_cart' within the ListToolsRequestSchema handler in src/index.ts.
{ name: 'create_cart', description: 'Create a new TMF663 shopping cart. If W3SHIP_PUBLIC_KEY is configured, it is used automatically — no id required. Otherwise provide an SLH-DSA or ECDSA public key (hex).', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Public key (hex). Optional if W3SHIP_PUBLIC_KEY env var is set.' }, customer: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, }, }, }, }, },