crowdcode-mcp 0.3.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,22 +11,38 @@ sent**.
11
11
  ## Install
12
12
 
13
13
  ```bash
14
- claude mcp add --scope user crowdcode -- npx -y crowdcode-mcp
14
+ npx -y crowdcode-mcp@latest install
15
15
  ```
16
16
 
17
- Or the generic `mcpServers` JSON used by most clients (Cursor, VS Code, Codex,
18
- Claude Desktop):
17
+ The installer detects Codex, Claude Code, Cursor, and Claude Desktop; installs
18
+ the eager CrowdCode skill; and configures the local MCP server. Restart the
19
+ configured clients afterward. Useful non-interactive forms:
20
+
21
+ ```bash
22
+ npx -y crowdcode-mcp@latest install --all-detected --yes
23
+ npx -y crowdcode-mcp@latest install --client codex --client claude-code --yes
24
+ npx -y crowdcode-mcp@latest doctor
25
+ ```
26
+
27
+ For another MCP client, use the generic configuration and install the
28
+ CrowdCode `SKILL.md` in that client's global skill directory:
19
29
 
20
30
  ```json
21
31
  {
22
32
  "mcpServers": {
23
- "crowdcode": { "command": "npx", "args": ["-y", "crowdcode-mcp"] }
33
+ "crowdcode": {
34
+ "command": "npx",
35
+ "args": ["-y", "crowdcode-mcp@latest"]
36
+ }
24
37
  }
25
38
  }
26
39
  ```
27
40
 
28
41
  No API key or configuration required. Node 20+.
29
42
 
43
+ Codex plugin source is distributed in `plugins/crowdcode`. Claude Desktop
44
+ release artifacts use the platform-specific `.mcpb` format.
45
+
30
46
  ## Tools
31
47
 
32
48
  ### `get_service_score` — call this before paying
@@ -61,7 +77,7 @@ evidence*, not as a bad service, and fall back to price and your spend policy.
61
77
 
62
78
  The algorithm is public: [docs/SCORING.md][scoring].
63
79
 
64
- ### `review_service` — call this after every paid use
80
+ ### `review_service` — call this after every uniquely paid use
65
81
 
66
82
  Success, slow response, or failure. A bad outcome is not a reason to skip the
67
83
  review; it **is** the review — rate 1–2 and put the failure in the reason.
@@ -80,8 +96,9 @@ proofs from the *actual payment*, not from a directory listing:
80
96
  x402, `Payment-Receipt` for mppx). Optional: pass it when you have it, but
81
97
  verified status comes from the on-chain transfer either way. The response's
82
98
  `payment_verification_level` is the source of truth. On-chain verification
83
- covers x402 on Base and mppx on Tempo; payments settled elsewhere (e.g.
84
- Solana) are accepted but stay `signature_only`.
99
+ supports x402 USDC on Base and mppx on Tempo. Solana and other chains are
100
+ rejected as unsupported; new machine-payment reviews never fall back to
101
+ `signature_only`.
85
102
  - `payment_target_ref` — the real payee (the 402 challenge recipient / on-chain
86
103
  `Transfer` `to`), not a bazaar-advertised `payTo`.
87
104
 
@@ -106,14 +123,12 @@ The signing path never transmits raw review text — only a SHA-256 hash.
106
123
 
107
124
  ## Wallet
108
125
 
109
- Reviews are signed by the wallet that paid, resolved in this order:
110
-
111
- 1. `X402_PRIVATE_KEY`
112
- 2. `~/.agentcash/wallet.json` (shared with [agentcash][agentcash])
113
- 3. lazily auto-created in that same format with `0600` permissions
126
+ Reviews are signed by `~/.agentcash/wallet.json` (shared with
127
+ [agentcash][agentcash]), lazily auto-created with `0600` permissions when
128
+ needed. Environment private keys are not accepted.
114
129
 
115
130
  An existing wallet file is never overwritten. Responses report
116
- `wallet_source` (`env` | `agentcash` | `none`).
131
+ `wallet_source` (`agentcash` | `none`).
117
132
 
118
133
  You must sign with a self-custody key that can produce an EIP-191 signature and
119
134
  that is the same wallet that paid. Custodial or login-only wallets will not
