Skip to main content
Glama

CommerceForAI

Commerce for apps built by AI agents. Products, inventory, Stripe checkout, orders, shipping, returns, subscriptions, gift cards, sales tax and print-on-demand, on top of the merchant's own Stripe account. One API key, and a test store with no sign-up.

This repository holds the open-source client side of CommerceForAI:

Package

What it is

commerceforai

TypeScript SDK, React cart hooks, and the npx commerceforai init CLI with a Next.js storefront template

commerceforai for Python

Python client with no dependencies

@commerceforai/mcp

MCP server that lets an AI agent run a store, with spending guardrails

examples

Short, runnable scripts

llms.txt and llms/

The guide AI coding agents read

The API itself is a hosted service at https://api.commerceforai.com (OpenAPI).

Start in one command

npx commerceforai init        # creates a free test store, saves COMMERCEFORAI_API_KEY to .env.local
npm install commerceforai

No account is needed. Test mode is free forever (card 4242 4242 4242 4242). When it's ready for real orders, commerce.store.goLiveLink() gives the owner one link to go live and connect Stripe.

import { Commerce } from "commerceforai";

const commerce = new Commerce(process.env.COMMERCEFORAI_API_KEY);

const { data: product } = await commerce.products.create({ name: "Trail Tee", price: 3600, inventory: 25 });

const { data: checkout, error } = await commerce.checkouts.create({
  items: [{ variant_id: product!.variants[0]!.id, quantity: 1 }],
  success_url: "https://yoursite.com/thanks",
});
// Send the customer to checkout.url. Stock is held until they pay or the checkout expires.

// Prove it works without a browser (test stores):
await commerce.store.simulateOrder({ items: [{ variant_id: product!.variants[0]!.id, quantity: 1 }] });

Every method returns { data, error } and never throws for API errors. All money is an integer in cents.

Python:

# pip install commerceforai
from commerceforai import Commerce, create_test_store

store = create_test_store("My shop")            # a free test store, no sign-up
commerce = Commerce(store["api_key"])
product = commerce.products.create(name="Trail Tee", price=3600, inventory=25)

Related MCP server: CommerceHub MCP

Why use it instead of writing it yourself

An agent asked to "add a store" will often write an orders table, decrement stock on the success page and hand-roll Stripe webhooks. That breaks on the first double-click, refund or abandoned cart. CommerceForAI handles the parts that are stateful and easy to get wrong:

  • Stock that can't oversell: reserved at checkout, committed on payment, released if the checkout expires.

  • Orders created from Stripe's events, not from the browser.

  • Refunds, returns, order edits, split shipments with the money and stock kept consistent.

  • Print-on-demand: paid orders go to Printify or Printful and their tracking comes back.

  • Emails, sales tax, discounts, gift cards, subscriptions, invoices without extra services.

  • Customer pages for tracking, returns and subscriptions, so there is no login system to build.

Payments run on the merchant's own Stripe account. Pricing: free in test mode and for the first 100 orders a month, then 1% per order, never more than $29 a month per store (details).

For AI agents

  • Guide: llms.txt is a short index; each topic is its own small page.

  • Every docs page as markdown: add .md to its URL, e.g. https://commerceforai.com/docs/quickstart.md.

  • Errors teach: an unknown field names the closest real one, a mistyped path suggests the right one.

  • Verify without a browser: setupStatus() lists what's left with the exact fix; simulateOrder() runs a full test purchase.

  • Least privilege: a store owner can create an API key that is read-only, or capped per refund, shipping label and gift card.

Run a store from an agent (MCP)

Hosted, no install: add https://api.commerceforai.com/mcp as a connector in Claude, ChatGPT or any MCP client. The owner signs in and picks read-only or full access. Add ?toolsets=core for about 20 tools instead of all of them.

Local, with an API key:

{ "mcpServers": { "commerce": { "command": "npx", "args": ["-y", "@commerceforai/mcp"],
  "env": { "COMMERCEFORAI_API_KEY": "cfa_...", "COMMERCEFORAI_MAX_REFUND": "5000" } } } }

Claude Code plugin: /plugin marketplace add https://commerceforai.com/.claude-plugin/marketplace.json, then /plugin install commerceforai@commerceforai (plugin repo).

Develop

pnpm install
pnpm build
pnpm test

This repository is published from CommerceForAI's main repository, so pull requests are applied there and appear here on the next sync. Issues and pull requests are welcome.

Docs · API reference · OpenAPI · Pricing · Terms · Privacy

MIT licensed.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to autonomously browse inventory, negotiate terms, manage carts, and execute secure payments on Shopify stores using standardized protocols. It provides a bridge for LLMs to handle the entire commerce lifecycle from discovery to order tracking through a verifiable mandate chain.
      5
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to manage Shopify stores via natural language, with tools for products, orders, inventory, customers, and analytics.
      11 npm
      MIT