@gvnrdao/dh-mcp 0.3.0 → 0.4.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,13 +11,13 @@ so there is **nothing to install first** (no Node, no npm):
11
11
 
12
12
  | You are on | Install path |
13
13
  |---|---|
14
- | **Claude Desktop (macOS / Windows)** | Download the bundle and open it (double-click / drag into Settings → Extensions): `https://assets.gvnr.xyz/dh-mcp/v0.3.0/dh-mcp-0.3.0.mcpb` — Claude Desktop runs it on its own embedded runtime; network and optional keystore are configured in the extension's settings UI (the password is held by the OS credential store, never written to a config file). |
15
- | **Linux — including Claude Desktop builds on Linux — or any other MCP host** | One line, no sudo: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| sh` — installs a self-contained binary (its own Node runtime inside) to `~/.dh-mcp/bin/dh-mcp`, verifies its SHA-256, and prints the exact `mcpServers` snippet. **Then wire the host:** Claude Code: `claude mcp add diamond-hands -- $HOME/.dh-mcp/bin/dh-mcp` (new session); Claude Desktop (Linux builds): the snippet in `~/.config/Claude/claude_desktop_config.json`, full quit + relaunch; other hosts: the snippet in their MCP config. Pin a version: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| DH_VERSION=0.3.0 sh` |
14
+ | **Claude Desktop (macOS / Windows)** | Download the bundle and open it (double-click / drag into Settings → Extensions): `https://assets.gvnr.xyz/dh-mcp/v0.4.0/dh-mcp-0.4.0.mcpb` — Claude Desktop runs it on its own embedded runtime; network and optional keystore are configured in the extension's settings UI (the password is held by the OS credential store, never written to a config file). |
15
+ | **Linux — including Claude Desktop builds on Linux — or any other MCP host** | One line, no sudo: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| sh` — installs a self-contained binary (its own Node runtime inside) to `~/.dh-mcp/bin/dh-mcp`, verifies its SHA-256, and prints the exact `mcpServers` snippet. **Then wire the host:** Claude Code: `claude mcp add diamond-hands -- $HOME/.dh-mcp/bin/dh-mcp` (new session); Claude Desktop (Linux builds): the snippet in `~/.config/Claude/claude_desktop_config.json`, full quit + relaunch; other hosts: the snippet in their MCP config. Pin a version: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| DH_VERSION=0.4.0 sh` |
16
16
  | **Developers** (requires **Node ≥ 18 on PATH** — this path does NOT work on a bare machine) | Claude Code: `claude mcp add diamond-hands -- npx -y @gvnrdao/dh-mcp` · any host JSON: `{ "mcpServers": { "diamond-hands": { "command": "npx", "args": ["-y", "@gvnrdao/dh-mcp"] } } }` |
17
17
 
18
18
  Downloads landing page (which file is for which system, checksums, security notes):
19
19
  **https://assets.gvnr.xyz/dh-mcp/** — all artifacts and `SHA256SUMS` live under it
20
- (`latest/` and `v<version>/` — e.g. `v0.3.0/`).
20
+ (`latest/` and `v<version>/` — e.g. `v0.4.0/`).
21
21
 
22
22
  Local installs serve local MCP hosts only — **claude.ai web / mobile / Cowork cannot
23
23
  reach them** (a hosted remote connector is a separate, upcoming tier).
@@ -42,7 +42,7 @@ overridable by environment variables:
42
42
  | Variable | Default | Meaning |
43
43
  |---|---|---|
44
44
  | `DH_ADAPTER` | `real` | `real` protocol, or `mock` (offline practice sandbox; needs `DH_MOCK_DB` + `DH_MOCK_LATENCY`) |
45
- | `DH_NETWORK` | `sepolia` | `sepolia` or `mainnet` (mainnet reads work; mainnet writes are disabled unless the operator explicitly arms them) |
45
+ | `DH_NETWORK` | `sepolia` | `sepolia` (practice) or `mainnet` (REAL money — reads and writes both work out of the box) |
46
46
  | `ETH_RPC_URL` | public node per network | your own RPC if preferred |
47
47
  | `DH_SERVICE_ENDPOINT` | per network | Diamond Hands ops service |
48
48
  | `DH_KEYSTORE_PATH` + `DH_KEYSTORE_PASSWORD` | unset | optional: encrypted keystore for automatic signing (both or neither) |
@@ -57,7 +57,7 @@ paste-code) or a local encrypted keystore. Safe smart-account and delegation mod
57
57
  | Network | Reads (public) | Reads (authenticated) | Writes |
