Skip to content

CLI — add to an existing project

@curless/cli adds agentbank to an existing project in one command. Where create-agentbank scaffolds a new project, curless init writes the integration into the repo you already have. It picks between two roles:

  • --role receive — a storefront backend that sells to agents: it opens a priced checkout and the money lands in your account. Uses the merchant SDK.
  • --role paywall (default) — charge an agent per call. Detects your framework (MCP server / Next.js / Express / Python) and drops the paywall in.
Terminal window
# Receive agent payments (a storefront backend)
npx @curless/cli init --role receive --merchant curless_mch_… --api https://mcp.curless.ai
# Or a per-call paywall (framework auto-detected)
npx @curless/cli init --role paywall --product prd_2UU8ZRCR --amount 4900 \
--currency USD --api https://mcp.curless.ai

init resolves the recipe (--role receive → the storefront recipe; --role paywall → your detected framework), pulls it from the AgentBank API (GET /v1/integrations/recipes/:type), writes the scaffold into your repo, and sets up .env.local (guarding it in .gitignore). The recipe env is server-driven — the CLI writes exactly the keys that recipe needs, fills the non-secret ones (API base, merchant id, currency), and leaves every secret blank for you to fill.

The recipes use the production SDKs: the storefront recipe wires @curless/agentbank-merchant-sdk; the paywall recipes use @curless/agentbank-mcp-pay’s withPaywall (MCP) or the /mpp/:merchant/verify handshake (HTTP frameworks).

Flag Meaning
--role receive | paywall (default paywall)
--product, -p Curless product ref (prd_…)
--merchant, -m your merchant id (curless_mch_…)
--amount price in minor units (e.g. 4900)
--currency ISO currency (default USD)
--api AgentBank API base — required (or set $CURLESS_BASE_URL); local dev: http://localhost:3000
--target, -t force the recipe type — storefront | mcp-server | mcp-server-python | nextjs | express
--force overwrite an existing scaffold file
  • A scaffold file — src/agentbank-storefront.ts for receive, or the framework’s paywall file (src/curless-paywall.ts, app/api/unlock/route.ts, …) for paywall.
  • .env.local with the recipe’s env keys. The receive role writes AGENTBANK_API_URL, AGENTBANK_MERCHANT_ID, MERCHANT_CURRENCY (filled) and AGENTBANK_MERCHANT_TOKEN (blank); the paywall role writes CURLESS_BASE_URL (filled) and CURLESS_SECRET_KEY (blank). Secrets are never written for you.
  • A .env.local entry in .gitignore.

It never overwrites a scaffold file (without --force) and never clobbers an env value you’ve already set.