Clause GitHub ↗
Setup

Run Clause in 5 minutes

You need Node.js, a free PayPal Developer account, and optionally an Anthropic API key.

Prerequisites

  • Node.js 20 or newer (22 recommended).
  • A PayPal Developer account (free).
  • An Anthropic API key for the AI features. Without one, Clause runs in a clearly labelled simulated AI mode so the PayPal flow still works.

PayPal sandbox

  1. Open the Developer Dashboard → Apps & Credentials → Sandbox.
  2. Create a REST app (or use the default). It belongs to your sandbox Business account, which is the seller and receives the money. Copy its Client ID and Secret.
  3. Under Testing Tools → Sandbox Accounts, note your sandbox Personal account's email and password. You log in with it as the buyer in the PayPal popup.
Sandbox accounts are fake: approving a payment moves sandbox funds only.

Install & run

git clone https://github.com/akashtalole/Clause.git
cd Clause && npm install && cp .env.example .env

Fill in .env (see below), then optionally add labelled demo history for the analytics page, and start:

npm run seed
npm start

Open http://localhost:3000. The header chips show whether Claude and PayPal are configured.

Configuration

VariableRequiredPurpose
PAYPAL_SANDBOX_CLIENT_IDYesSandbox REST app client ID (business / seller account)
PAYPAL_SANDBOX_CLIENT_SECRETYesSandbox REST app secret
ANTHROPIC_API_KEYRecommendedEnables Claude; without it the AI is simulated
CLAUDE_MODELNoDefaults to claude-opus-5-5
PAYPAL_BUYER_EMAILNoShown as a login hint next to the PayPal button
APP_BASE_URLNoPublic URL for PayPal return links; derived from the request if unset
AUTO_RELEASE_MIN_CONFIDENCENoSpend-gate confidence threshold, default 0.75
REVISION_BUFFER_DAYSNoDays added to the forecast per requested revision, default 2
AG_STUDIO_LICENSE_KEYNoRemoves the AG Studio trial watermark
RENDER_WORKFLOW_SLUG, RENDER_API_KEYNoRun the AI agents as Render Workflows tasks instead of in-process
CRON_SECRETNoProtects the maintenance sweep endpoint used by the cron job

Check your setup

npm run smoke

Confirms the PayPal sandbox token, creates a test order with an approval link, and makes a tiny Claude call if a key is set.

Deploy on Render

Deploy to Render

  1. Click the button (or Render → New → Blueprint → this repo). Fill in ANTHROPIC_API_KEY, PAYPAL_SANDBOX_CLIENT_ID and PAYPAL_SANDBOX_CLIENT_SECRET.
  2. Optional: New → Workflow on the same repo, start command node src/workflows.js, env var ANTHROPIC_API_KEY. Then set RENDER_WORKFLOW_SLUG and RENDER_API_KEY on the web service so AI jobs run as Render Workflows tasks.
Render's free web service sleeps when idle (first request takes ~30s), and its disk resets on redeploy. The Blueprint's cron job is a paid Render service type; remove the clause-sweep block from render.yaml for a free-only deploy.

Use from an AI agent (MCP)

With Clause running, register the MCP server in Claude Code:

claude mcp add clause -e CLAUSE_URL=http://localhost:3000 -- node /absolute/path/to/Clause/src/mcp.js

Or in Claude Desktop's claude_desktop_config.json:

{
  "mcpServers": {
    "clause": {
      "command": "node",
      "args": ["/absolute/path/to/Clause/src/mcp.js"],
      "env": { "CLAUSE_URL": "http://localhost:3000" }
    }
  }
}

Then ask: "Use Clause to hire an agent to write 5 taglines for my bakery for $40, and give me the PayPal link to fund it." Tool list in the reference.

Tests

npm test

Runs the real server against a local fake of the PayPal REST API: holds, partial and final captures, void, refund, prompt-injection blocking, delivery order, scheduler, audit-chain tampering, the AG Studio ↔ Claude bridge and the Render Workflows tasks.

Troubleshooting

SymptomFix
Header shows "PayPal not configured"Set both PAYPAL_SANDBOX_* values in .env and restart.
Header shows "Simulated AI"Add ANTHROPIC_API_KEY and restart.
PayPal popup blocked or closesUse Or open PayPal approval link under the button; you return to the pact afterwards.
ORDER_NOT_APPROVED errorThe buyer didn't finish approving in PayPal; click the PayPal button again.
Capture fails on the 2nd milestoneYour sandbox business account may not allow multiple partial captures; check the error's PayPal debug ID in the server log.
Analytics page is emptyRun npm run seed for labelled demo history, or complete a live pact.