58
58
  |---|---|---|---|
59
59
  | **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 |
60
- | **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 |
60
+ | **mainnet** (real money) | always (indexer gaps are reported honestly) | after a login (the broker throttles logins per address) | signer modes **keystore** and **external**, same as sepolia — every operation moves REAL funds behind your confirmation + signature; PSM writes refuse (sepolia-only) |
61
61
  | **mock** (`DH_ADAPTER=mock` — offline practice sandbox) | always | always | all modes, including the simulated Safe and delegation planes |
62
62
 
63
63
  Signer modes `safe` and `safe-module` (Safe smart-account borrower, delegation) are
@@ -73,8 +73,8 @@ refuses legibly, and the user says "connect my wallet" (`signer_setup` action `c
73
73
  - The approval bridge listens on **loopback only** (127.0.0.1, token-gated).
74
74
  - Every fund-moving call requires your explicit confirmation AND a real signature; the
75
75
  card you sign is decoded from the exact transaction — never re-formatted.
76
- - **Mainnet writes are disabled unless the operator explicitly arms them**; PSM mainnet
77
- writes refuse regardless.
76
+ - **Mainnet operations move real funds** — they run only behind your explicit
77
+ confirmation plus a real signature you approve; PSM mainnet writes refuse (sepolia-only).
78
78
 
79
79
  ## What it solves
80
80
 
@@ -151,12 +151,11 @@ diagrams, data contracts, scenario catalog) live in the repository:
151
151
  - Behavior is pinned by scenario tests that run through the genuine MCP request path
152
152
  (in-memory client/server pair), covering happy paths and failure classes alike
153
153
  (missing config, uncollateralized operations, source divergence, upstream outages).
154
- - Current stage: **real adapter (sepolia writes, mainnet reads) + mock simulator**, both
155
- behind the same boundary contract and the same scenario suites. External-wallet signing
156
- runs on the real adapter; external-mode BTC withdrawal is the one remaining refusal
157
- (its true reason is stated; keystore withdrawal works).
158
- - Mainnet writes are disabled unless the operator explicitly arms them. Reads are
159
- unrestricted, with indexer gaps reported honestly.
154
+ - Current stage: **real adapter (sepolia AND mainnet, reads and writes) + mock
155
+ simulator**, all behind the same boundary contract and the same scenario suites.
156
+ External-wallet signing runs on the real adapter; external-mode BTC withdrawal is the
157
+ one remaining refusal (its true reason is stated; keystore withdrawal works).
158
+ - Reads are unrestricted, with indexer gaps reported honestly.
160
159
 
161
160
  ## Security model
162
161
 
@@ -191,12 +190,13 @@ pair (`DH_KEYSTORE_PATH` + `DH_KEYSTORE_PASSWORD`) or connecting the user's own
191
190
  Dependencies are pinned to exact versions so nothing drifts silently between installs.
192
191
  Bump deliberately, in lockstep with sibling packages, and run `npm ci` in CI.
193
192
 
194
- ### Mainnet writes are operator-gated
193
+ ### Mainnet moves real funds
195
194
 
196
- Mainnet reads work out of the box. Mainnet writes are disabled unless the operator
197
- explicitly arms them — an unarmed server refuses every mainnet write and names the
198
- standing gate as the reason. Do not arm mainnet writes without reviewing your host's
199
- approval flow and key management; PSM mainnet writes refuse regardless.
195
+ Mainnet reads and writes both work out of the box. Every fund-moving operation still
196
+ requires the explicit human `confirmed: true` plus a real signature (wallet approval
197
+ card or keystore), and the network switch ceremony states the money reality loudly.
198
+ Review your host's approval flow and key management before using mainnet; PSM mainnet
199
+ writes refuse (sepolia-only).
200
200
 
201
201
  ## For AI assistants
202
202
 
package/dist/boundary.js CHANGED
@@ -87601,7 +87601,7 @@ function psmMainnetWriteRefusal(network, chainId) {
87601
87601
  return {
87602
87602
  kind: "rejected",
87603
87603
  source: SOURCE5,
87604
- message: `psmSwap is refused (MAINNET_WRITES_DISABLED): PSM writes are enabled on sepolia ONLY, and this process is configured for network '${network}' (chainId ${chainId}) \u2014 the standing mainnet write block; mainnet PSM operations await their dedicated security review. No ceremony was started and no signer was touched. PSM reads (psm_quote, protocol://psm) remain available.`
87604
+ message: `psmSwap is refused (MAINNET_WRITES_DISABLED): PSM writes are enabled on sepolia ONLY, and this process is configured for network '${network}' (chainId ${chainId}) \u2014 the PSM-specific sepolia-only anchor; mainnet PSM operations await their dedicated security review. No ceremony was started and no signer was touched. PSM reads (psm_quote, protocol://psm) remain available. Loan operations are NOT affected by this gate.`
87605
87605
  };
87606
87606
  }
