@toon-protocol/client-mcp 0.1.0 → 0.3.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.
Files changed (36) hide show
  1. package/README.md +19 -38
  2. package/dist/app/index.html +166 -0
  3. package/dist/{chunk-5KFXUT5Q.js → chunk-CQ2QIZ6Z.js} +864 -604
  4. package/dist/chunk-CQ2QIZ6Z.js.map +1 -0
  5. package/dist/{chunk-FSS45ZX3.js → chunk-DLYE6U2Z.js} +1516 -316
  6. package/dist/chunk-DLYE6U2Z.js.map +1 -0
  7. package/dist/{chunk-3NAWISI5.js → chunk-QFHCXJ2V.js} +348 -101
  8. package/dist/chunk-QFHCXJ2V.js.map +1 -0
  9. package/dist/chunk-XV52IHVR.js +977 -0
  10. package/dist/chunk-XV52IHVR.js.map +1 -0
  11. package/dist/daemon.js +3 -4
  12. package/dist/daemon.js.map +1 -1
  13. package/dist/e2e/run-journey.d.ts +1 -0
  14. package/dist/e2e/run-journey.js +19953 -0
  15. package/dist/e2e/run-journey.js.map +1 -0
  16. package/dist/{ed25519-2QVPINLS.js → ed25519-2LFQXLYS.js} +6 -2
  17. package/dist/index.d.ts +282 -68
  18. package/dist/index.js +380 -5
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp.js +39 -6
  21. package/dist/mcp.js.map +1 -1
  22. package/package.json +11 -7
  23. package/dist/anon-proxy-W3KMM7GU-FN7ZJY7P.js +0 -25
  24. package/dist/chunk-3NAWISI5.js.map +0 -1
  25. package/dist/chunk-5KFXUT5Q.js.map +0 -1
  26. package/dist/chunk-FSS45ZX3.js.map +0 -1
  27. package/dist/chunk-SKQTKZIH.js +0 -278
  28. package/dist/chunk-SKQTKZIH.js.map +0 -1
  29. package/dist/chunk-ZQKYZJWT.js +0 -359
  30. package/dist/chunk-ZQKYZJWT.js.map +0 -1
  31. package/dist/ed25519-2QVPINLS.js.map +0 -1
  32. package/dist/gateway-QOK47RKS-SEGTXBR3.js +0 -16
  33. package/dist/gateway-QOK47RKS-SEGTXBR3.js.map +0 -1
  34. package/dist/socks5-WTJBYGME-6COK4LXW.js +0 -139
  35. package/dist/socks5-WTJBYGME-6COK4LXW.js.map +0 -1
  36. /package/dist/{anon-proxy-W3KMM7GU-FN7ZJY7P.js.map → ed25519-2LFQXLYS.js.map} +0 -0
package/README.md CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Let a Claude agent — **Claude Desktop or Claude Code** — act as a full TOON
4
4
  Protocol client: **pay-to-write** publishing, **free** reads/subscriptions,
5
- payment-channel/balance management, and mill swaps.
5
+ payment-channel/balance management, and swaps.
6
6
 
7
7
  The agent surface is an **MCP server** — bin **`toon-mcp`**, which registers
8
8
  with the host under the server name **`toon-client`** (this is the name that
9
9
  appears in Claude's MCP server list and in the `initialize` handshake;
10
10
  `mcpServers.toon` in config is just your local alias). The two long-lived
11
11
  connections that can't live in an ephemeral agent session — a **BTP** session
12
- (paid writes via the connector/apex, optionally over a managed `.anyone`
13
- SOCKS5h proxy) and a **town-relay Nostr-WS** subscription (free reads) — live in
12
+ (paid writes via the connector/apex) and a **town-relay Nostr-WS** subscription
13
+ (free reads) — live in
14
14
  an **always-on detached daemon** (`toon-clientd`). The MCP server is a thin
15
15
  stdio proxy that auto-spawns the daemon and never holds chain keys.
16
16
 
@@ -34,8 +34,8 @@ Claude (Desktop / Code)
34
34
 
