@gvnrdao/dh-mcp 0.1.1 → 0.2.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 +67 -26
- package/dist/boundary.js +1507 -444
- package/dist/index.js +1687 -492
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -25,14 +25,28 @@ overridable by environment variables:
|
|
|
25
25
|
| Variable | Default | Meaning |
|
|
26
26
|
|---|---|---|
|
|
27
27
|
| `DH_ADAPTER` | `real` | `real` protocol, or `mock` (offline practice sandbox; needs `DH_MOCK_DB` + `DH_MOCK_LATENCY`) |
|
|
28
|
-
| `DH_NETWORK` | `sepolia` | `sepolia` or `mainnet` (mainnet
|
|
28
|
+
| `DH_NETWORK` | `sepolia` | `sepolia` or `mainnet` (mainnet reads work; mainnet writes are disabled unless the operator explicitly arms them) |
|
|
29
29
|
| `ETH_RPC_URL` | public node per network | your own RPC if preferred |
|
|
30
30
|
| `DH_SERVICE_ENDPOINT` | per network | Diamond Hands ops service |
|
|
31
31
|
| `DH_KEYSTORE_PATH` + `DH_KEYSTORE_PASSWORD` | unset | optional: encrypted keystore for automatic signing (both or neither) |
|
|
32
32
|
|
|
33
|
-
Signing is chosen **by conversation** (`signer_setup`
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
Signing is chosen **by conversation** (`signer_setup` — available on the real adapter):
|
|
34
|
+
your own wallet (MetaMask browser popup, or WalletConnect for mobile — scannable QR or
|
|
35
|
+
paste-code) or a local encrypted keystore. Safe smart-account and delegation modes are
|
|
36
|
+
**mock-only for now** (table below).
|
|
37
|
+
|
|
38
|
+
## What works where
|
|
39
|
+
|
|
40
|
+
| Network | Reads (public) | Reads (authenticated) | Writes |
|
|
41
|
+
|---|---|---|---|
|
|
42
|
+
| **sepolia** (default — the real protocol, practice money) | always, no setup | after a login: keystore env pair, or "connect my wallet" (`signer_setup`) | signer modes **keystore** and **external** (your own wallet). External-mode BTC withdrawal is not shipped yet — it refuses with that true reason; keystore withdrawal works |
|
|
43
|
+
| **mainnet** (real money) | always (indexer gaps are reported honestly) | after a login (the broker throttles logins per address) | **disabled unless the operator explicitly arms them**; PSM writes refuse regardless |
|
|
44
|
+
| **mock** (`DH_ADAPTER=mock` — offline practice sandbox) | always | always | all modes, including the simulated Safe and delegation planes |
|
|
45
|
+
|
|
46
|
+
Signer modes `safe` and `safe-module` (Safe smart-account borrower, delegation) are
|
|
47
|
+
**mock-only pending their own deliveries** — on the real adapter they refuse with that
|
|
48
|
+
true reason. **Reads never trigger wallet popups:** an authenticated read without a login
|
|
49
|
+
refuses legibly, and the user says "connect my wallet" (`signer_setup` action `connect`).
|
|
36
50
|
|
|
37
51
|
## Security posture (what this package will never do)
|
|
38
52
|
|
|
@@ -42,7 +56,8 @@ multi-owner — co-signers join through one shareable ceremony link).
|
|
|
42
56
|
- The approval bridge listens on **loopback only** (127.0.0.1, token-gated).
|
|
43
57
|
- Every fund-moving call requires your explicit confirmation AND a real signature; the
|
|
44
58
|
card you sign is decoded from the exact transaction — never re-formatted.
|
|
45
|
-
- **Mainnet writes are
|
|
59
|
+
- **Mainnet writes are disabled unless the operator explicitly arms them**; PSM mainnet
|
|
60
|
+
writes refuse regardless.
|
|
46
61
|
|
|
47
62
|
## What it solves
|
|
48
63
|
|
|
@@ -72,7 +87,9 @@ misrepresent upstream state, always answer with legible, typed results.
|
|
|
72
87
|
event history, pending withdrawals (`position_*`, `position://{id}`), protocol health and
|
|
73
88
|
terms (`protocol_*`, `protocol://config`, `protocol://terms`), BTC balance and oracle price
|
|
74
89
|
(`btc_*`), and `boundary://info` — which world the server is talking to (adapter, sources,
|
|
75
|
-
signer identity; never secrets)
|
|
90
|
+
signer identity; never secrets), including its `capabilities` block: network, chain id,
|
|
91
|
+
practice-vs-real money, whether reads need a login, whether writes are enabled (and the
|
|
92
|
+
true reason when not), and which signer modes this build offers.
|
|
76
93
|
|
|
77
94
|
## Architecture: the protocol boundary
|
|
78
95
|
|
|
@@ -88,26 +105,33 @@ All protocol traffic passes through one module — the `ProtocolBoundary` port
|
|
|
88
105
|
instead of presenting one side as truth.
|
|
89
106
|
- A single switch (`DH_ADAPTER=mock|real`) selects the adapter behind the port.
|
|
90
107
|
|
|
91
|
-
The **
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
The **real adapter** (the zero-config default) speaks to the live protocol: the Diamond
|
|
109
|
+
Hands SDK, the lit-ops service, and an Ethereum RPC. Public reads need no setup;
|
|
110
|
+
authenticated reads need a login; writes run on sepolia through the keystore or the
|
|
111
|
+
user's own wallet (capability table above). The **mock adapter** is a full protocol
|
|
112
|
+
simulator: complete position lifecycle (deposit → active → repaid → closed), LTV-checked
|
|
113
|
+
mints, fee math, event history — held in memory, persisted to a local file DB (survives
|
|
114
|
+
restarts), with deterministic operation delays and injectable fault scenarios. It enables
|
|
115
|
+
end-to-end agent development and testing with zero funds at risk, offline.
|
|
116
|
+
|
|
117
|
+
In one paragraph: tools and resources talk only to the `ProtocolBoundary` port; behind it
|
|
118
|
+
sit the two adapters, a signer layer (`signer_setup`) with a loopback-only approval
|
|
119
|
+
bridge for external wallets, and a result-envelope contract carrying data provenance and
|
|
120
|
+
typed errors — never raw upstream text. The full design docs (use cases, sequence
|
|
121
|
+
diagrams, data contracts, scenario catalog) live in the repository:
|
|
122
|
+
<https://github.com/gvnrdao/diamond-hands>.
|
|
100
123
|
|
|
101
124
|
## Reliability status
|
|
102
125
|
|
|
103
126
|
- Behavior is pinned by scenario tests that run through the genuine MCP request path
|
|
104
127
|
(in-memory client/server pair), covering happy paths and failure classes alike
|
|
105
128
|
(missing config, uncollateralized operations, source divergence, upstream outages).
|
|
106
|
-
- Current stage: **
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
129
|
+
- Current stage: **real adapter (sepolia writes, mainnet reads) + mock simulator**, both
|
|
130
|
+
behind the same boundary contract and the same scenario suites. External-wallet signing
|
|
131
|
+
runs on the real adapter; external-mode BTC withdrawal is the one remaining refusal
|
|
132
|
+
(its true reason is stated; keystore withdrawal works).
|
|
133
|
+
- Mainnet writes are disabled unless the operator explicitly arms them. Reads are
|
|
134
|
+
unrestricted, with indexer gaps reported honestly.
|
|
111
135
|
|
|
112
136
|
## Security model
|
|
113
137
|
|
|
@@ -133,15 +157,32 @@ rejected before signing — but address correctness is still the human's respons
|
|
|
133
157
|
### Signer required for writes
|
|
134
158
|
|
|
135
159
|
All write tools require a configured signer; without one they return a typed
|
|
136
|
-
`SIGNER_UNAVAILABLE` error.
|
|
160
|
+
`SIGNER_UNAVAILABLE` error. On the real adapter the two remedies are the keystore env
|
|
161
|
+
pair (`DH_KEYSTORE_PATH` + `DH_KEYSTORE_PASSWORD`) or connecting the user's own wallet
|
|
162
|
+
(`signer_setup`, mode `external`). In mock mode the signed identity is `DH_MOCK_BORROWER`.
|
|
137
163
|
|
|
138
164
|
### Supply chain (audit H-6)
|
|
139
165
|
|
|
140
166
|
Dependencies are pinned to exact versions so nothing drifts silently between installs.
|
|
141
167
|
Bump deliberately, in lockstep with sibling packages, and run `npm ci` in CI.
|
|
142
168
|
|
|
143
|
-
###
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
169
|
+
### Mainnet writes are operator-gated
|
|
170
|
+
|
|
171
|
+
Mainnet reads work out of the box. Mainnet writes are disabled unless the operator
|
|
172
|
+
explicitly arms them — an unarmed server refuses every mainnet write and names the
|
|
173
|
+
standing gate as the reason. Do not arm mainnet writes without reviewing your host's
|
|
174
|
+
approval flow and key management; PSM mainnet writes refuse regardless.
|
|
175
|
+
|
|
176
|
+
## For AI assistants
|
|
177
|
+
|
|
178
|
+
- **Read `boundary://info` FIRST.** Its `capabilities` block is the truth about the
|
|
179
|
+
session: network, chain id, practice-vs-real money, whether reads need a login, whether
|
|
180
|
+
writes are enabled (and the true reason when not), which signer modes exist, and
|
|
181
|
+
whether `signer_setup` is registered. Never promise a capability it does not list.
|
|
182
|
+
- **Use the `guide://` topics** (also served by the `guide` tool) — `guide://index` lists
|
|
183
|
+
them; `getting-started`, `first-setup`, and `connect-wallet` carry the onboarding path.
|
|
184
|
+
Narrate them in the user's language.
|
|
185
|
+
- **Never invent flows.** Every refusal names its true reason and next step — relay that,
|
|
186
|
+
don't improvise around it.
|
|
187
|
+
- Claude Code users may copy the `guide://index` content into a project skill for
|
|
188
|
+
persistent context across sessions.
|