@@ -123,25 +138,23 @@ work.
123
138
 
124
139
  | Variable | Default | Purpose |
125
140
  |---|---|---|
126
- | `X402_PRIVATE_KEY` | — | Signing key (takes precedence over the wallet file) |
127
141
  | `CROWDCODE_WALLET_DIR` | `~/.agentcash` | Where the wallet file lives |
128
142
  | `CROWDCODE_DISABLE_WALLET_CREATE` | unset | Never auto-create a wallet |
129
143
  | `CROWDCODE_BACKEND_URL` | hosted backend | Point at your own CrowdCode backend |
130
- | `CROWDCODE_UPSTREAM_TIMEOUT_MS` | `60000` | Backend timeout (the hosted tier cold-starts) |
144
+ | `CROWDCODE_UPSTREAM_TIMEOUT_MS` | `15000` | Backend timeout |
131
145
  | `CROWDCODE_CACHE_DIR` | `~/.cache/crowdcode-mcp` | Redaction model cache |
132
146
  | `CROWDCODE_DISABLE_MODEL` | unset | Deterministic redaction only, no model download |
133
147
 
134
148
  ## Rate limits
135
149
 
136
- Keyed on wallet identity, rolling 24 hours: **1 review per service per wallet**,
137
- **5 service requests per wallet**. Rejections carry `retry_after_seconds` and a
138
- `next_step` object with the exact command or retry that fixes them — failure
139
- responses generally do.
150
+ Every unique verified payment may be reviewed. Reviews from one wallet for one
151
+ service are aggregated into one capped UTC-day scoring bucket. Service requests
152
+ remain limited to **5 per wallet per rolling 24 hours**.
140
153
 
141
154
  ## Links
142
155
 
143
156
  [Source and issues][repo] · [Scoring algorithm][scoring] · MIT licensed ·
144
- requires CrowdCode backend 0.3.0.
157
+ requires CrowdCode backend 0.5.0.
145
158
 
146
159
  [repo]: https://github.com/sr33j/crowdcode-mcp
147
160
  [scoring]: https://github.com/sr33j/crowdcode-mcp/blob/main/docs/SCORING.md
@@ -32,15 +32,11 @@ async function loadWallet(opts = {}) {
32
32
  return result;
33
33
  }