35
35
  | Layer | Bin / module | Responsibility |
36
36
  |---|---|---|
37
- | **Daemon** | `toon-clientd` | Owns one `ToonClient` (BTP + managed anon + channels + mnemonic keystore + network targeting) **plus** a persistent town-relay subscription. Loopback HTTP control API, single-instance PID lock, channel nonce-watermark persistence, graceful shutdown. |
38
- | **MCP server** | `toon-mcp` | `@modelcontextprotocol/sdk` stdio server. Maps tools → daemon HTTP; auto-spawns the daemon detached if down; reports "bootstrapping — retry" while anon boots; holds no keys. |
37
+ | **Daemon** | `toon-clientd` | Owns one `ToonClient` (BTP + channels + mnemonic keystore + network targeting) **plus** a persistent town-relay subscription. Loopback HTTP control API, single-instance PID lock, channel nonce-watermark persistence, graceful shutdown. |
38
+ | **MCP server** | `toon-mcp` | `@modelcontextprotocol/sdk` stdio server. Maps tools → daemon HTTP; auto-spawns the daemon detached if down; reports "bootstrapping — retry" while the BTP session comes up; holds no keys. |
39
39
  | **Skill** | `.claude/skills/toon-client/` | Teaches the agent pay-to-write / free-read / settlement semantics. |
40
40
 
41
41
  ## Tools
