Getting Started
Tools are the "actions" that your AI agent can perform. In the LLM Gateway, tools are built on top of your Backends and automatically adapted to various LLM formats (MCP, OpenAI, Grok).
The gateway comes with a set of standard commerce tools. You can enable them by simply adding their names to your configuration.
| Tool Name | Backend Required | Description |
|-----------|------------------|-------------|
| search_products | products | Search for products using keywords and filters. |
| get_product_details | products | Get full details for a specific product. |
| check_inventory | products | Check if items are in stock and get ATP. |
| add_to_cart | cart | Add a product variant to the current cart. |
| create_order | orders | Initialize checkout and create a draft order. |
One of the core strengths of the gateway is its universal tool format. You define a tool once using Zod for schema validation, and the gateway handles the rest.
1import { createTool } from '@commercegateway/commerce-gateway';2import { z } from 'zod';3 4const myCustomTool = createTool({5 name: 'recommend_by_style',6 description: 'Find products that match a specific style',7 schema: z.object({8 style: z.enum(['modern', 'vintage', 'industrial']),9 limit: z.number().optional().default(5),10 }),11 handler: async ({ style, limit }, context) => {12 "cmt">// Access your backend via context13 return await context.backends.products.searchByStyle(style, limit);14 }15});When you serve your gateway, it dynamically generates the correct definitions for the target platform:
The gateway generates a JSON-RPC response that Claude's MCP client can consume, including instructions on how to call the tool.
The gateway converts the Zod schema into a JSON Schema format that OpenAI expects in the tools array of a chat completion request.
Similar to OpenAI, it formats the tools for X's LLM engine.
Tools are automatically protected by the gateway's authentication layer. When an LLM attempts to call a tool, the gateway verifies:
Check out the Guides to see how these tools appear in different AI environments.