34
34
  async function load(env, dir, autoCreate) {
35
- const envKey = env.X402_PRIVATE_KEY?.trim();
36
- if (envKey) {
37
- if (!PRIVATE_KEY_RE.test(envKey)) {
38
- return none(
39
- "X402_PRIVATE_KEY is set but is not a 0x-prefixed 32-byte hex key"
40
- );
41
- }
42
- const account2 = privateKeyToAccount(envKey);
43
- return { source: "env", account: account2, address: account2.address };
35
+ if (Object.prototype.hasOwnProperty.call(env, "X402_PRIVATE_KEY")) {
36
+ return none(
37
+ "X402_PRIVATE_KEY is no longer supported; remove it from the CrowdCode process and use the local agentcash wallet file instead",
38
+ "wallet_configuration_error"
39
+ );
44
40
  }
45
41
  const file = join(dir, "wallet.json");
46
42
  let raw = null;
@@ -104,8 +100,8 @@ function parseStored(raw, file) {
104
100
  }
105
101
  return { source: "agentcash", account, address: getAddress(parsed.data.address) };
106
102
  }
107
- function none(error) {
108
- return { source: "none", account: null, address: null, error };
103
+ function none(error, errorCode) {
104
+ return { source: "none", account: null, address: null, error, errorCode };
109
105
  }
110
106
 
111
107
  // src/config.ts
@@ -117,8 +113,7 @@ function getConfig(env = process.env) {
117
113
  backendUrl: env.CROWDCODE_BACKEND_URL ?? "https://crowdcode-backend.onrender.com/mcp",
118
114
  cacheDir: env.CROWDCODE_CACHE_DIR ?? join2(homedir2(), ".cache", "crowdcode-mcp"),
119
115
  disableModel: TRUTHY.has((env.CROWDCODE_DISABLE_MODEL ?? "").toLowerCase()),
120
- // Generous default: the free-tier Render backend cold-starts slowly.
121
- upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 6e4),
116
+ upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 15e3),
122
117
  // Signing wallet shared with agentcash (~/.agentcash/wallet.json).
123
118
  walletDir: env.CROWDCODE_WALLET_DIR ?? defaultWalletDir(),
124
119
  walletAutoCreate: !TRUTHY.has(
@@ -131,4 +126,4 @@ export {
131
126
  loadWallet,
132
127
  getConfig
133
128
  };
134
- //# sourceMappingURL=chunk-SKCQBRTB.js.map
129
+ //# sourceMappingURL=chunk-OFN5EBG5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wallet.ts","../src/config.ts"],"sourcesContent":["/**\n * Local signing wallet, shared with agentcash.\n *\n * Reads (and lazily creates) the same wallet file agentcash uses —\n * ~/.agentcash/wallet.json — so reviews are signed by the identical identity\n * that pays for x402/mppx services. Private keys supplied through environment\n * variables are deliberately unsupported: the agent gets addresses and\n * canonical review signatures, never a key-ingestion API.\n * 1. An existing file is zod-validated and its address cross-checked\n * against the key; an unreadable or invalid file is NEVER overwritten.\n * 2. A missing file is created on demand (opt-out via\n * CROWDCODE_DISABLE_WALLET_CREATE) with agentcash's exact shape and\n * 0600 permissions, so a later agentcash install picks up the same\n * wallet.\n */\n\nimport { chmod, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport {\n generatePrivateKey,\n privateKeyToAccount,\n type PrivateKeyAccount,\n} from \"viem/accounts\";\nimport { getAddress } from \"viem/utils\";\nimport { z } from \"zod\";\n\nexport type WalletSource = \"agentcash\" | \"none\";\n\nexport interface LoadedWallet {\n source: WalletSource;\n account: PrivateKeyAccount | null;\n address: string | null;\n error?: string;\n errorCode?: string;\n created?: boolean;\n}\n\nexport interface LoadWalletOptions {\n env?: NodeJS.ProcessEnv;\n walletDir?: string;\n autoCreate?: boolean;\n}\n\nconst PRIVATE_KEY_RE = /^0x[a-fA-F0-9]{64}$/;\n\n// Same shape agentcash's storedWalletSchema validates (src/wallet/evm.ts).\nconst storedWalletSchema = z.object({\n privateKey: z.string().regex(PRIVATE_KEY_RE),\n address: z.string().regex(/^0x[a-fA-F0-9]{40}$/),\n createdAt: z.string(),\n});\n\nexport function defaultWalletDir(): string {\n return join(homedir(), \".agentcash\");\n}\n\nlet memo: LoadedWallet | null = null;\n\n/** Test hook: clear the process-level memo. */\nexport function resetWalletCache(): void {\n memo = null;\n}\n\nexport async function loadWallet(\n opts: LoadWalletOptions = {},\n): Promise<LoadedWallet> {\n const isDefault = opts.env === undefined && opts.walletDir === undefined;\n if (isDefault && memo) return memo;\n\n const result = await load(\n opts.env ?? process.env,\n opts.walletDir ?? defaultWalletDir(),\n opts.autoCreate ?? false,\n );\n // Memoize only usable wallets: a \"none\" result must stay retryable (a later\n // call with autoCreate, or after the user installs agentcash, should see\n // the new state). `created` is dropped from the memo so only the call that\n // actually wrote the file reports it.\n if (isDefault && result.source !== \"none\") {\n memo = { ...result, created: undefined };\n }\n return result;\n}\n\nasync function load(\n env: NodeJS.ProcessEnv,\n dir: string,\n autoCreate: boolean,\n): Promise<LoadedWallet> {\n if (Object.prototype.hasOwnProperty.call(env, \"X402_PRIVATE_KEY\")) {\n return none(\n \"X402_PRIVATE_KEY is no longer supported; remove it from the CrowdCode \" +\n \"process and use the local agentcash wallet file instead\",\n \"wallet_configuration_error\",\n );\n }\n\n const file = join(dir, \"wallet.json\");\n let raw: string | null = null;\n try {\n raw = await readFile(file, \"utf8\");\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") {\n return none(`wallet file is unreadable: ${(err as Error).message}`);\n }\n }\n\n if (raw !== null) {\n return parseStored(raw, file);\n }\n\n if (!autoCreate) {\n return none();\n }\n\n const privateKey = generatePrivateKey();\n const account = privateKeyToAccount(privateKey);\n const stored = {\n privateKey,\n address: account.address,\n createdAt: new Date().toISOString(),\n };\n try {\n await mkdir(dir, { recursive: true, mode: 0o700 });\n // \"wx\" fails on a concurrently created file instead of clobbering it.\n await writeFile(file, JSON.stringify(stored, null, 2), {\n mode: 0o600,\n flag: \"wx\",\n });\n await chmod(file, 0o600);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"EEXIST\") {\n try {\n return parseStored(await readFile(file, \"utf8\"), file);\n } catch (readErr) {\n return none(`wallet file is unreadable: ${(readErr as Error).message}`);\n }\n }\n return none(`could not create wallet file: ${(err as Error).message}`);\n }\n return { source: \"agentcash\", account, address: account.address, created: true };\n}\n\nfunction parseStored(raw: string, file: string): LoadedWallet {\n let parsedJson: unknown;\n try {\n parsedJson = JSON.parse(raw);\n } catch {\n return none(`wallet file is not valid JSON: ${file} — fix or remove it`);\n }\n const parsed = storedWalletSchema.safeParse(parsedJson);\n if (!parsed.success) {\n return none(\n `wallet file does not match the agentcash wallet shape: ${file} — ` +\n \"fix or remove it\",\n );\n }\n const account = privateKeyToAccount(parsed.data.privateKey as `0x${string}`);\n // Defense against a swapped/corrupted file: the stored address must be the\n // one the stored key derives.\n if (getAddress(account.address) !== getAddress(parsed.data.address)) {\n return none(\n `wallet file address does not match its private key: ${file} — ` +\n \"fix or remove it\",\n );\n }\n return { source: \"agentcash\", account, address: getAddress(parsed.data.address) };\n}\n\nfunction none(error?: string, errorCode?: string): LoadedWallet {\n return { source: \"none\", account: null, address: null, error, errorCode };\n}\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { defaultWalletDir } from \"./wallet.js\";\n\nexport interface Config {\n backendUrl: string;\n cacheDir: string;\n disableModel: boolean;\n upstreamTimeoutMs: number;\n walletDir: string;\n walletAutoCreate: boolean;\n}\n\nconst TRUTHY = new Set([\"1\", \"true\", \"yes\"]);\n\nexport function getConfig(env: NodeJS.ProcessEnv = process.env): Config {\n return {\n backendUrl:\n env.CROWDCODE_BACKEND_URL ?? \"https://crowdcode-backend.onrender.com/mcp\",\n cacheDir: env.CROWDCODE_CACHE_DIR ?? join(homedir(), \".cache\", \"crowdcode-mcp\"),\n disableModel: TRUTHY.has((env.CROWDCODE_DISABLE_MODEL ?? \"\").toLowerCase()),\n upstreamTimeoutMs: Number(env.CROWDCODE_UPSTREAM_TIMEOUT_MS ?? 15_000),\n // Signing wallet shared with agentcash (~/.agentcash/wallet.json).\n walletDir: env.CROWDCODE_WALLET_DIR ?? defaultWalletDir(),\n walletAutoCreate: !TRUTHY.has(\n (env.CROWDCODE_DISABLE_WALLET_CREATE ?? \"\").toLowerCase(),\n ),\n };\n}\n"],"mappings":";AAgBA,SAAS,OAAO,OAAO,UAAU,iBAAiB;AAClD,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,kBAAkB;AAC3B,SAAS,SAAS;AAmBlB,IAAM,iBAAiB;AAGvB,IAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc;AAAA,EAC3C,SAAS,EAAE,OAAO,EAAE,MAAM,qBAAqB;AAAA,EAC/C,WAAW,EAAE,OAAO;AACtB,CAAC;AAEM,SAAS,mBAA2B;AACzC,SAAO,KAAK,QAAQ,GAAG,YAAY;AACrC;AAEA,IAAI,OAA4B;AAOhC,eAAsB,WACpB,OAA0B,CAAC,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