@gvnrdao/dh-mcp 0.0.1

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 (43) hide show
  1. package/.env.example +22 -0
  2. package/README.md +39 -0
  3. package/dist/index.js +1575 -0
  4. package/package.json +26 -0
  5. package/src/actions/index.ts +13 -0
  6. package/src/actions/loan-create.action.ts +28 -0
  7. package/src/actions/loan-extend.action.ts +17 -0
  8. package/src/actions/loan-mint.action.ts +17 -0
  9. package/src/actions/loan-pay.action.ts +17 -0
  10. package/src/actions/loan-withdraw.action.ts +17 -0
  11. package/src/actions/types.ts +33 -0
  12. package/src/config.ts +43 -0
  13. package/src/context.ts +87 -0
  14. package/src/index.ts +23 -0
  15. package/src/resources/position.ts +39 -0
  16. package/src/resources/protocol.ts +57 -0
  17. package/src/server.ts +58 -0
  18. package/src/signer/eoa-dh.ts +35 -0
  19. package/src/signer/index.ts +12 -0
  20. package/src/signer/safe-module-signer-adapter.ts +61 -0
  21. package/src/signer/safe-module.ts +110 -0
  22. package/src/signer/types.ts +12 -0
  23. package/src/tools/_helpers.ts +47 -0
  24. package/src/tools/btc.ts +38 -0
  25. package/src/tools/loan.ts +197 -0
  26. package/src/tools/position.ts +93 -0
  27. package/src/tools/protocol.ts +35 -0
  28. package/src/util/btc-address.ts +58 -0
  29. package/src/util/eip712-login.ts +65 -0
  30. package/src/util/errors.ts +24 -0
  31. package/src/util/extend-fee-bound.ts +51 -0
  32. package/src/util/format.ts +9 -0
  33. package/src/util/network.ts +34 -0
  34. package/src/util/server-fetch.ts +27 -0
  35. package/src/util/server-mint.ts +108 -0
  36. package/src/util/server-renew.ts +107 -0
  37. package/src/util/server-repay.ts +118 -0
  38. package/src/util/server-session.ts +108 -0
  39. package/src/util/server-withdraw.ts +34 -0
  40. package/src/util/tx-validator.ts +231 -0
  41. package/src/util/validate.ts +41 -0
  42. package/tsconfig.json +20 -0
  43. package/tsup.config.ts +11 -0
package/.env.example ADDED
@@ -0,0 +1,22 @@
1
+ # Required: private key for the borrower wallet (hex, 0x-prefixed or bare)
2
+ DH_PRIVATE_KEY=0x...
3
+
4
+ # Network: sepolia | mainnet | hardhat (default: sepolia)
5
+ DH_NETWORK=sepolia
6
+
7
+ # Ethereum RPC URL
8
+ ETH_RPC_URL=https://...
9
+
10
+ # lit-ops-server endpoint (default: http://localhost:3005)
11
+ DH_SERVICE_ENDPOINT=http://localhost:3005
12
+
13
+ # Lit Protocol network: chipotle | naga (default: chipotle)
14
+ DH_LIT_NETWORK=chipotle
15
+
16
+ # Safe module custody (optional)
17
+ # DH_SAFE_MODE=module
18
+ # DH_SAFE_ADDRESS=0x...
19
+ # DH_AGENT_MODULE=0x...
20
+
21
+ # Validator version override (optional)
22
+ # DH_VALIDATOR_VERSION=2
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # @gvnrdao/dh-mcp
2
+
3
+ MCP (Model Context Protocol) server for the Diamond Hands protocol. Exposes read and write tools
4
+ for lending positions (create, mint, repay, extend, withdraw BTC) backed by the Diamond Hands SDK.
5
+
6
+ ## Security model
7
+
8
+ These tools move real funds and create on-chain state. Treat them accordingly.
9
+
10
+ ### Write tools require explicit human confirmation (audit H-5)
11
+
12
+ The irreversible, fund-moving tools — `loan_create`, `loan_mint`, `loan_withdraw` — are gated by a
13
+ `confirmed: true` parameter. They **refuse to run** until it is set, and it is meant to be set by a
14
+ **human**, not by the model:
15
+
16
+ - The model should surface the exact operation (amounts, destination address, position) to the
17
+ user and obtain explicit approval **before** re-invoking with `confirmed: true`.
18
+ - These tools are annotated `destructiveHint: true`; compliant MCP hosts present an approval prompt.
19
+ - In a fully headless context with no human in the loop, leave `confirmed` unset — the tool will
20
+ refuse rather than move funds silently.
21
+
22
+ `loan_withdraw` sends BTC to an external address and is **unrecoverable**. The destination address
23
+ is validated against the configured BTC network (`validateBtcAddress`) — a mismatched-network
24
+ address is rejected before signing — but address correctness is still the human's responsibility.
25
+
26
+ ### Signer required for writes
27
+
28
+ All write tools run through `getSignedCtx` (a signer must be configured). Writes are additionally
29
+ blocked on mainnet via `requireNotMainnetForWrites`.
30
+
31
+ ### Supply chain (audit H-6)
32
+
33
+ `@gvnrdao/dh-sdk` is pinned to an exact version (not `latest`) so the dependency cannot drift
34
+ silently between installs. Bump it deliberately, in lockstep with the CLI, and run `npm ci` in CI.
35
+
36
+ ### Not mainnet-ready without review
37
+
38
+ This server has not been hardened for unattended mainnet operation. Do not point it at mainnet
39
+ funds without a dedicated security review of the host's approval flow and key management.