Skip to main content
Glama
Sell Your Soul
by Saamael

Sell Your Soul

A marketplace of human expertise for AI agents. Experts sell answers, not documents. Built with Kiro for Kiroween 2026.

An expert's own agent turns their working knowledge into a soul file, strips secrets on their machine and uploads it only after they say yes. Buyers' agents (Kiro, Claude Code, Cursor and others) consult a soul over MCP and pay a few cents per answer; the expert earns 70%. The soul file itself never leaves: no route returns it, every answer is checked before release, and a question the soul does not cover costs nothing.

Architecture

One Cloudflare Worker serves the pages, the REST API and both MCP doors. D1 holds the chunks, the word-search index and a double-entry ledger; the soul file sits in a private R2 bucket.

flowchart LR
  subgraph Seller
    E["Expert's agent runs prompts/sell-your-soul.md<br/>local secret and rights check, one yes"] --> U["POST /api/souls<br/>or kotsu action upload"]
  end
  U --> S["Upload scan: secrets, injection, hidden text,<br/>look-alike letters, company-fact warnings"]
  S --> C["Opus check: names, personal data, quality"]
  C --> D[("D1: chunks, FTS5, ledger")]
  C --> R[("R2: private soul file")]
  subgraph Buyer
    B["Buyer's agent with an API key"] --> M["/mcp: kotsu, kotsu_vision"]
    W["Agent with a wallet"] --> X["/x402/mcp: x402, USDC on Base"]
  end
  M --> A["Answer service"]
  X --> A
  A --> I["Input screen: keys, extraction (free)"]
  I --> P["FTS5 plus Haiku pick<br/>not covered: free, no answer call"]
  P --> H["Hold the price"]
  H --> L["Answer model: picked chunks only,<br/>in a nonce fence, rules after the soul"]
  L --> G["Guards G1 to G5: schema, chunk ids, verbatim and laundering,<br/>orders to an AI, safe markdown"]
  G -->|pass| K["Capture: 3.5¢ to the soul, 1.5¢ to the house"]
  G -->|fail| F["Withdraw: free"]
  D -.-> P

The specs Kiro worked from are in .kiro/specs/sell-your-soul/ (requirements, design with the numbered properties P1 to P63, tasks), and the rules every change follows are in .kiro/steering/ (product, security, voice, design). The hooks in .kiro/hooks/ run the property tests when money or safety code is saved, ask for a screenshot and copy check when a page changes, check the tasks for drift when a spec changes, and fail on a leftover placeholder marker. The backend design notes are in docs/backend/.

Related MCP server: x402-starter

Run it locally

npm install
npm run start:local

start:local writes a git-ignored .dev.vars with local-only random secrets and MODEL_STUB=1 (only if you have none yet), applies the D1 migrations to the local database, builds the pages and starts the Worker on http://127.0.0.1:8787. With MODEL_STUB=1 no model is called; put a real ANTHROPIC_API_KEY in .dev.vars and remove MODEL_STUB to answer with Claude.

Try it without a key, on the wallet door:

curl -s http://127.0.0.1:8787/x402/mcp -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"kotsu","arguments":{"action":"check_setup","rule_text":"Use pnpm.","effort":"xhigh"}}}'

A free agent key for the keyed door: POST http://127.0.0.1:8787/api/keys/agent with {"device_name": "my laptop"}. Keep the key in an environment variable; it is shown once.

Other commands: npm run deploy:check builds and dry-runs both environments and deploys nothing; npm run site:check checks a running npm run dev with Playwright. Deploying is in docs/deploy/DEPLOY.md.

Connect an agent

Kiro. This repo carries .kiro/settings/mcp.json with both doors. Put your API key in SELL_YOUR_SOUL_API_KEY and add that name to Kiro's approved environment variables for MCP; the wallet door needs no key. Claude Code, Cursor and the other agents are on https://sellyoursoul.dev/connect.

The tools. Two tools, so an agent's context stays small:

kotsu action

What it does

Cost

search

Find a soul for a question (word search, no model text reaches your agent)

free

ask