87607
87607
  var SOURCE5 = "real-ops";
@@ -88525,7 +88525,7 @@ var RealUpstreamPlugin = class {
88525
88525
  })
88526
88526
  )
88527
88527
  };
88528
- const writeRefusalReason = this.config.network !== "sepolia" ? `writes are enabled on sepolia ONLY, and this process is configured for network '${this.config.network}' (chainId ${this.config.chainId}) \u2014 the standing mainnet write block; mainnet writes await their dedicated security review. Reads remain available.` : !this.wallet ? `no signer is configured (SIGNER_UNAVAILABLE) \u2014 writes need the keystore env pair (DH_KEYSTORE_PATH + DH_KEYSTORE_PASSWORD), or run signer_setup.` : `the lit-ops login session is unavailable \u2014 the keystore is configured but EIP-712 login did not complete; check the broker endpoint and retry.`;
88528
+ const writeRefusalReason = !this.wallet ? `no signer is configured (SIGNER_UNAVAILABLE) \u2014 writes need the keystore env pair (DH_KEYSTORE_PATH + DH_KEYSTORE_PASSWORD), or run signer_setup.` : `the lit-ops login session is unavailable \u2014 the keystore is configured but EIP-712 login did not complete; check the broker endpoint and retry.`;
88529
88529
  const readOnly = (op) => Promise.resolve(
88530
88530
  upFail({
88531
88531
  kind: "unavailable",
@@ -88533,10 +88533,9 @@ var RealUpstreamPlugin = class {
88533
88533
  message: `${op} is refused: ${writeRefusalReason}`
88534
88534
  })
88535
88535
  );
88536
- const writesArmed = this.config.network === "sepolia" || this.config.network === "mainnet" && this.config.mainnetWritesAck === true;
88537
- if (writesArmed && this.runtime) {
88536
+ if (this.runtime) {
88538
88537
  this.ops = this.resolvingOps();
88539
- } else if (writesArmed && this.wallet && this.session) {
88538
+ } else if (this.wallet && this.session) {
88540
88539
  this.ops = this.keystoreGateway(this.wallet.connect(this.provider), this.session);
88541
88540
  } else {
88542
88541
  this.ops = {
@@ -88589,8 +88588,6 @@ var RealUpstreamPlugin = class {
88589
88588
  * Safe to call repeatedly; failures leave the write plane honestly unavailable
88590
88589
  * (createPosition/withdraw report the uninitialized SDK). */
88591
88590
  async initWriteSdk() {
88592
- const writesArmed = this.config.network === "sepolia" || this.config.network === "mainnet" && this.config.mainnetWritesAck === true;
88593
- if (!writesArmed) return;
88594
88591
  if (this.runtime && this.runtime.manager.mode() !== "keystore") return;
88595
88592
  const wallet = this.wallet ?? this.runtime?.keystore.signer() ?? null;
88596
88593
  if (!wallet) return;
@@ -88687,7 +88684,7 @@ var RealUpstreamPlugin = class {
88687
88684
  verifyBudget() {
88688
88685
  return this.config.network === "mainnet" ? { attempts: 100, delayMs: 3e3 } : void 0;
88689
88686
  }
88690
- /** The armed-boot ops surface: every method resolves the CURRENT signer mode first, so
88687
+ /** The runtime ops surface: every method resolves the CURRENT signer mode first, so
88691
88688
  * the refusal-truth matrix is decided at call time, never frozen at boot. */
88692
88689
  resolvingOps() {
88693
88690
  const call = (k) => (async (p) => {
@@ -90163,20 +90160,6 @@ function resolveRealConfig(env) {
90163
90160
  bridgeOpenBrowser = bridgeOpenRaw === "1";
90164
90161
  }
90165
90162
  }
90166
- const ACK_PHRASE = "I-UNDERSTAND-REAL-FUNDS";
90167
- const ackRaw = env["DH_MAINNET_WRITES_ACK"];
90168
- let mainnetWritesAck;
90169
- if (ackRaw !== void 0 && ackRaw !== "") {
90170
- if (network !== "mainnet") {
90171
- problems.push("DH_MAINNET_WRITES_ACK is only meaningful with DH_NETWORK=mainnet \u2014 unset it on other networks.");
90172
- } else if (ackRaw !== ACK_PHRASE) {
90173
- problems.push(
90174
- "DH_MAINNET_WRITES_ACK is set but does not match the required acknowledgement phrase \u2014 mainnet writes stay refused. (The phrase is deliberate friction: it arms REAL-FUND transactions.)"
90175
- );
90176
- } else {
90177
- mainnetWritesAck = true;
90178
- }
90179
- }
90180
90163
  const validatorRaw = env["DH_VALIDATOR_VERSION"];
90181
90164
  let validatorVersion = defaults2.validatorVersion;
90182
90165
  if (validatorRaw !== void 0 && validatorRaw !== "") {
@@ -90211,8 +90194,7 @@ function resolveRealConfig(env) {
90211
90194
  ...bridgeUrlFile ? { bridgeUrlFile } : {},
90212
90195
  ...bridgeOpenBrowser !== void 0 ? { bridgeOpenBrowser } : {},
90213
90196
  ...wcProjectId ? { wcProjectId } : {},
90214
- ...validatorVersion !== void 0 ? { validatorVersion } : {},
90215
- ...mainnetWritesAck === true ? { mainnetWritesAck: true } : {}
90197
+ ...validatorVersion !== void 0 ? { validatorVersion } : {}
90216
90198
  }
90217
90199
  };
90218
90200
  }
@@ -90387,18 +90369,12 @@ async function createRealBoundary(config, wallet) {
90387
90369
  const plugin = new RealUpstreamPlugin(config, wallet, { manager, bridge, keystore });
90388
90370
  await plugin.initWriteSdk();
90389
90371
  const configFingerprint = (0, import_node_crypto7.createHash)("sha256").update(JSON.stringify({ adapter: config.adapter, network: config.network, ops: config.serviceEndpoint })).digest("hex").slice(0, 12);
90390
- const writesArmed = config.network === "sepolia" || config.network === "mainnet" && config.mainnetWritesAck === true;
90391
90372
  const capabilities = () => ({
90392
90373
  reads: {
90393
90374
  public: true,
90394
90375
  authenticated: plugin.authenticatedReadsAvailable() ? "available" : "needs-signer"
90395
90376
  },
90396
- writes: writesArmed ? { enabled: true, signerModes: ["external", "keystore"], activeMode: manager.mode() } : {
90397
- enabled: false,
90398
- reason: "writes are operator-gated on mainnet \u2014 the standing mainnet write block; mainnet writes await their dedicated security review. Reads remain available.",
90399
- signerModes: [],
90400
- activeMode: manager.mode()
90401
- },
90377
+ writes: { enabled: true, signerModes: ["external", "keystore"], activeMode: manager.mode() },
90402
90378
  signerSetupTool: true,
90403
90379
  // Plan 13: the real adapter switches networks by conversation (network_switch tool).
90404
90380
  networkSwitch: true
package/dist/index.js CHANGED
@@ -37063,8 +37063,8 @@ var require_lit_ops_module = __commonJS({
37063
37063
  if (!wallet.provider)
37064
37064
  return void 0;
37065
37065
  try {
37066
- const net = await wallet.provider.getNetwork();
37067
- return Number(net.chainId);
37066
+ const net2 = await wallet.provider.getNetwork();
37067
+ return Number(net2.chainId);
37068
37068
  } catch {
37069
37069
  return void 0;
37070
37070
  }
@@ -52048,6 +52048,7 @@ var init_wc_transport = __esm({
52048
52048
  });
52049
52049
 
52050
52050
  // src/index.ts
52051
+ var net = __toESM(require("net"));
52051
52052
  var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
52052
52053
 
52053
52054
  // src/boundary/errors.ts
@@ -52213,20 +52214,6 @@ function resolveRealConfig(env) {
52213
52214
  bridgeOpenBrowser = bridgeOpenRaw === "1";
52214
52215
  }
52215
52216
  }
52216
- const ACK_PHRASE = "I-UNDERSTAND-REAL-FUNDS";
52217
- const ackRaw = env["DH_MAINNET_WRITES_ACK"];
52218
- let mainnetWritesAck;
52219
- if (ackRaw !== void 0 && ackRaw !== "") {
52220
- if (network !== "mainnet") {
52221
- problems.push("DH_MAINNET_WRITES_ACK is only meaningful with DH_NETWORK=mainnet \u2014 unset it on other networks.");
52222
- } else if (ackRaw !== ACK_PHRASE) {
52223
- problems.push(
52224
- "DH_MAINNET_WRITES_ACK is set but does not match the required acknowledgement phrase \u2014 mainnet writes stay refused. (The phrase is deliberate friction: it arms REAL-FUND transactions.)"
52225
- );
52226
- } else {
52227
- mainnetWritesAck = true;
52228
- }
52229
- }
52230
52217
  const validatorRaw = env["DH_VALIDATOR_VERSION"];
52231
52218
  let validatorVersion = defaults2.validatorVersion;
52232
52219
  if (validatorRaw !== void 0 && validatorRaw !== "") {
@@ -52261,8 +52248,7 @@ function resolveRealConfig(env) {
52261
52248
  ...bridgeUrlFile ? { bridgeUrlFile } : {},
52262
52249
  ...bridgeOpenBrowser !== void 0 ? { bridgeOpenBrowser } : {},
52263
52250
  ...wcProjectId ? { wcProjectId } : {},
52264
- ...validatorVersion !== void 0 ? { validatorVersion } : {},
52265
- ...mainnetWritesAck === true ? { mainnetWritesAck: true } : {}
52251
+ ...validatorVersion !== void 0 ? { validatorVersion } : {}
52266
52252
  }
52267
52253
  };
52268
52254
  }
@@ -52287,9 +52273,9 @@ function errEnvelope(error) {
52287
52273
 
52288
52274
  // src/util/btc-address.ts
52289
52275
  var import_bitcoinjs_lib = require("bitcoinjs-lib");
52290
- function networkObj(net) {
52291
- if (net === "mainnet") return import_bitcoinjs_lib.networks.bitcoin;
52292
- if (net === "testnet") return import_bitcoinjs_lib.networks.testnet;
52276
+ function networkObj(net2) {
52277
+ if (net2 === "mainnet") return import_bitcoinjs_lib.networks.bitcoin;
52278
+ if (net2 === "testnet") return import_bitcoinjs_lib.networks.testnet;
52293
52279
  return import_bitcoinjs_lib.networks.regtest;
52294
52280
  }
52295
52281
  function checkBtcAddress(addr, expected) {
@@ -87813,7 +87799,7 @@ function psmMainnetWriteRefusal(network, chainId) {
87813
87799
  return {
87814
87800
  kind: "rejected",
87815
87801
  source: SOURCE5,
87816
- message: `psmSwap is refused (MAINNET_WRITES_DISABLED): PSM writes are enabled on sepolia ONLY, and this process is configured for network '${network}' (chainId ${chainId}) \u2014 the standing mainnet write block; mainnet PSM operations await their dedicated security review. No ceremony was started and no signer was touched. PSM reads (psm_quote, protocol://psm) remain available.`
87802
+ message: `psmSwap is refused (MAINNET_WRITES_DISABLED): PSM writes are enabled on sepolia ONLY, and this process is configured for network '${network}' (chainId ${chainId}) \u2014 the PSM-specific sepolia-only anchor; mainnet PSM operations await their dedicated security review. No ceremony was started and no signer was touched. PSM reads (psm_quote, protocol://psm) remain available. Loan operations are NOT affected by this gate.`
87817
87803
  };
87818
87804
  }
87819
87805
  var SOURCE5 = "real-ops";
@@ -88737,7 +88723,7 @@ var RealUpstreamPlugin = class {
88737
88723
  })
88738
88724
  )
88739
88725
  };
88740
- const writeRefusalReason = this.config.network !== "sepolia" ? `writes are enabled on sepolia ONLY, and this process is configured for network '${this.config.network}' (chainId ${this.config.chainId}) \u2014 the standing mainnet write block; mainnet writes await their dedicated security review. Reads remain available.` : !this.wallet ? `no signer is configured (SIGNER_UNAVAILABLE) \u2014 writes need the keystore env pair (DH_KEYSTORE_PATH + DH_KEYSTORE_PASSWORD), or run signer_setup.` : `the lit-ops login session is unavailable \u2014 the keystore is configured but EIP-712 login did not complete; check the broker endpoint and retry.`;
88726
+ const writeRefusalReason = !this.wallet ? `no signer is configured (SIGNER_UNAVAILABLE) \u2014 writes need the keystore env pair (DH_KEYSTORE_PATH + DH_KEYSTORE_PASSWORD), or run signer_setup.` : `the lit-ops login session is unavailable \u2014 the keystore is configured but EIP-712 login did not complete; check the broker endpoint and retry.`;
88741
88727
  const readOnly = (op) => Promise.resolve(
88742
88728
  upFail({
88743
88729
  kind: "unavailable",
@@ -88745,10 +88731,9 @@ var RealUpstreamPlugin = class {
88745
88731
  message: `${op} is refused: ${writeRefusalReason}`
88746
88732
  })
88747
88733
  );
88748
- const writesArmed = this.config.network === "sepolia" || this.config.network === "mainnet" && this.config.mainnetWritesAck === true;
88749
- if (writesArmed && this.runtime) {
88734
+ if (this.runtime) {
88750
88735
  this.ops = this.resolvingOps();
88751
- } else if (writesArmed && this.wallet && this.session) {
88736
+ } else if (this.wallet && this.session) {
88752
88737
  this.ops = this.keystoreGateway(this.wallet.connect(this.provider), this.session);
88753
88738
  } else {
88754
88739
  this.ops = {
@@ -88801,8 +88786,6 @@ var RealUpstreamPlugin = class {
88801
88786
  * Safe to call repeatedly; failures leave the write plane honestly unavailable
88802
88787
  * (createPosition/withdraw report the uninitialized SDK). */
88803
88788
  async initWriteSdk() {
88804
- const writesArmed = this.config.network === "sepolia" || this.config.network === "mainnet" && this.config.mainnetWritesAck === true;
88805
- if (!writesArmed) return;
88806
88789
  if (this.runtime && this.runtime.manager.mode() !== "keystore") return;
88807
88790
  const wallet = this.wallet ?? this.runtime?.keystore.signer() ?? null;
88808
88791
  if (!wallet) return;
@@ -88899,7 +88882,7 @@ var RealUpstreamPlugin = class {
88899
88882
  verifyBudget() {
88900
88883
  return this.config.network === "mainnet" ? { attempts: 100, delayMs: 3e3 } : void 0;
88901
88884
  }
88902
- /** The armed-boot ops surface: every method resolves the CURRENT signer mode first, so
88885
+ /** The runtime ops surface: every method resolves the CURRENT signer mode first, so
88903
88886
  * the refusal-truth matrix is decided at call time, never frozen at boot. */
88904
88887
  resolvingOps() {
88905
88888
  const call = (k) => (async (p) => {
@@ -90387,18 +90370,12 @@ async function createRealBoundary(config, wallet) {
90387
90370
  const plugin = new RealUpstreamPlugin(config, wallet, { manager, bridge, keystore });
90388
90371
  await plugin.initWriteSdk();
90389
90372
  const configFingerprint = (0, import_node_crypto7.createHash)("sha256").update(JSON.stringify({ adapter: config.adapter, network: config.network, ops: config.serviceEndpoint })).digest("hex").slice(0, 12);
90390
- const writesArmed = config.network === "sepolia" || config.network === "mainnet" && config.mainnetWritesAck === true;
90391
90373
  const capabilities = () => ({
90392
90374
  reads: {
90393
90375
  public: true,
90394
90376
  authenticated: plugin.authenticatedReadsAvailable() ? "available" : "needs-signer"
90395
90377
  },
90396
- writes: writesArmed ? { enabled: true, signerModes: ["external", "keystore"], activeMode: manager.mode() } : {
90397
- enabled: false,
90398
- reason: "writes are operator-gated on mainnet \u2014 the standing mainnet write block; mainnet writes await their dedicated security review. Reads remain available.",
90399
- signerModes: [],
90400
- activeMode: manager.mode()
90401
- },
90378
+ writes: { enabled: true, signerModes: ["external", "keystore"], activeMode: manager.mode() },
90402
90379
  signerSetupTool: true,
90403
90380
  // Plan 13: the real adapter switches networks by conversation (network_switch tool).
90404
90381
  networkSwitch: true
@@ -90487,7 +90464,6 @@ function createNetworkSwitchRuntime(opts) {
90487
90464
  },
90488
90465
  async switchTo(network) {
90489
90466
  const targetEnv = { ...opts.env, DH_NETWORK: network };
90490
- delete targetEnv["DH_MAINNET_WRITES_ACK"];
90491
90467
  const configResult = resolveBoundaryConfig(targetEnv);
90492
90468
  if (!configResult.ok) return { ok: false, error: configResult.error };
90493
90469
  const next = await buildBoundary(configResult);
@@ -91658,8 +91634,8 @@ tolerance; if fees or the rate drifted beyond that between quote and execution,
91658
91634
  contract refuses \u2014 you never silently receive less. Output always lands at the signer's
91659
91635
  own address. If you approve step 1 but decline step 2, the exact-amount allowance remains
91660
91636
  standing \u2014 it authorizes only that amount and nothing else; the result says so plainly.
91661
- On the real protocol, PSM writes run on sepolia ONLY \u2014 mainnet PSM writes are refused by
91662
- the standing mainnet write block.`,
91637
+ On the real protocol, PSM writes run on sepolia ONLY \u2014 mainnet PSM writes are refused
91638
+ (the PSM-specific sepolia-only anchor; loan operations are not affected).`,
91663
91639
  authorization: `# Authorization \u2014 who signs, and what a signature means
91664
91640
 
91665
91641
  Every fund-moving operation needs TWO things, always in this order:
@@ -91803,9 +91779,9 @@ no switch, and that is by design.
91803
91779
  the human approves the card. sepolia = practice funds; mainnet = REAL MONEY.
91804
91780
  - NOTHING carries across: positions, vaults, signer bindings, logins are per-network.
91805
91781
  A sepolia position does not exist on mainnet and vice versa.
91806
- - Switching to mainnet does NOT enable fund-moving operations: mainnet writes are
91807
- operator-gated \u2014 reads work, write tools refuse with the true reason. Never imply
91808
- otherwise.
91782
+ - Fund-moving loan operations work on BOTH networks \u2014 on mainnet they move REAL money,
91783
+ and every one still requires the user's explicit confirmation plus the signer
91784
+ ceremony. The exception is PSM swaps: sepolia-only, refused on mainnet.
91809
91785
  - A pending signing ceremony blocks the switch (finish or decline it first).
91810
91786
  - The switch is session-scoped: when the server restarts, the configured default
91811
91787
  network returns.
@@ -91821,9 +91797,8 @@ reality in your next message. The user must never have to ask which world they a
91821
91797
  - **"Not logged in" on a read** \u2014 authenticated reads NEVER pop the wallet; the remedy is
91822
91798
  the same pair: keystore env pair, or "connect my wallet" (\`signer_setup connect\`). An
91823
91799
  EXPIRED login refuses the same way \u2014 reconnect on the user's word.
91824
- - **Mainnet write refused** \u2014 mainnet writes are disabled unless the operator explicitly
91825
- arms them; the refusal is the standing gate, not a bug. Reads keep working. This is
91826
- TRUE after a conversational network switch too \u2014 switching never arms writes.
91800
+ - **PSM write refused on mainnet** \u2014 PSM swaps are sepolia-only (a deliberate anchor,
91801
+ not a bug); loan operations work on mainnet. Reads keep working everywhere.
91827
91802
  - **"Wrong network" / wants mainnet or sepolia** \u2014 real adapter: \`network_switch\`
91828
91803
  (human-confirmed card; nothing carries across networks). Mock: the world is pinned by
91829
91804
  config \u2014 no switch exists there.
@@ -91994,7 +91969,7 @@ function registerGuidePrompts(server) {
91994
91969
  // src/tools/network-switch.ts
91995
91970
  var import_zod8 = require("zod");
91996
91971
  function moneyLine(network) {
91997
- return network === "mainnet" ? "mainnet \u2014 REAL MONEY: fund-moving operations spend real funds once enabled" : `${network} \u2014 PRACTICE FUNDS (test network: real contracts, no real money)`;
91972
+ return network === "mainnet" ? "mainnet \u2014 REAL MONEY: fund-moving operations spend real funds" : `${network} \u2014 PRACTICE FUNDS (test network: real contracts, no real money)`;
91998
91973
  }
91999
91974
  function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92000
91975
  registerBoundaryTool(
@@ -92002,7 +91977,7 @@ function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92002
91977
  "network_switch",
92003
91978
  {
92004
91979
  title: "Show or switch the active network",
92005
- description: "Which world this server is on \u2014 and switching it by conversation (real adapter). 'status' states the active network and whether money is real. 'switch' moves this session between sepolia (practice funds) and mainnet (REAL MONEY) after an explicit human confirmation; positions, vaults, and signer bindings are per-network and do not carry across. Mainnet writes stay operator-gated after a switch \u2014 reads work, fund-moving tools refuse with the true reason. The switch lasts for this server session only; the configured default returns on restart. After a switch, re-read boundary://info and STATE the new environment to the user.",
91980
+ description: "Which world this server is on \u2014 and switching it by conversation (real adapter). 'status' states the active network and whether money is real. 'switch' moves this session between sepolia (practice funds) and mainnet (REAL MONEY) after an explicit human confirmation; positions, vaults, and signer bindings are per-network and do not carry across. Fund-moving operations work on BOTH networks (on mainnet they move REAL money; PSM swaps stay sepolia-only). The switch lasts for this server session only; the configured default returns on restart. After a switch, re-read boundary://info and STATE the new environment to the user.",
92006
91981
  inputSchema: {
92007
91982
  action: import_zod8.z.enum(["status", "switch"]).describe("status = current world; switch = change network (needs confirmed:true)"),
92008
91983
  network: import_zod8.z.string().optional().describe("switch target: sepolia | mainnet"),
@@ -92020,7 +91995,7 @@ function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92020
91995
  lines.push(
92021
91996
  `Switchable networks: ${SWITCHABLE_NETWORKS.join(", ")} (action 'switch', confirmed:true after human approval).`,
92022
91997
  "A switch changes worlds entirely: positions, vaults, and signer bindings are per-network.",
92023
- "Mainnet writes are operator-gated regardless of switching \u2014 reads work, fund-moving tools refuse.",
91998
+ "Fund-moving operations work on both networks \u2014 on mainnet they move REAL money (PSM swaps: sepolia-only).",
92024
91999
  "Session-scoped: the configured default network returns when the server restarts."
92025
92000
  );
92026
92001
  return { content: [{ type: "text", text: lines.join("\n") }] };
@@ -92051,7 +92026,7 @@ function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92051
92026
  FROM: ${from}
92052
92027
  TO: ${moneyLine(target)}
92053
92028
  - Positions, vaults, and signer bindings are PER-NETWORK: nothing carries across.
92054
- - Mainnet fund-moving operations remain operator-gated after the switch \u2014 reads work, writes refuse.
92029
+ - Fund-moving operations WORK on the target network \u2014 on mainnet they move REAL money.
92055
92030
  - Session-scoped: the configured default network returns on server restart.
92056
92031
  Re-invoke with confirmed: true ONLY after a human has approved this exact switch. Do not set it on your own.`
92057
92032
  }
@@ -92175,7 +92150,7 @@ function registerBoundaryInfoResource(server, getB) {
92175
92150
  }
92176
92151
 
92177
92152
  // src/server.ts
92178
- var SERVER_VERSION = "0.3.0";
92153
+ var SERVER_VERSION = "0.4.0";
92179
92154
  var SERVER_INSTRUCTIONS = "Diamond Hands MCP \u2014 Bitcoin-collateralized borrowing. Before promising ANY flow, read the boundary://info resource and honor its `capabilities` block: it states which network this server is on, whether money is real (practiceWorld), whether writes are enabled (and the true reason when they are not), and which signer modes this build actually offers \u2014 never describe a flow outside it. State the network and whether funds are real when the user first acts. Authorization is chosen by conversation via the signer_setup tool (when listed); writes always require confirmed:true after showing the human-readable card. For walkthroughs consult the guide tool / guide:// resources instead of inventing steps; when a tool refuses, relay its stated reason and remedy \u2014 do not improvise alternatives. When a network_switch tool is listed, the network can change mid-session \u2014 after ANY switch, re-read boundary://info and state the new network and money reality to the user before doing anything else.";
92180
92155
  function createServer2(deps) {
92181
92156
  const server = new import_mcp2.McpServer(
@@ -92210,6 +92185,7 @@ function createServer2(deps) {
92210
92185
  }
92211
92186
 
92212
92187
  // src/index.ts
92188
+ net.setDefaultAutoSelectFamilyAttemptTimeout(Math.max(net.getDefaultAutoSelectFamilyAttemptTimeout(), 2e3));
92213
92189
  if (process.argv.includes("--version")) {
92214
92190
  process.stdout.write(`${SERVER_VERSION}
92215
92191
  `);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-mcp",
3
- "version": "0.3.0",
4
- "description": "MCP server for the Diamond Hands protocol — Bitcoin-collateralized UCD lending with human-approved signing (sepolia by default; mainnet read-only)",
3
+ "version": "0.4.0",
4
+ "description": "MCP server for the Diamond Hands protocol — Bitcoin-collateralized UCD lending with human-approved signing (sepolia practice by default; mainnet fully enabled)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
7
7
  "type": "git",