Overview#

The Cognitive Cart MCP server exposes two tools:

  • list-products — Fetches products from the store’s REST API (id, name, price, amount_total). In hosts that support MCP Apps, it can show an interactive UI (product list + Buy button).
  • buy-products — Creates a checkout session with the given line items and returns a Stripe Checkout URL. The user completes payment in their browser.

No changes to your Stripe Connect or Worker are required for this flow; the server uses the same endpoints as other agents.

The MCP server is not included in the Cognitive Cart plugin zip or WordPress.org build. It lives in the Cognitive Cart source repo. To use it, clone the repo and run the server from the mcp-server/ directory.

Prerequisites#

  • A Cognitive Cart store with Stripe Connect and Worker configured (see Stripe Connect & Checkout).
  • Node.js 18+ on the machine where you run the MCP server.

Running the MCP server#

Install dependencies — From the Cognitive Cart repo root: cd mcp-server && npm install.

Set the store URL — Set the base URL of your store (no trailing slash): export COGNITIVE_CART_STORE_URL=https://your-store.com.

Start the servernpm start. The server uses stdio transport (reads from stdin, writes to stdout). MCP hosts start it as a subprocess and communicate over stdio.

Claude Desktop#

1. Open Claude Desktop settings (e.g. Settings → Developer).
2. Add an MCP server that runs the Cognitive Cart MCP server with your store URL. Example claude_desktop_config.json:

{
  "mcpServers": {
    "cognitive-cart": {
      "command": "node",
      "args": ["/path/to/cognitive-cart/mcp-server/index.js"],
      "env": {
        "COGNITIVE_CART_STORE_URL": "https://your-store.com"
      }
    }
  }
}

Use the actual path to the repo’s mcp-server/index.js and your store’s base URL.
3. Restart Claude Desktop. You can then ask Claude to list products or buy items; it will use the list-products and buy-products tools.

ChatGPT and other hosts#

If your host supports MCP (or Custom GPTs with an MCP backend), add a new MCP server with:

  • Command: node
  • Args: Path to mcp-server/index.js (e.g. C:\path\to\cognitive-cart\mcp-server\index.js or /path/to/cognitive-cart/mcp-server/index.js)
  • Environment: COGNITIVE_CART_STORE_URL=https://your-store.com

Exact steps depend on the host; refer to the host’s documentation for adding an MCP server.

Troubleshooting#

  • “COGNITIVE_CART_STORE_URL is not set” — Start the server with the env var set (e.g. in the host’s config or your shell).
  • “Failed to list products” / “Checkout failed” — Ensure the store URL is correct and the store’s REST API is reachable (e.g. GET https://your-store.com/wp-json/cognitive-cart/v1/products). Confirm Stripe Connect and the Worker are set up.
  • Checkout URL opens but payment fails — Confirm Stripe Connect and the Worker are configured for the store.