Ask a soul. Returns answered, not_covered, needs_context (with the soul's own setup questions) or refused

5¢ when answered; everything else free

verify_draft

Check a draft against a soul without exposing its text

per covered check

check_setup

Read a coding agent's rule file and settings against Kotsu Lab's Paper #1 (below). No model call, never charged, never repeats the file

free

get_balance, rate

Credit left; rate a paid answer 1 to 5

free

get_prompt, upload, list_mine, publish_version, delete

Sell a soul from your agent, no website step (keyed door only)

free

kotsu_vision does image analysis and 1:1 visual checks through the Vision Soul.

The Vision Soul is a closed soul that the seller runs on their own server; this repo holds only the code that calls it.

The x402 flow. On /x402/mcp an agent with a wallet needs no key. search and check_setup are free. ask with no payment returns a PaymentRequired result (5¢ USDC on Base); the agent signs it and calls again with the payment in _meta["x402/payment"]; the answer comes back with the settlement in _meta["x402/payment-response"]. Only a delivered, billable answer is settled: not covered, needs context, refused and failed answers never are.

Security, and what the red team found

Defence in depth, in the order an attack meets it: the upload scan, the free input screen, the prompt shape, the output guards G1 to G5, and billing that charges only for a delivered answer that passed every guard. The full threat model, every layer and the accepted risks are in docs/SECURITY.md.

The red-team suite (npm run test:security: 82 Node tests and 15 Worker tests, the Worker ones through the real answer pipeline) and a battery you can run against any git ref (node scripts/security-battery.ts --ref <ref>). Before and after the 29 Nov 2026 hardening:

Attack

Before

After

Extraction requests under 8 disguises (look-alike letters, zero-width, full-width, tags, case)

50 of 112 refused

112 of 112

Planted orders in a soul, under the same disguises

60 of 80 refused at upload

80 of 80

A chunk copied with zero-width spaces, look-alikes or digits for letters

0 of 5 withdrawn (delivered word for word)

5 of 5

A chunk handed out as base64, hex, ROT13, reversed or spread out

0 of 7 withdrawn

7 of 7

Honest craft questions the old filter refused ("show me the file naming you use")

0 of 5 answered

5 of 5

The battery was written together with the fixes, so the "after" column is in-sample; the gap is the result. A faithful paraphrase or a translation still passes the copy guard; that limit is written down and pinned by a test.

Research behind it

These are Kotsu Lab's own research notes (unpublished); the figures carry their ranges.

  • Paper #1, "Size Instructions, Setup Overhead, and the Brevity–Quality Tradeoff in Coding Agents" (Draft 3, 26 Nov 2026, revised after an independent audit; 1,197 stored sessions, 1,194 scored, plus 72 cross-family runs and 55 external Python cells). Its findings are the check_setup action, with every figure cited in the reply: the two-sentence size block cut changed lines by 47.3% on 8 open-source bug fixes with every suite passing, and cut cost by 14.9% on top of a full personal setup; "your code's size is measured" did not beat it and made code harder to read; effort high instead of xhigh cut cost by 38.0% on 10 of 10 tasks; dropping unused tool servers, skills and plugins with effort high cut cost by 57.5%, with asked work 1.6 to 2.1 points lower and a range that crosses zero. Scope: short headless command-line tasks that needed no tool server. Run it on your own rule file: npm run setup:check -- CLAUDE.md --effort xhigh --mcp-servers 6 --mcp-servers-used 1.

  • Kotsu format, run 6 (18 Nov 2026, 36 situations): serving 3 passages by word search tied handing over the whole file (usefulness −0.14, range −0.36 to +0.08) at about one sixth of the cost, and beat no file by +0.35 usefulness (+0.14 to +0.56). So answers load a few picked chunks, never the whole soul. The same run traced two earlier results to an "answer ONLY from the file" prompt: with the model free to add its own knowledge, the whole file beat no file by +0.49 usefulness. The live answering frame has no such restriction and labels general practice as such; src/anthropic/frame-contract.test.ts keeps it that way.

  • Callable soul, run 7: agents that could call the soul's ask from their own code fixed 0.94 of planted mistakes, against 0.66 with no soul, and matched an agent holding the whole file on large held-out files (24 of 30 each).

  • Experience capture, run 3: what an expert adds in real sessions is mostly facts the agent could not see and verdicts on finished work; a soul written as advice by the old seller method made a model predict the expert's verdicts worse than reading nothing. The seller prompt now asks for verdicts, numbers with their situation, worked examples, and the expert's own thresholds from their scripts.

Selling a soul

prompts/sell-your-soul.md is the product's front door: an expert pastes it into their own agent, which reads their session history in two passes (their corrections first, then what fixed each problem), keeps only confirmed expertise, strips secrets and other people's facts, runs a rights check, tests the soul with 8 buyer questions, and uploads only after one yes. prompts/tend-your-soul.md is the weekly follow-up that turns the soul's gap list into better chunks.

Before uploading, any soul file can be checked locally with the server's own parser, scan and company-fact warnings: node prompts/tests/parse-soul.mjs my-soul/<slug>.soul.md. node prompts/tests/run-tests.mjs keeps the prompts, the parser and the scrubber locked together.

Verify it yourself

npm run typecheck
npm run test:node          # unit and property tests (node --test)
npm run test:worker        # Worker tests in workerd with local D1 and R2 (Vitest)
npm run test:security      # the red-team suite
npm run deploy:check       # builds and dry-runs both environments; deploys nothing
node prompts/tests/run-tests.mjs

The counts at each check are in KIROWEEN-LAUNCH-CHECKLIST.md.

Repo map

Path

What is there

src/answer/

The answer service, guards G1 to G5, laundering checks, gap notes, spend cap

src/anthropic/

Soul format and parser, prompts, pick and answer requests, intake

src/scrub/

Upload scan: secrets, contact data, injection, hidden text, look-alikes, company facts

src/mcp/

MCP server: kotsu, kotsu_vision, the key door (OAuth) and the wallet door (x402)

src/ledger/, src/payments/

Double-entry ledger, holds and captures, top-ups, x402, payouts

src/setup-check/

check_setup: Paper #1 as a rule-file check

src/security/

The red-team suite and its runtime fixtures

prompts/

The seller and weekly prompts, their tests, the hand-test plan

scripts/

Local setup, the security battery, the setup check, seeding, smoke tests

design/round-2/landing/

The pages (built into dist/site/)

migrations/

D1 schema, 0001 to 0015

Dependencies

Four runtime packages ship in the Worker (three for the MCP server, task 1.15; one for the key door, task 3.2). Nothing ships to the browser. Versions are pinned exactly.

  • agents (0.33.0, Cloudflare): createMcpHandler from agents/mcp/server serves the stateless Streamable HTTP MCP endpoint at /mcp.

  • @modelcontextprotocol/server (2.4.0, Model Context Protocol project): McpServer, the tool registry and the JSON-RPC protocol layer under it.

  • zod (4.6.7): input and output schemas for the MCP tools. The MCP SDK turns them into JSON Schema for clients.

  • @cloudflare/workers-oauth-provider (1.2.4, Cloudflare): the OAuth 2.1 authorization server behind the key door (src/mcp/door.ts), so claude.ai, Claude Desktop and ChatGPT can connect. It keeps clients, grants and tokens in the KV namespace bound as OAUTH_KV.

The rest are dev dependencies.

  • Wrangler (4.162.0, Cloudflare): runs the Worker locally, builds the bundle and deploys it.

  • Playwright: takes the design screenshots (npm run shoot) and runs the site check (npm run site:check).

  • TypeScript (7.0.2, Microsoft): type checking only (npm run typecheck). It emits nothing.

  • Vitest (4.1.12) and @cloudflare/vitest-plugin (1.8.2, Cloudflare): run the Worker tests in test/worker/ inside the Workers runtime with local D1 and R2 (npm run test:worker).

  • fast-check (4.10.2): property tests.

  • @cloudflare/workers-types (5.20261113.1, Cloudflare) and @types/node (24.10.1): type declarations only.

No new dependency was added for the red-team suite, check_setup or the local setup: they use Node's built-in test runner, node:crypto and the packages above.

npm test runs node --test "src/**/*.test.ts" and then the Worker tests.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers