Skip to main content
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).

Built-in Tools

The gateway comes with a set of standard commerce tools. You can enable them by simply adding their names to your configuration.
Tool NameBackend RequiredDescription
search_productsproductsSearch for products using keywords and filters.
get_product_detailsproductsGet full details for a specific product.
check_inventoryproductsCheck if items are in stock and get ATP.
add_to_cartcartAdd a product variant to the current cart.
create_orderordersInitialize checkout and create a draft order.

Universal Tool Abstraction

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.
import { createTool } from '@betterdata/commerce-gateway';
import { z } from 'zod';

const myCustomTool = createTool({
  name: 'recommend_by_style',
  description: 'Find products that match a specific style',
  schema: z.object({
    style: z.enum(['modern', 'vintage', 'industrial']),
    limit: z.number().optional().default(5),
  }),
  handler: async ({ style, limit }, context) => {
    // Access your backend via context
    return await context.backends.products.searchByStyle(style, limit);
  }
});

How Adaption Works

When you serve your gateway, it dynamically generates the correct definitions for the target platform:

For Claude (MCP)

The gateway generates a JSON-RPC response that Claude’s MCP client can consume, including instructions on how to call the tool.

For OpenAI (Function Calling)

The gateway converts the Zod schema into a JSON Schema format that OpenAI expects in the tools array of a chat completion request.

For Grok

Similar to OpenAI, it formats the tools for X’s LLM engine.

Authentication & Security

Tools are automatically protected by the gateway’s authentication layer. When an LLM attempts to call a tool, the gateway verifies:
  1. The request has a valid session or API key.
  2. The session is allowed to call the specific tool.
  3. The inputs match the defined schema.

Next Steps

Check out the Guides to see how these tools appear in different AI environments.