commerce-bots

Get the code

Pick the tools you want, choose a flow, and we'll generate a ready-to-run starter project — free. Shopify quick start scaffolds a full Catalog → Cart → Checkout agent in one click. The Premium option adds safeguards for production use, such as retry protection that helps avoid duplicate orders. Runs locally or in your own cloud — no credentials needed to generate.

Static analysis · 1 server · 5,161 tok / 8,000 tok budget

No issues detected for this selection.

Generated project (11 files)

src/adapters/base.ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

export interface AdapterConfig {
  serverId: string;
  transport: "stdio" | "http-sse" | "http-stream";
  command?: string;
  args?: string[];
  url?: string;
  headers?: Record<string, string>;
}

export async function connectAdapter(config: AdapterConfig): Promise<Client> {
  const client = new Client(
    { name: "commerce-agent-harness", version: "1.0.0" },
    { capabilities: { tools: {} } },
  );

  if (config.transport === "stdio" && config.command) {
    const transport = new StdioClientTransport({
      command: config.command,
      args: config.args ?? [],
      env: process.env as Record<string, string>,
    });
    await client.connect(transport);
  } else if (config.transport === "http-stream" && config.url) {
    // Streamable HTTP — the modern remote-MCP transport (Shopify hosted, Stripe).
    const transport = new StreamableHTTPClientTransport(new URL(config.url), {
      requestInit: { headers: config.headers },
    });
    await client.connect(transport);
  } else if (config.transport === "http-sse" && config.url) {
    const transport = new SSEClientTransport(new URL(config.url), {
      requestInit: { headers: config.headers },
    });
    await client.connect(transport);
  } else {
    throw new Error(`Unsupported transport for ${config.serverId}`);
  }
  return client;
}
Build · commerce-bots