@@ -80,8 +80,7 @@ On the **first** `toon-clientd run`/`start` (including the auto-spawn from
80
80
  `TOON_CLIENT_KEYSTORE_PASSWORD` when set, otherwise a default password so the
81
81
  identity reloads on every restart with **no env var required**.
82
82
  - **Transport scaffolding** — it writes a starter `~/.toon-client/config.json`
83
- carrying the `btpUrl`/`relayUrl`/`managedAnonProxy` knobs plus a `_help`
84
- block documenting direct-vs-`.anyone` selection.
83
+ carrying the `btpUrl`/`relayUrl` knobs plus a `_help` block documenting them.
85
84
 
86
85
  The one thing you must supply is the apex you pay: set **`btpUrl`** (and usually
87
86
  `relayUrl`) in the scaffolded config, then publish. Everything below is for
@@ -99,12 +98,12 @@ can supply your own via env or an imported keystore.
99
98
  {
100
99
  "network": "testnet", // settlement presets (#209)
101
100
  "keystorePath": "~/.toon-client/keystore.json",
102
- "btpUrl": "ws://<apex-host>.anyone:3000/btp",
103
- "relayUrl": "wss://<relay-host>.anyone/", // free reads
101
+ "btpUrl": "ws://<apex-host>:3000/btp",
102
+ "relayUrl": "ws://<relay-host>:7100", // free reads
104
103
  "destination": "g.townhouse.town",
105
104
  "feePerEvent": "1",
106
105
  "httpPort": 8787,
107
- // HS / direct-apex mode: bootstrap finds 0 peers, so name the apex's
106
+ // Direct-apex mode: bootstrap finds 0 peers, so name the apex's
108
107
  // settlement address directly (mirrors the docker entrypoint):
109
108
  "apex": {
110
109
  "destination": "g.townhouse.town",
@@ -120,26 +119,12 @@ can supply your own via env or an imported keystore.
120
119
  ```
121
120
 
122
121
  Environment overrides: `TOON_CLIENT_MNEMONIC`, `TOON_CLIENT_KEYSTORE_PASSWORD`,
123
- `TOON_CLIENT_BTP_URL`, `TOON_CLIENT_RELAY_URL`, `TOON_CLIENT_SOCKS`,
122
+ `TOON_CLIENT_BTP_URL`, `TOON_CLIENT_RELAY_URL`,
124
123
  `TOON_CLIENT_HTTP_PORT`, `TOON_CLIENT_NETWORK`, `TOON_CLIENT_HOME`.
125
124
 
126
- **Transport is inferred from the URLs no separate "direct vs hidden-service"
127
- switch.** The daemon parses the host of each URL independently:
128
-
129
- - `btpUrl`/`relayUrl` on a normal host (`ws://1.2.3.4:3000/btp`, `wss://…`) →
130
- **direct**, dialed as-is.
131
- - `btpUrl` on a `.anyone` host → the ToonClient auto-starts a managed `anon`
132
- SOCKS5h proxy and routes paid writes (and reads) through it.
133
- - `btpUrl` **direct** but `relayUrl` on a `.anyone` host → the daemon starts its
134
- own managed `anon` proxy just for the free-read subscription; paid writes stay
135
- direct. (Mixed transports — a direct apex with a hidden-service relay — work
136
- out of the box.)
137
-
138
- No explicit `socksProxy` is needed for any of these. Set `socksProxy` only to
139
- point at your own external proxy, or `managedAnonProxy: false` to opt out of the
140
- managed proxy entirely. The first bootstrap pays the anon warm-up cost (~30–90s)
141
- **once** — the detached daemon then stays up. A read-proxy failure surfaces under
142
- `relay.proxyError` in `toon_status` and never blocks direct paid writes.
125
+ `btpUrl` (paid writes over BTP) and `relayUrl` (free reads over Nostr-WS) are
126
+ dialed directly as-is. The first bootstrap brings up the BTP session **once**
127
+ the detached daemon then stays up.
143
128
 
144
129
  ### Create an encrypted keystore
145
130
 
@@ -197,7 +182,7 @@ Add to `claude_desktop_config.json`:
197
182
 
198
183
  Then restart Claude Desktop. The TOON tools appear in the tool list; the first
199
184
  `toon_publish` after a cold start may report "bootstrapping — retry" while the
200
- anon proxy + BTP session come up.
185
+ BTP session comes up.
201
186
 
202
187
  ## Usage example
203
188
 
@@ -213,8 +198,8 @@ The agent runs:
213
198
  { "ready": true, "bootstrapping": false, "settlementChain": "evm",
214
199
  "relay": { "connected": true }, "identity": { "evmAddress": "0x99ed…" } }
215
200
  ```
216
- (If it returns `bootstrapping: true` or a "retry shortly" message, wait ~30–90s
217
- for the anon proxy + BTP session, then retry.)
201
+ (If it returns `bootstrapping: true` or a "retry shortly" message, wait a few
202
+ seconds for the BTP session, then retry.)
218
203
 
219
204
  2. **`toon_subscribe`** for its own author so it can read the note back:
220
205
  ```json
@@ -273,14 +258,10 @@ receive a target-chain claim.
273
258
 
274
259
  ```bash
275
260
  pnpm --filter @toon-protocol/client-mcp test # unit
276
- RUN_LIVE_HS_E2E=1 …env… \
277
- pnpm --filter @toon-protocol/client-mcp test:integration # gated live-HS round-trip
261
+ pnpm --filter @toon-protocol/client-mcp test:integration # gated integration suite
278
262
  ```
279
263
 
280
- The gated integration test boots the daemon against a live `.anyone` HS apex,
281
- publishes a paid event, reads it back through the subscription, verifies the
282
- channel nonce advanced, restarts the daemon, and confirms the nonce watermark
283
- persisted. See `src/__integration__/`.
264
+ The integration suite lives in `src/__integration__/`.
284
265
 
285
266
  ## Publishing
286
267
 
@@ -295,7 +276,7 @@ are **bundled into `dist`** at build time (tsup `noExternal`), so the published
295
276
  `package.json` carries **zero `@toon-protocol/*` runtime deps** — only npm
296
277
  packages (`fastify`, `@modelcontextprotocol/sdk`, `nostr-tools`, `viem`, `ws`,
297
278
  `@toon-format/toon`) plus optional chain libs (`o1js`, `mina-signer`,
298
- `@solana/web3.js`, `socks-proxy-agent`) installed only when you use those chains.
279
+ `@solana/web3.js`) installed only when you use those chains.
299
280
  A guard test (`src/package-structure.test.ts`) fails the build if a
300
281
  `@toon-protocol/*` runtime dep ever leaks in.
301
282