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
- Open the Developer Dashboard → Apps & Credentials → Sandbox.
- 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.
- 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.
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
| Variable | Required | Purpose |
|---|---|---|
PAYPAL_SANDBOX_CLIENT_ID | Yes | Sandbox REST app client ID (business / seller account) |
PAYPAL_SANDBOX_CLIENT_SECRET | Yes | Sandbox REST app secret |
ANTHROPIC_API_KEY | Recommended | Enables Claude; without it the AI is simulated |
CLAUDE_MODEL | No | Defaults to claude-opus-5-5 |
PAYPAL_BUYER_EMAIL | No | Shown as a login hint next to the PayPal button |
APP_BASE_URL | No | Public URL for PayPal return links; derived from the request if unset |
AUTO_RELEASE_MIN_CONFIDENCE | No | Spend-gate confidence threshold, default 0.75 |
REVISION_BUFFER_DAYS | No | Days added to the forecast per requested revision, default 2 |
AG_STUDIO_LICENSE_KEY | No | Removes the AG Studio trial watermark |
RENDER_WORKFLOW_SLUG, RENDER_API_KEY | No | Run the AI agents as Render Workflows tasks instead of in-process |
CRON_SECRET | No | Protects 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
- Click the button (or Render → New → Blueprint → this repo). Fill in
ANTHROPIC_API_KEY,PAYPAL_SANDBOX_CLIENT_IDandPAYPAL_SANDBOX_CLIENT_SECRET. - Optional: New → Workflow on the same repo, start command
node src/workflows.js, env varANTHROPIC_API_KEY. Then setRENDER_WORKFLOW_SLUGandRENDER_API_KEYon the web service so AI jobs run as Render Workflows tasks.
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
| Symptom | Fix |
|---|---|
| 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 closes | Use Or open PayPal approval link under the button; you return to the pact afterwards. |
ORDER_NOT_APPROVED error | The buyer didn't finish approving in PayPal; click the PayPal button again. |
| Capture fails on the 2nd milestone | Your sandbox business account may not allow multiple partial captures; check the error's PayPal debug ID in the server log. |
| Analytics page is empty | Run npm run seed for labelled demo history, or complete a live pact. |