@toon-protocol/client-mcp 0.26.2
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/LICENSE +190 -0
- package/README.md +261 -0
- package/dist/anon-proxy-6N362VEV-M7AX2QD7.js +24 -0
- package/dist/anon-proxy-6N362VEV-M7AX2QD7.js.map +1 -0
- package/dist/chunk-245J23EB.js +278 -0
- package/dist/chunk-245J23EB.js.map +1 -0
- package/dist/chunk-2SGZPDGE.js +625 -0
- package/dist/chunk-2SGZPDGE.js.map +1 -0
- package/dist/chunk-32QD72IL.js +83 -0
- package/dist/chunk-32QD72IL.js.map +1 -0
- package/dist/chunk-5YIZ2JQO.js +205 -0
- package/dist/chunk-5YIZ2JQO.js.map +1 -0
- package/dist/chunk-LR7W2ISE.js +657 -0
- package/dist/chunk-LR7W2ISE.js.map +1 -0
- package/dist/chunk-QTDCFXPF.js +2802 -0
- package/dist/chunk-QTDCFXPF.js.map +1 -0
- package/dist/chunk-VA7XC4FD.js +185 -0
- package/dist/chunk-VA7XC4FD.js.map +1 -0
- package/dist/chunk-WMYY5I3H.js +10818 -0
- package/dist/chunk-WMYY5I3H.js.map +1 -0
- package/dist/daemon.d.ts +1 -0
- package/dist/daemon.js +137 -0
- package/dist/daemon.js.map +1 -0
- package/dist/ed25519-OFFWPWRE.js +26 -0
- package/dist/ed25519-OFFWPWRE.js.map +1 -0
- package/dist/gateway-QOK47RKS-HB65KIKC.js +15 -0
- package/dist/gateway-QOK47RKS-HB65KIKC.js.map +1 -0
- package/dist/hmac-7WSXTWW4.js +11 -0
- package/dist/hmac-7WSXTWW4.js.map +1 -0
- package/dist/index.d.ts +642 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +80 -0
- package/dist/mcp.js.map +1 -0
- package/dist/sha512-LMOIUNFJ.js +33 -0
- package/dist/sha512-LMOIUNFJ.js.map +1 -0
- package/dist/socks5-WTJBYGME-IXWLQDE7.js +138 -0
- package/dist/socks5-WTJBYGME-IXWLQDE7.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 TOON Protocol Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# @toon-protocol/client-mcp
|
|
2
|
+
|
|
3
|
+
Let a Claude agent — **Claude Desktop or Claude Code** — act as a full TOON
|
|
4
|
+
Protocol client: **pay-to-write** publishing, **free** reads/subscriptions,
|
|
5
|
+
payment-channel/balance management, and mill swaps.
|
|
6
|
+
|
|
7
|
+
The agent surface is an **MCP server** — bin **`toon-mcp`**, which registers
|
|
8
|
+
with the host under the server name **`toon-client`** (this is the name that
|
|
9
|
+
appears in Claude's MCP server list and in the `initialize` handshake;
|
|
10
|
+
`mcpServers.toon` in config is just your local alias). The two long-lived
|
|
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
|
|
14
|
+
an **always-on detached daemon** (`toon-clientd`). The MCP server is a thin
|
|
15
|
+
stdio proxy that auto-spawns the daemon and never holds chain keys.
|
|
16
|
+
|
|
17
|
+
| | Name |
|
|
18
|
+
|---|---|
|
|
19
|
+
| npm package | `@toon-protocol/client-mcp` |
|
|
20
|
+
| MCP server name (handshake) | `toon-client` |
|
|
21
|
+
| MCP server bin | `toon-mcp` |
|
|
22
|
+
| Daemon bin | `toon-clientd` |
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Claude (Desktop / Code)
|
|
26
|
+
│ stdio (MCP)
|
|
27
|
+
▼
|
|
28
|
+
toon-mcp ──HTTP──▶ toon-clientd (detached, always-on)
|
|
29
|
+
├─ ToonClient: BTP session + payment channels + signer
|
|
30
|
+
└─ RelaySubscription: persistent town-relay Nostr-WS
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Architecture
|
|
34
|
+
|
|
35
|
+
| Layer | Bin / module | Responsibility |
|
|
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. |
|
|
39
|
+
| **Skill** | `.claude/skills/toon-client/` | Teaches the agent pay-to-write / free-read / settlement semantics. |
|
|
40
|
+
|
|
41
|
+
## Tools
|
|
42
|
+
|
|
43
|
+
The `toon-client` MCP server exposes **8 tools**:
|
|
44
|
+
|
|
45
|
+
| MCP tool | Daemon endpoint | Backing |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `toon_status` | `GET /status` | ready/bootstrapping, transport, relay health, per-chain settlement, active chain |
|
|
48
|
+
| `toon_identity` | `GET /status` | Nostr pubkey + EVM/Solana/Mina addresses (no keys) |
|
|
49
|
+
| `toon_publish(event,{destination?,fee?})` | `POST /publish` | `signBalanceProof` + `publishEvent` (paid write) |
|
|
50
|
+
| `toon_subscribe(filters,{subId?})` | `POST /subscribe` | register a persistent free-read subscription |
|
|
51
|
+
| `toon_read({subId?,cursor?,limit?})` | `GET /events` | drain buffered events by cursor (free) |
|
|
52
|
+
| `toon_open_channel({destination?})` | `POST /channels` | `openChannel` (pre-open / fetch a channel) |
|
|
53
|
+
| `toon_channels` | `GET /channels` | `getTrackedChannels` + nonce watermark + cumulative spend |
|
|
54
|
+
| `toon_swap(destination,amount,{toonData?})` | `POST /swap` | `sendSwapPacket` (mill swap) |
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pnpm add -g @toon-protocol/client-mcp # or use npx/pnpm dlx
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This installs two bins: `toon-clientd` and `toon-mcp`.
|
|
63
|
+
|
|
64
|
+
## Configure the daemon
|
|
65
|
+
|
|
66
|
+
The daemon reads `~/.toon-client/config.json` (override with `TOON_CLIENT_CONFIG`).
|
|
67
|
+
The **mnemonic is never stored in plaintext by default** — supply it via env or an
|
|
68
|
+
encrypted keystore (scrypt + AES-256-GCM, mode 0600).
|
|
69
|
+
|
|
70
|
+
```jsonc
|
|
71
|
+
// ~/.toon-client/config.json
|
|
72
|
+
{
|
|
73
|
+
"network": "testnet", // settlement presets (#209)
|
|
74
|
+
"keystorePath": "~/.toon-client/keystore.json",
|
|
75
|
+
"btpUrl": "ws://<apex-host>.anyone:3000/btp",
|
|
76
|
+
"relayUrl": "wss://<relay-host>.anyone/", // free reads
|
|
77
|
+
"destination": "g.townhouse.town",
|
|
78
|
+
"feePerEvent": "1",
|
|
79
|
+
"httpPort": 8787,
|
|
80
|
+
// HS / direct-apex mode: bootstrap finds 0 peers, so name the apex's
|
|
81
|
+
// settlement address directly (mirrors the docker entrypoint):
|
|
82
|
+
"apex": {
|
|
83
|
+
"destination": "g.townhouse.town",
|
|
84
|
+
"peerId": "town",
|
|
85
|
+
"chain": "evm",
|
|
86
|
+
"chainKey": "evm:base:84532",
|
|
87
|
+
"chainId": 84532,
|
|
88
|
+
"settlementAddress": "0x<apex-receive-addr>",
|
|
89
|
+
"tokenAddress": "0x<usdc>",
|
|
90
|
+
"tokenNetwork": "0x<token-network>"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Environment overrides: `TOON_CLIENT_MNEMONIC`, `TOON_CLIENT_KEYSTORE_PASSWORD`,
|
|
96
|
+
`TOON_CLIENT_BTP_URL`, `TOON_CLIENT_RELAY_URL`, `TOON_CLIENT_SOCKS`,
|
|
97
|
+
`TOON_CLIENT_HTTP_PORT`, `TOON_CLIENT_NETWORK`, `TOON_CLIENT_HOME`.
|
|
98
|
+
|
|
99
|
+
The managed `.anyone` SOCKS5h proxy auto-starts when `btpUrl` is a `.anyone`
|
|
100
|
+
host and no explicit `socksProxy` is set. The first bootstrap pays the anon
|
|
101
|
+
warm-up cost (~30–90s) **once** — the detached daemon then stays up.
|
|
102
|
+
|
|
103
|
+
### Create an encrypted keystore
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
TOON_CLIENT_MNEMONIC="word word ..." \
|
|
107
|
+
TOON_CLIENT_KEYSTORE_PASSWORD="…" \
|
|
108
|
+
node -e "import('@toon-protocol/client').then(m => m.importKeystore(process.env.HOME+'/.toon-client/keystore.json', process.env.TOON_CLIENT_MNEMONIC, process.env.TOON_CLIENT_KEYSTORE_PASSWORD))"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Daemon lifecycle (Claude Code only — it has a shell)
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
toon-clientd start # spawn detached, wait until reachable
|
|
115
|
+
toon-clientd status # print status JSON
|
|
116
|
+
toon-clientd stop # SIGTERM the locked PID
|
|
117
|
+
toon-clientd run # run in the foreground (what the detached spawn runs)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The MCP server auto-spawns the daemon, so `start` is optional.
|
|
121
|
+
|
|
122
|
+
## Register with Claude
|
|
123
|
+
|
|
124
|
+
### Claude Code
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
claude mcp add toon -- toon-mcp
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
…or add to `.mcp.json` in your project:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"mcpServers": {
|
|
135
|
+
"toon": { "command": "toon-mcp" }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Claude Desktop
|
|
141
|
+
|
|
142
|
+
Add to `claude_desktop_config.json`:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"mcpServers": {
|
|
147
|
+
"toon": {
|
|
148
|
+
"command": "toon-mcp",
|
|
149
|
+
"env": {
|
|
150
|
+
"TOON_CLIENT_KEYSTORE_PASSWORD": "…"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Then restart Claude Desktop. The TOON tools appear in the tool list; the first
|
|
158
|
+
`toon_publish` after a cold start may report "bootstrapping — retry" while the
|
|
159
|
+
anon proxy + BTP session come up.
|
|
160
|
+
|
|
161
|
+
## Usage example
|
|
162
|
+
|
|
163
|
+
You don't call these tools by hand — the agent does, in response to plain
|
|
164
|
+
requests. A typical "post a note, then read it back" flow:
|
|
165
|
+
|
|
166
|
+
> **You:** Post a note to TOON saying "gm from my agent", then show me when it lands.
|
|
167
|
+
|
|
168
|
+
The agent runs:
|
|
169
|
+
|
|
170
|
+
1. **`toon_status`** → confirm the client is up.
|
|
171
|
+
```json
|
|
172
|
+
{ "ready": true, "bootstrapping": false, "settlementChain": "evm",
|
|
173
|
+
"relay": { "connected": true }, "identity": { "evmAddress": "0x99ed…" } }
|
|
174
|
+
```
|
|
175
|
+
(If it returns `bootstrapping: true` or a "retry shortly" message, wait ~30–90s
|
|
176
|
+
for the anon proxy + BTP session, then retry.)
|
|
177
|
+
|
|
178
|
+
2. **`toon_subscribe`** for its own author so it can read the note back:
|
|
179
|
+
```json
|
|
180
|
+
{ "filters": { "authors": ["<my-hex-pubkey>"], "kinds": [1] } }
|
|
181
|
+
→ { "subId": "sub-1" }
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
3. **`toon_publish`** the signed kind:1 event (the daemon signs the payment-channel
|
|
185
|
+
claim and forwards it over BTP):
|
|
186
|
+
```json
|
|
187
|
+
{ "event": { "kind": 1, "content": "gm from my agent", "id": "…", "sig": "…", … } }
|
|
188
|
+
→ { "eventId": "0d0c1f98…", "channelId": "0xc73a77…", "nonce": 7 }
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
4. **`toon_read`** until the event appears (free; cursor long-poll):
|
|
192
|
+
```json
|
|
193
|
+
{ "subId": "sub-1" }
|
|
194
|
+
→ { "events": [ { "id": "0d0c1f98…", "content": "gm from my agent", … } ],
|
|
195
|
+
"cursor": 12, "hasMore": false }
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
5. **`toon_channels`** to show what it cost:
|
|
199
|
+
```json
|
|
200
|
+
→ { "channels": [ { "channelId": "0xc73a77…", "nonce": 7, "cumulativeAmount": "7" } ] }
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Other common calls: **`toon_open_channel`** to pre-open a channel before a burst
|
|
204
|
+
of publishes, and **`toon_swap({ destination, amount })`** to pay a mill peer and
|
|
205
|
+
receive a target-chain claim.
|
|
206
|
+
|
|
207
|
+
> **CLI equivalent** (handy for scripting/debugging — the MCP tools map 1:1 to
|
|
208
|
+
> these daemon endpoints):
|
|
209
|
+
> ```bash
|
|
210
|
+
> toon-clientd start # boot the daemon
|
|
211
|
+
> curl -s localhost:8787/status | jq # toon_status
|
|
212
|
+
> curl -s -XPOST localhost:8787/subscribe \
|
|
213
|
+
> -H content-type:application/json \
|
|
214
|
+
> -d '{"filters":{"authors":["<hex>"],"kinds":[1]}}' # toon_subscribe
|
|
215
|
+
> curl -s -XPOST localhost:8787/publish \
|
|
216
|
+
> -H content-type:application/json \
|
|
217
|
+
> -d '{"event":{…signed kind:1…}}' # toon_publish
|
|
218
|
+
> curl -s 'localhost:8787/events?subId=sub-1' | jq # toon_read
|
|
219
|
+
> curl -s localhost:8787/channels | jq # toon_channels
|
|
220
|
+
> ```
|
|
221
|
+
|
|
222
|
+
## Security
|
|
223
|
+
|
|
224
|
+
- The daemon holds the mnemonic/keystore; the agent sees **only addresses and
|
|
225
|
+
results**, never private keys.
|
|
226
|
+
- A single-instance PID lock prevents two daemons from racing the channel nonce
|
|
227
|
+
watermark (which would corrupt the payment proof).
|
|
228
|
+
- The control plane binds `127.0.0.1` only (no auth layer — it never leaves
|
|
229
|
+
loopback).
|
|
230
|
+
|
|
231
|
+
## Tests
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
pnpm --filter @toon-protocol/client-mcp test # unit
|
|
235
|
+
RUN_LIVE_HS_E2E=1 …env… \
|
|
236
|
+
pnpm --filter @toon-protocol/client-mcp test:integration # gated live-HS round-trip
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The gated integration test boots the daemon against a live `.anyone` HS apex,
|
|
240
|
+
publishes a paid event, reads it back through the subscription, verifies the
|
|
241
|
+
channel nonce advanced, restarts the daemon, and confirms the nonce watermark
|
|
242
|
+
persisted. See `src/__integration__/`.
|
|
243
|
+
|
|
244
|
+
## Publishing
|
|
245
|
+
|
|
246
|
+
This package is **published to npm automatically by CI/CD**, in lockstep with the
|
|
247
|
+
repo's release tag (the same `vX.Y.Z` semantic-release cuts for
|
|
248
|
+
`@toon-protocol/townhouse`). On a release, `publish-townhouse-images.yml` builds
|
|
249
|
+
this package, sets its version to the tag, and runs
|
|
250
|
+
`pnpm --filter @toon-protocol/client-mcp publish --access public`.
|
|
251
|
+
|
|
252
|
+
It is **self-contained**: its `@toon-protocol/*` workspace deps (`client`, `core`)
|
|
253
|
+
are **bundled into `dist`** at build time (tsup `noExternal`), so the published
|
|
254
|
+
`package.json` carries **zero `@toon-protocol/*` runtime deps** — only npm
|
|
255
|
+
packages (`fastify`, `@modelcontextprotocol/sdk`, `nostr-tools`, `viem`, `ws`,
|
|
256
|
+
`@toon-format/toon`) plus optional chain libs (`o1js`, `mina-signer`,
|
|
257
|
+
`@solana/web3.js`, `socks-proxy-agent`) installed only when you use those chains.
|
|
258
|
+
A guard test (`src/package-structure.test.ts`) fails the build if a
|
|
259
|
+
`@toon-protocol/*` runtime dep ever leaks in.
|
|
260
|
+
|
|
261
|
+
To publish manually: `pnpm --filter @toon-protocol/client-mcp build && pnpm --filter @toon-protocol/client-mcp publish --access public`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
ANON_ASSETS,
|
|
4
|
+
ANON_VERSION,
|
|
5
|
+
defaultCacheDir,
|
|
6
|
+
ensureAnonBinary,
|
|
7
|
+
renderTorrc,
|
|
8
|
+
selectAnonAsset,
|
|
9
|
+
startManagedAnonProxy,
|
|
10
|
+
tcpProbe,
|
|
11
|
+
waitForAnonSocks
|
|
12
|
+
} from "./chunk-245J23EB.js";
|
|
13
|
+
export {
|
|
14
|
+
ANON_ASSETS,
|
|
15
|
+
ANON_VERSION,
|
|
16
|
+
defaultCacheDir,
|
|
17
|
+
ensureAnonBinary,
|
|
18
|
+
renderTorrc,
|
|
19
|
+
selectAnonAsset,
|
|
20
|
+
startManagedAnonProxy,
|
|
21
|
+
tcpProbe,
|
|
22
|
+
waitForAnonSocks
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=anon-proxy-6N362VEV-M7AX2QD7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|