dexe-mcp 0.1.5 → 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 (111) hide show
  1. package/.mcp.example.json +12 -2
  2. package/CHANGELOG.md +84 -0
  3. package/FUTURE.md +26 -5
  4. package/README.md +105 -197
  5. package/dist/config.d.ts +12 -0
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +34 -1
  8. package/dist/config.js.map +1 -1
  9. package/dist/index.js +16 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/addresses.d.ts +57 -0
  12. package/dist/lib/addresses.d.ts.map +1 -0
  13. package/dist/lib/addresses.js +83 -0
  14. package/dist/lib/addresses.js.map +1 -0
  15. package/dist/lib/calldata.d.ts +32 -0
  16. package/dist/lib/calldata.d.ts.map +1 -0
  17. package/dist/lib/calldata.js +28 -0
  18. package/dist/lib/calldata.js.map +1 -0
  19. package/dist/lib/govEnums.d.ts +12 -0
  20. package/dist/lib/govEnums.d.ts.map +1 -0
  21. package/dist/lib/govEnums.js +35 -0
  22. package/dist/lib/govEnums.js.map +1 -0
  23. package/dist/lib/ipfs.d.ts +60 -0
  24. package/dist/lib/ipfs.d.ts.map +1 -0
  25. package/dist/lib/ipfs.js +168 -0
  26. package/dist/lib/ipfs.js.map +1 -0
  27. package/dist/lib/markdownToSlate.d.ts +39 -0
  28. package/dist/lib/markdownToSlate.d.ts.map +1 -0
  29. package/dist/lib/markdownToSlate.js +203 -0
  30. package/dist/lib/markdownToSlate.js.map +1 -0
  31. package/dist/lib/multicall.d.ts +33 -0
  32. package/dist/lib/multicall.d.ts.map +1 -0
  33. package/dist/lib/multicall.js +46 -0
  34. package/dist/lib/multicall.js.map +1 -0
  35. package/dist/lib/proposalCatalog.d.ts +45 -0
  36. package/dist/lib/proposalCatalog.d.ts.map +1 -0
  37. package/dist/lib/proposalCatalog.js +416 -0
  38. package/dist/lib/proposalCatalog.js.map +1 -0
  39. package/dist/lib/signer.d.ts +12 -0
  40. package/dist/lib/signer.d.ts.map +1 -0
  41. package/dist/lib/signer.js +31 -0
  42. package/dist/lib/signer.js.map +1 -0
  43. package/dist/lib/subgraph.d.ts +15 -0
  44. package/dist/lib/subgraph.d.ts.map +1 -0
  45. package/dist/lib/subgraph.js +42 -0
  46. package/dist/lib/subgraph.js.map +1 -0
  47. package/dist/tools/dao.d.ts +4 -0
  48. package/dist/tools/dao.d.ts.map +1 -0
  49. package/dist/tools/dao.js +242 -0
  50. package/dist/tools/dao.js.map +1 -0
  51. package/dist/tools/daoDeploy.d.ts +4 -0
  52. package/dist/tools/daoDeploy.d.ts.map +1 -0
  53. package/dist/tools/daoDeploy.js +573 -0
  54. package/dist/tools/daoDeploy.js.map +1 -0
  55. package/dist/tools/flow.d.ts +5 -0
  56. package/dist/tools/flow.d.ts.map +1 -0
  57. package/dist/tools/flow.js +451 -0
  58. package/dist/tools/flow.js.map +1 -0
  59. package/dist/tools/index.d.ts.map +1 -1
  60. package/dist/tools/index.js +32 -0
  61. package/dist/tools/index.js.map +1 -1
  62. package/dist/tools/ipfs.d.ts +6 -0
  63. package/dist/tools/ipfs.d.ts.map +1 -0
  64. package/dist/tools/ipfs.js +376 -0
  65. package/dist/tools/ipfs.js.map +1 -0
  66. package/dist/tools/proposal.d.ts +4 -0
  67. package/dist/tools/proposal.d.ts.map +1 -0
  68. package/dist/tools/proposal.js +217 -0
  69. package/dist/tools/proposal.js.map +1 -0
  70. package/dist/tools/proposalBuild.d.ts +4 -0
  71. package/dist/tools/proposalBuild.d.ts.map +1 -0
  72. package/dist/tools/proposalBuild.js +372 -0
  73. package/dist/tools/proposalBuild.js.map +1 -0
  74. package/dist/tools/proposalBuildComplex.d.ts +4 -0
  75. package/dist/tools/proposalBuildComplex.d.ts.map +1 -0
  76. package/dist/tools/proposalBuildComplex.js +766 -0
  77. package/dist/tools/proposalBuildComplex.js.map +1 -0
  78. package/dist/tools/proposalBuildInternal.d.ts +4 -0
  79. package/dist/tools/proposalBuildInternal.d.ts.map +1 -0
  80. package/dist/tools/proposalBuildInternal.js +224 -0
  81. package/dist/tools/proposalBuildInternal.js.map +1 -0
  82. package/dist/tools/proposalBuildMore.d.ts +4 -0
  83. package/dist/tools/proposalBuildMore.d.ts.map +1 -0
  84. package/dist/tools/proposalBuildMore.js +457 -0
  85. package/dist/tools/proposalBuildMore.js.map +1 -0
  86. package/dist/tools/proposalBuildOffchain.d.ts +4 -0
  87. package/dist/tools/proposalBuildOffchain.d.ts.map +1 -0
  88. package/dist/tools/proposalBuildOffchain.js +389 -0
  89. package/dist/tools/proposalBuildOffchain.js.map +1 -0
  90. package/dist/tools/read.d.ts +4 -0
  91. package/dist/tools/read.d.ts.map +1 -0
  92. package/dist/tools/read.js +580 -0
  93. package/dist/tools/read.js.map +1 -0
  94. package/dist/tools/subgraph.d.ts +4 -0
  95. package/dist/tools/subgraph.d.ts.map +1 -0
  96. package/dist/tools/subgraph.js +404 -0
  97. package/dist/tools/subgraph.js.map +1 -0
  98. package/dist/tools/txSend.d.ts +5 -0
  99. package/dist/tools/txSend.d.ts.map +1 -0
  100. package/dist/tools/txSend.js +87 -0
  101. package/dist/tools/txSend.js.map +1 -0
  102. package/dist/tools/vote.d.ts +4 -0
  103. package/dist/tools/vote.d.ts.map +1 -0
  104. package/dist/tools/vote.js +196 -0
  105. package/dist/tools/vote.js.map +1 -0
  106. package/dist/tools/voteBuild.d.ts +4 -0
  107. package/dist/tools/voteBuild.d.ts.map +1 -0
  108. package/dist/tools/voteBuild.js +983 -0
  109. package/dist/tools/voteBuild.js.map +1 -0
  110. package/package.json +18 -5
  111. package/PLAN.md +0 -132
package/.mcp.example.json CHANGED
@@ -1,8 +1,18 @@
1
1
  {
2
- "_comment": "Mac/Linux: use `dexe-mcp` directly. Windows: replace with { command: 'cmd', args: ['/c', 'dexe-mcp'] }. See README.md for the full install matrix.",
2
+ "_comment": "Mac/Linux: use `dexe-mcp` directly. Windows: use the absolute-path form (node.exe + dist/index.js). See README.md. Env vars are all optional — tools that need them fail with a clear message.",
3
3
  "mcpServers": {
4
4
  "dexe": {
5
- "command": "dexe-mcp"
5
+ "command": "dexe-mcp",
6
+ "env": {
7
+ "DEXE_PROTOCOL_PATH": "/absolute/path/to/DeXe-Protocol",
8
+ "DEXE_RPC_URL": "https://bsc-dataseed.binance.org",
9
+ "DEXE_CHAIN_ID": "56",
10
+ "DEXE_PINATA_JWT": "<your Pinata JWT>",
11
+ "DEXE_IPFS_GATEWAY": "https://<your-subdomain>.mypinata.cloud",
12
+ "DEXE_IPFS_GATEWAYS_FALLBACK": "https://dweb.link,https://ipfs.io",
13
+ "DEXE_SUBGRAPH_INTERACTIONS_URL": "https://api.studio.thegraph.com/query/.../dao-interactions/...",
14
+ "DEXE_BACKEND_API_URL": "https://api.dexe.io"
15
+ }
6
16
  }
7
17
  }
8
18
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,89 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0
4
+
5
+ End-to-end testnet validation. Every proposal-builder tool is now exercised by an automated swarm scenario on BSC testnet, and the harness itself ships in-repo so external integrators can run it. **111 tools** total, **41 swarm scenarios**, full sweep green.
6
+
7
+ ### Added
8
+
9
+ **Swarm test harness (`tests/swarm/` + `scripts/swarm/`)**
10
+ - `scripts/swarm/orchestrator.ts` — scenario loader + dispatcher. Inline ethers dispatchers for the no-IPFS toolset (vote_user_power, read_delegation_map, build_undelegate, build_withdraw, build_withdraw_all, build_erc20_approve, build_deposit, build_delegate, build_vote). Generic MCP-stdio fallback (`mcpFallbackDispatcher`) routes anything else through the dexe-mcp child server, so adding a scenario for a new tool is JSON-only — no code changes.
11
+ - Loop expansion (`spec.loop.over` × `appliesToSteps`), template engine (`{{dao}}`, `{{firstAllowlistedToken}}`, `{{firstAllowlistedDao}}`, `{{secondAllowlistedDao}}`, `{{dao.<helper>}}`, `{{agent:X:address}}`, `{{capture.path}}`, `{{capture.0.field}}`), `skipIf` evaluator with limited expressions, deferred-cascade for chained captures, wallet semaphore for parallel-safe broadcasts, per-scenario `prefund` hook that tops up agents from `AGENT_FUNDER_PK` before each scenario runs.
12
+ - `scripts/swarm/preflight.ts` + `scripts/swarm/fund-pool.ts` — wallet-readiness check + token allowlist–enforced top-up. Hard-refuses to send to any non-pool address or any token not on the allowlist.
13
+ - `scripts/swarm/nightly.sh` — Phase 5 cron runner. Pulls main, runs preflight + full sweep, tails the run report, posts the one-line summary to `SWARM_SUMMARY_WEBHOOK` and/or `SWARM_SUMMARY_ISSUE` (gh CLI), runs a triage stub on failure (with `SWARM_FIXER=1` opt-in for auto-fix), and rotates run-report dirs older than 30 days while keeping the latest 50.
14
+ - `scripts/swarm/orchestrator.ts` emits a single greppable summary line after `writeReport`: `SWARM <runId> <pass>/<total> <mode> <chainTag> <reportPath>` — consumed by nightly.sh and any external poster.
15
+ - `scripts/swarm/one-shot-execute.mjs` — closes a proposal lifecycle once it reaches `SucceededFor`. Polls + caps `wait()` at 90 s to avoid sandbox hangs.
16
+ - 41 scenario JSONs covering: reset, delegation chain, validator pass / veto / full lifecycle, expert / participation / staking / validator / catalog / cross-DAO / multi-proposal-state read snapshots, cancel-vote, decode-and-introspect, build-only sanity for every external + internal proposal type from `dexe_proposal_catalog`.
17
+ - Role prompts: `proposer`, `voter`, `delegator`, `reporter`, `triage`, `validator`, `expert`, `fixer`, plus `_shared.md` and the dao-personas fixture. Fixer prompt encodes the CLAUDE.md auto-fix loop verbatim — branch `swarm-fix/<YYYY-MM-DD>`, never push to main, diff scope hard-bounded to `src/tools/`, `src/lib/`, `tests/swarm/`.
18
+
19
+ **Composite + signing tools**
20
+ - `dexe_proposal_create` — full prerequisite handling: balance check, ERC20 approve, deposit, IPFS metadata upload, `createProposalAndVote`. When `DEXE_PRIVATE_KEY` is set the tool signs and broadcasts; otherwise returns the ordered `TxPayload` list. Supports `proposalType: 'modify_dao_profile' | 'custom'`.
21
+ - `dexe_proposal_vote_and_execute` — vote-then-execute composite with `autoExecute` + `depositFirst` flags.
22
+ - `dexe_tx_send` + `dexe_tx_status` — opt-in signer surface that uses the configured `DEXE_PRIVATE_KEY` when present. Calls remain calldata-by-default; users opt in by setting the env var.
23
+ - `dexe_dao_build_deploy` predicted-address auto-wiring: `govToken` flowed into `userKeeperParams.tokenAddress` and `distributionProposal` + `govTokenSale` into `additionalProposalExecutors` automatically. LINEAR / POLYNOMIAL `votePower` initData auto-encoded.
24
+
25
+ **Reads + introspection**
26
+ - `dexe_read_dao_list`, `_dao_members`, `_dao_experts`, `_user_activity`, `_distribution_status`, `_token_sale_tiers`, `_token_sale_user`, `_staking_info`, `_validator_list`, `_privacy_policy_status`, `_delegation_map` — fill out the DAO read surface.
27
+ - `dexe_get_methods` returns structured per-function metadata (4-byte selectors, mutability, full structured inputs/outputs with `internalType` preserved for tuples).
28
+ - `dexe_proposal_voters` switched to the `pools` subgraph and the proposalInteractions composite ID format (poolAddr + uint32LE(proposalId), no separator).
29
+ - `dexe_decode_proposal` understands every external + internal proposal action shape.
30
+
31
+ ### Fixed
32
+
33
+ - **Proposal metadata format**: builders now emit `proposalName` / `proposalDescription` (not `name` / `description`), wrap diffs inside `changes: { proposedChanges, currentChanges }`, set `isMeta: false`, and round-trip identical to the frontend reference. 17 builders touched.
34
+ - **Approve target for deposits** is `UserKeeper`, not `GovPool`. Both flow tools (`proposal_create`, `vote_and_execute`) now approve the right address.
35
+ - **Personal voting power** = `tokenBalance.balance − ownedBalance` (deposited only). Without this, `withdraw` on freshly-funded agents reverts `GovUK: can't withdraw this`.
36
+ - **VotePower initData** uses `__LinearPower_init()` selector `0x892aea1f` (not empty `0x`) so newly-deployed DAOs initialize their LINEAR vote-power proxy correctly.
37
+ - **`STATE_NAMES` enum order** corrected (Defeated / Locked positions were swapped).
38
+ - **Custom-proposal IPFS metadata** now includes `category`, `isMeta`, `proposedChanges`, `currentChanges`.
39
+ - **Subgraph migration**: Studio URLs deprecated; switched to The Graph decentralized network with API key. Per-chain endpoints documented.
40
+ - **IPFS gateway path normalization**: dedicated gateways configured with a trailing `/ipfs` (e.g. `https://<sub>.mypinata.cloud/ipfs`) no longer produce `/ipfs/ipfs/<cid>` 404s.
41
+
42
+ ### Changed
43
+
44
+ - README updated: tool count `83 → 111`, new "Swarm test harness" section.
45
+ - `process.loadEnvFile()` is invoked from `index.ts` so the MCP server loads `.env` itself; users no longer have to plumb env-var changes through their MCP client config (which often doesn't reload).
46
+ - Repo now ships `.claude/skills/swarm-test/SKILL.md` for users running Claude Code; lets them invoke the swarm with `/swarm-test`.
47
+
48
+ ### Notes
49
+
50
+ - **Validated network**: BSC testnet (chain 97). Two fixture DAOs deployed for the harness — Glacier (50% quorum, no validators) and Sentinel (5% quorum, 2 validators with 1k SVT each).
51
+ - **Mainnet status**: a separate run pass is staged (Stage B per `tests/swarm/README.md`) but blocked on a previously-observed `PoolFactory.deployGovPool` revert. Re-validate when the protocol team confirms a fix.
52
+ - **Off-chain backend tools** require `DEXE_BACKEND_API_URL` and only run on chains where DeXe operates a backend. The corresponding swarm scenarios declare `requiresChain: [56]` so they auto-skip on testnet.
53
+
54
+ ## 0.2.0
55
+
56
+ The big one — dexe-mcp expands from 15 dev-tooling tools to **83 tools** covering the full DeXe DAO lifecycle. AI agents can now create DAOs, build any of the 33 proposal types the DeXe frontend exposes, upload metadata to IPFS, stake/delegate/vote/execute/claim — all end-to-end.
57
+
58
+ ### Added
59
+
60
+ **Foundations + reads (13 tools)** — `dexe_dao_info`, `dexe_dao_predict_addresses`, `dexe_dao_registry_lookup`, `dexe_proposal_state`, `dexe_proposal_list`, `dexe_proposal_voters`, `dexe_vote_user_power`, `dexe_vote_get_votes`, `dexe_read_multicall`, `dexe_read_treasury`, `dexe_read_validators`, `dexe_read_settings`, `dexe_read_expert_status`. Backed by an `AddressBook` that resolves contracts via `ContractsRegistry`, a Multicall3 batch helper, a canonical `TxPayload` shape, enum mirrors for `ProposalState` / `VoteType`, and a minimal subgraph GraphQL client.
61
+
62
+ **IPFS (6 tools)** — `dexe_ipfs_upload_proposal_metadata`, `_upload_dao_metadata`, `_upload_file`, `_fetch`, `_cid_info`, `_cid_for_json`. Backed by a Pinata client and local CID computation via `multiformats`. Public gateways (dweb.link, ipfs.io, cf-ipfs, 4everland) are unreliable and NOT defaulted. Users must set `DEXE_IPFS_GATEWAY` to a dedicated gateway (the one Pinata provides alongside the JWT is recommended). Public gateways are opt-in via `DEXE_IPFS_GATEWAYS_FALLBACK` (comma-separated, tried sequentially — no parallel races).
63
+
64
+ **Proposals — all 33 types (35 tools)**
65
+ - `dexe_proposal_catalog` — enumerate every proposal type the DeXe UI exposes (24 external, 4 internal, 5 off-chain), with metadata shape, gating, and linked MCP builder.
66
+ - Primitives: `dexe_proposal_build_external` (+ `createProposalAndVote`), `dexe_proposal_build_internal`, `dexe_proposal_build_custom_abi`, `dexe_proposal_build_offchain`.
67
+ - External wrappers (each returns `{ metadata, actions: Action[] }`): `token_transfer`, `token_distribution`, `token_sale`, `token_sale_recover`, `change_voting_settings`, `manage_validators`, `add_expert`, `remove_expert`, `withdraw_treasury`, `delegate_to_expert`, `revoke_from_expert`, `create_staking_tier`, `change_math_model`, `modify_dao_profile`, `blacklist`, `reward_multiplier`, `apply_to_dao`, `new_proposal_type` (also covers *Enable Staking*).
68
+ - Internal validator wrappers (each returns `{ metadata, proposalType, data }`): `change_validator_balances` (type 0), `change_validator_settings` (type 1), `monthly_withdraw` (type 2), `offchain_internal_proposal` (type 3).
69
+ - Off-chain backend proposals: `offchain_single_option`, `offchain_multi_option`, `offchain_for_against`, `offchain_settings`. Plus `dexe_auth_request_nonce` + `dexe_auth_login_request` for the 2-step Bearer flow, and `dexe_offchain_build_vote` / `dexe_offchain_build_cancel_vote`.
70
+ - **Write model is calldata-only.** No signer, no private keys. Every write tool emits a signable payload the agent's wallet submits.
71
+
72
+ **Vote / stake / execute / claim writes (14 tools)** — `erc20_approve`, `deposit` (payable for native-staking DAOs), `withdraw`, `delegate`, `undelegate`, `vote`, `cancel_vote`, `validator_vote`, `validator_cancel_vote`, `move_to_validators`, `execute`, `claim_rewards`, `claim_micropool_rewards`, plus `multicall` to batch any of the above into one atomic tx. Arg-order gotchas captured in code comments (e.g. `GovPool.vote(pid, isFor, amount, nftIds)` vs `GovValidators.voteInternalProposal(pid, amount, isFor)`).
73
+
74
+ **DAO deploy (1 tool)** — `dexe_dao_build_deploy` encodes `PoolFactory.deployGovPool(GovPoolDeployParams)` with the full nested struct (settings / validators / userKeeper / token / votePower / verifier / BABT flag / descriptionURL / name). Auto-resolves PoolFactory via `ContractsRegistry` if omitted. When `deployer` + RPC are available, also returns the predicted GovPool address so agents can wire follow-up txs before the DAO exists. Encodes against the compiled `PoolFactory.json` artifact when present (strict parity); falls back to a hand-rolled tuple signature derived from `IPoolFactory.sol` otherwise.
75
+
76
+ ### Changed
77
+
78
+ - `src/config.ts` adds `DEXE_CHAIN_ID` (default 56), `DEXE_CONTRACTS_REGISTRY` override, `DEXE_PINATA_JWT`, three subgraph URL overrides, `DEXE_BACKEND_API_URL`.
79
+ - `package.json` description rewritten to reflect full DAO-ops scope. New dep: `multiformats` (Protocol Labs, for local CID computation).
80
+ - `README.md` reorganized around the eight tool groups; added the full env-var matrix.
81
+
82
+ ### Notes
83
+
84
+ - **No breaking changes.** All v0.1.x tools remain. The write contract is new-world: `TxPayload` for single-tx builders, `Action[]` for proposal wrappers — never a singular `action` field.
85
+ - **Deferred to future work** (`FUTURE.md`): Hardhat-fork simulation (`dexe_simulate_vote`), signer-aware send mode, additional IPFS pinning providers (Storacha, Lighthouse), and alternate subgraphs.
86
+
3
87
  ## 0.1.5
4
88
 
5
89
  ### Fixed
package/FUTURE.md CHANGED
@@ -1,8 +1,29 @@
1
1
  # Future work
2
2
 
3
- Tracking features deliberately deferred out of the Phase A / B roadmap.
3
+ Deliberately deferred out of v0.2.0. Kept here so we don't re-litigate during planning.
4
4
 
5
- ## `dexe_get_storage_layout` (dropped from v1)
5
+ ## Signer-aware send mode
6
+
7
+ Every v0.2.0 write tool returns calldata (`TxPayload`). Actually *sending* the tx — reading a `PRIVATE_KEY` or opening a local keystore and submitting via ethers `Wallet.sendTransaction` — is deferred. Reason: scope + security posture. We don't want private keys anywhere near the MCP process by default. If re-opened, expose as an opt-in mode gated on an explicit `DEXE_SIGNING_MODE=enabled` env var with loud warnings in tool output.
8
+
9
+ ## `dexe_simulate_vote` + Hardhat fork management
10
+
11
+ Spawn a managed `hardhat node --fork $DEXE_RPC_URL` child process owned by the MCP, impersonate a voter, submit the `vote` calldata against the fork, and report success/revert with gas used. Would live in `src/fork.ts`.
12
+
13
+ ## Additional IPFS pinning providers
14
+
15
+ v0.2.0 ships Pinata only. Reasonable candidates if we need a second:
16
+ - **Lighthouse.storage** — one-time payment, permanent Filecoin storage. Best long-term fit for DAO metadata that must never disappear. User has flagged interest.
17
+ - **Storacha / web3.storage** — UCAN-based, Filecoin-backed, free tier.
18
+ - **Filebase** — S3-compatible, Filecoin-backed.
19
+
20
+ Design: extend `src/lib/ipfs.ts` with an `IpfsUploader` interface, factor Pinata into an adapter, add new adapters behind `DEXE_IPFS_PROVIDER`.
21
+
22
+ ## Additional subgraphs
23
+
24
+ We wire `DEXE_SUBGRAPH_INTERACTIONS_URL` (voter lists) and reserved slots for pools/validators subgraphs. Fleshing out list/search tools that use those other subgraphs is deferred — driven by user demand.
25
+
26
+ ## `dexe_get_storage_layout`
6
27
 
7
28
  The current `DeXe-Protocol/hardhat.config.js` does not include `storageLayout` in `outputSelection`, so build-info files don't contain the data this tool would read.
8
29
 
@@ -25,13 +46,13 @@ solidity: {
25
46
 
26
47
  Then the tool becomes a short handler reading `output.contracts[file][name].storageLayout` from the matching build-info JSON.
27
48
 
28
- ## `dexe_simulate_vote` (Phase B)
49
+ ## Fixture tests for write builders
29
50
 
30
- Needs a managed `hardhat node --fork $DEXE_RPC_URL` child process owned by the MCP. See `src/fork.ts` (not yet created) per the execution plan at `C:\Users\edwar\.claude\plans\kind-rolling-pelican.md`.
51
+ Phase 3 and 4 wrappers were verified against the DeXe frontend encodings but don't yet have byte-for-byte golden-file tests. For every `*_build_*` tool, capture the hex calldata from the frontend on identical inputs and snapshot it.
31
52
 
32
53
  ## Other ideas surfaced during design
33
54
 
34
55
  - **TypeChain integration** — the protocol already emits ethers-v5 TypeChain bindings. We intentionally parse ABI JSON directly (dexe-mcp uses ethers v6). Revisit if/when DeXe-Protocol moves to ethers v6.
35
- - **Custom `hardhat-migrate` wrappers** — out of scope per user decision (deployment tooling excluded).
56
+ - **Custom `hardhat-migrate` wrappers** — out of scope per user decision (deployment tooling excluded from the dev-tool surface).
36
57
  - **Gas reporter parsing** — the `hardhat-gas-reporter` plugin is already wired in the protocol; `dexe_test` could optionally parse its output for per-function gas numbers.
37
58
  - **Foundry fallback** — the repo is pure Hardhat today. Skip unless a Foundry config is added upstream.
package/README.md CHANGED
@@ -2,51 +2,26 @@
2
2
 
3
3
  ![npm](https://img.shields.io/npm/v/dexe-mcp.svg)
4
4
 
5
- MCP server for Claude Code / Antigravity that wraps the [DeXe Protocol](https://github.com/dexe-network/DeXe-Protocol) Hardhat codebase with build/test, contract introspection, and governance-domain tools.
5
+ MCP server that gives AI agents **full DeXe Protocol DAO operations coverage** — deploy DAOs, build any of the 33 proposal types the DeXe UI exposes, upload metadata to IPFS, stake/delegate/vote/execute/claim. Plus dev tooling: build/test/lint, contract introspection, ABI-aware calldata decoding.
6
6
 
7
- ## Prerequisites
7
+ **Two write modes, calldata-default.** Every write tool returns a ready-to-sign `TxPayload = { to, data, value, chainId, description }` that the agent's wallet (MetaMask, Safe, hardware, etc.) signs and submits — no key in the MCP. Power users who *want* the server to sign and broadcast can opt in by setting `DEXE_PRIVATE_KEY`; that unlocks `dexe_tx_send`, `dexe_tx_status`, and the auto-broadcast branch of `dexe_proposal_create` / `dexe_proposal_vote_and_execute`. Default stays calldata-only.
8
8
 
9
- - **Node.js >= 20** with a working `npm`. Verify before continuing:
9
+ **111 tools** across 9 groups. Call `dexe_proposal_catalog` at runtime for the full proposal-type map, or browse the [catalog](#tool-catalog) below.
10
10
 
11
- ```bash
12
- node --version # should print v20.x or higher
13
- npm --version # MUST print a version, not "command not found"
14
- ```
11
+ > **End-to-end coverage.** Every proposal-builder tool ships with a swarm-test scenario that exercises it on BSC testnet. Latest pass: **41/41 scenarios green**, ~200 broadcasts validated against two fixture DAOs (Glacier 50%-quorum + Sentinel 5%-quorum-with-validators). See [Swarm test harness](#swarm-test-harness) below.
15
12
 
16
- If `npm --version` fails, you have a stripped Node install (a bare `node.exe` without the rest of the toolchain — common on Windows when `C:\Program Files\nodejs\node.exe` was placed manually). Install Node from <https://nodejs.org> or via [nvm](https://github.com/nvm-sh/nvm) / [nvm-windows](https://github.com/coreybutler/nvm-windows) and retry. Without npm, `npm install -g dexe-mcp` silently does nothing.
13
+ ## Prerequisites
17
14
 
18
- - **Git** — only needed on first run, to clone DeXe-Protocol. If you already have a local checkout, point `DEXE_PROTOCOL_PATH` at it and git is optional.
15
+ - **Node.js 20** with a working `npm` (`node --version` and `npm --version` must both succeed).
16
+ - **Git** — only needed the first time a build tool runs, to clone DeXe-Protocol. Skippable if you point `DEXE_PROTOCOL_PATH` at an existing checkout.
19
17
 
20
18
  ## Install
21
19
 
22
- ### 1. Install the package globally
23
-
24
20
  ```bash
25
21
  npm install -g dexe-mcp
26
22
  ```
27
23
 
28
- Verify the install landed by asking npm where it put it:
29
-
30
- ```bash
31
- npm root -g
32
- # Mac/Linux: /usr/local/lib/node_modules (or ~/.nvm/versions/node/vXX.X.X/lib/node_modules)
33
- # Windows: C:\Users\<you>\AppData\Roaming\nvm\<version>\node_modules
34
- # (or C:\Users\<you>\AppData\Roaming\npm\node_modules for non-nvm)
35
- ```
36
-
37
- Note the output — you'll need it for the Windows install step below. The package lives at `<npm-root>/dexe-mcp/dist/index.js`.
38
-
39
- ### 2. Register the MCP server
40
-
41
- #### Mac / Linux
42
-
43
- Bare command works because Unix `exec` resolves PATH directly:
44
-
45
- ```bash
46
- claude mcp add dexe -- dexe-mcp
47
- ```
48
-
49
- Or in JSON (`.mcp.json`, `claude_desktop_config.json`, etc.):
24
+ Register the server with your MCP client (`.mcp.json`, `claude_desktop_config.json`, etc.):
50
25
 
51
26
  ```json
52
27
  {
@@ -58,84 +33,24 @@ Or in JSON (`.mcp.json`, `claude_desktop_config.json`, etc.):
58
33
  }
59
34
  ```
60
35
 
61
- #### Windows recommended: absolute path to `node` + `dist/index.js`
62
-
63
- On Windows, `dexe-mcp` is installed as a `.cmd` shim that many MCP clients (including Claude Code as of this writing) fail to spawn cleanly over stdio. The **absolute-path** form bypasses shim resolution entirely and is the known-good recipe:
64
-
65
- ```bash
66
- claude mcp add dexe -- "C:\Program Files\nodejs\node.exe" "C:\Users\<you>\AppData\Roaming\nvm\<version>\node_modules\dexe-mcp\dist\index.js"
67
- ```
68
-
69
- Substitute `<you>` and `<version>` (or use whatever `npm root -g` printed above). In JSON:
36
+ If your client can't spawn the bare `dexe-mcp` command directly (a known issue with some MCP clients on Windows when PATH-shim resolution is involved), point it at the installed script via Node:
70
37
 
71
38
  ```json
72
39
  {
73
40
  "mcpServers": {
74
41
  "dexe": {
75
- "command": "C:/Program Files/nodejs/node.exe",
76
- "args": ["C:/Users/<you>/AppData/Roaming/nvm/<version>/node_modules/dexe-mcp/dist/index.js"]
77
- }
78
- }
79
- }
80
- ```
81
-
82
- This works because:
83
- - No PATH dependency — every argument is an absolute path
84
- - No `.cmd` / `.ps1` shim in the chain, so `CreateProcess` semantics don't trip over missing extensions
85
- - `dexe-mcp` internally invokes `npm`/`hardhat` via `process.execPath`, so it uses whichever Node you pointed at and does not need npm on the spawned process PATH
86
-
87
- <details>
88
- <summary>Alternative: <code>cmd /c dexe-mcp</code> (not recommended — often unreliable with Claude Code)</summary>
89
-
90
- ```json
91
- {
92
- "mcpServers": {
93
- "dexe": {
94
- "command": "cmd",
95
- "args": ["/c", "dexe-mcp"]
42
+ "command": "node",
43
+ "args": ["<output of `npm root -g`>/dexe-mcp/dist/index.js"]
96
44
  }
97
45
  }
98
46
  }
99
47
  ```
100
48
 
101
- Use only if the absolute-path form is inconvenient. End-to-end testing showed this can pass a direct stdio check but fail to complete the MCP handshake when spawned by Claude Code.
102
- </details>
103
-
104
- ### 3. Verify the install (optional but recommended)
105
-
106
- Before wiring the server into your MCP client, confirm the binary can actually speak MCP over stdio. On any OS:
107
-
108
- ```bash
109
- # Send a minimal initialize request, expect a capabilities JSON back.
110
- echo "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{},\"clientInfo\":{\"name\":\"t\",\"version\":\"1\"}}}" | dexe-mcp
111
- ```
112
-
113
- On Windows if the above hangs, try instead:
114
-
115
- ```bash
116
- echo {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"1"}}} | node "C:\Users\<you>\AppData\Roaming\nvm\<version>\node_modules\dexe-mcp\dist\index.js"
117
- ```
118
-
119
- A healthy response starts with a single stderr line (`[dexe-mcp] connected on stdio. …`) and a stdout JSON blob containing `"serverInfo":{"name":"dexe-mcp"}`. If you see that, the server is fine and any "failed to connect" from your MCP client is purely a client-side spawn/config problem, not a bug in dexe-mcp.
120
-
121
- ### 4. Restart your MCP client
122
-
123
- On the first build-tool call (e.g. `dexe_compile`), `dexe-mcp` will automatically:
49
+ Run `npm root -g` to resolve the path on your machine. Restart the MCP client and the `dexe_*` tools will appear.
124
50
 
125
- 1. Shallow-clone `dexe-network/DeXe-Protocol` into a platform cache directory (~200 MB)
126
- 2. Run `npm install` in that checkout (a few minutes, one time)
51
+ ## Quickstart
127
52
 
128
- The MCP server itself starts instantly the heavy work is deferred until you actually need it. Cache locations:
129
-
130
- | OS | Path |
131
- |----|------|
132
- | Windows | `%LOCALAPPDATA%\dexe-mcp\DeXe-Protocol` |
133
- | macOS | `~/Library/Caches/dexe-mcp/DeXe-Protocol` |
134
- | Linux | `$XDG_CACHE_HOME/dexe-mcp/DeXe-Protocol` (or `~/.cache/dexe-mcp/DeXe-Protocol`) |
135
-
136
- ### Advanced: existing DeXe-Protocol checkout
137
-
138
- If you already have a DeXe-Protocol clone you want to reuse (and have run `npm install` there at least once), set `DEXE_PROTOCOL_PATH`:
53
+ Minimum config to get **read-only** access to a BSC mainnet DAO:
139
54
 
140
55
  ```json
141
56
  {
@@ -143,122 +58,119 @@ If you already have a DeXe-Protocol clone you want to reuse (and have run `npm i
143
58
  "dexe": {
144
59
  "command": "dexe-mcp",
145
60
  "env": {
146
- "DEXE_PROTOCOL_PATH": "/absolute/path/to/your/DeXe-Protocol"
61
+ "DEXE_RPC_URL": "https://bsc-dataseed.binance.org",
62
+ "DEXE_CHAIN_ID": "56"
147
63
  }
148
64
  }
149
65
  }
150
66
  }
151
67
  ```
152
68
 
153
- With this set, dexe-mcp will **not** clone or install anything it trusts the path you gave it. On Windows, wrap `command` with `cmd /c` as above.
69
+ Add `DEXE_PINATA_JWT` for IPFS uploads, `DEXE_BACKEND_API_URL` for off-chain proposals, and per-chain subgraph URLs for `dexe_proposal_voters` and the DAO-list reads. Full matrix [`docs/ENVIRONMENT.md`](./docs/ENVIRONMENT.md).
154
70
 
155
- ### Dev mode (working on dexe-mcp itself)
71
+ Three first-call examples (full set in [`docs/USAGE.md`](./docs/USAGE.md)):
156
72
 
157
- Clone this repo, build, and point the MCP command at the local `dist/index.js`:
73
+ ```jsonc
74
+ // 1) discover available proposal types
75
+ dexe_proposal_catalog({ category: "all", implementedOnly: true })
158
76
 
159
- ```bash
160
- git clone https://github.com/edward-arinin-web-dev/dexe-mcp.git
161
- cd dexe-mcp
162
- npm install
163
- npm run build
164
- ```
77
+ // 2) read a DAO
78
+ dexe_dao_info({ govPool: "0x..." })
165
79
 
166
- ```json
167
- {
168
- "mcpServers": {
169
- "dexe": {
170
- "command": "node",
171
- "args": ["/absolute/path/to/dexe-mcp/dist/index.js"],
172
- "env": {
173
- "DEXE_PROTOCOL_PATH": "/absolute/path/to/DeXe-Protocol"
174
- }
175
- }
176
- }
177
- }
80
+ // 3) build a token-transfer proposal (calldata only)
81
+ dexe_proposal_build_token_transfer({
82
+ govPool: "0x...",
83
+ token: "0x...",
84
+ recipient: "0x...",
85
+ amount: "1000000000000000000"
86
+ })
178
87
  ```
179
88
 
180
89
  ## First run
181
90
 
182
- Before introspection tools work, run `dexe_compile` once per session to populate `DeXe-Protocol/artifacts/`. You will get a clear "artifacts not found" error otherwise. On a brand-new install the first `dexe_compile` also triggers the clone + `npm install` steps described above.
183
-
184
- ## Tool catalog
185
-
186
- ### Build / test
187
-
188
- | Tool | Description |
189
- |------|-------------|
190
- | `dexe_compile` | Compile all contracts via Hardhat |
191
- | `dexe_test` | Run the test suite (optional grep filter) |
192
- | `dexe_coverage` | Run tests with solidity-coverage |
193
- | `dexe_lint` | Lint Solidity sources with solhint |
91
+ The MCP server starts instantly. On the first build-tool call (`dexe_compile` / `dexe_test` / `dexe_lint`), dexe-mcp will automatically shallow-clone DeXe-Protocol into a platform cache directory and run `npm install` there once. If you prefer to reuse an existing checkout, set `DEXE_PROTOCOL_PATH` in the MCP `env` block and nothing will be cloned.
194
92
 
195
- ### Contract introspection
196
-
197
- | Tool | Description |
198
- |------|-------------|
199
- | `dexe_list_contracts` | List all compiled contracts (filter by name/kind) |
200
- | `dexe_get_abi` | Get the full ABI for a contract |
201
- | `dexe_get_methods` | Enumerate read (view/pure) and write (nonpayable/payable) methods with structured inputs/outputs and `internalType` — for generating TypeScript interfaces |
202
- | `dexe_get_selectors` | List function selectors for a contract |
203
- | `dexe_find_selector` | Reverse-lookup: selector hex to function signature |
204
- | `dexe_get_natspec` | Read NatSpec documentation for a contract |
205
- | `dexe_get_source` | Read Solidity source code for a contract |
206
-
207
- ### Governance domain
208
-
209
- | Tool | Description |
210
- |------|-------------|
211
- | `dexe_decode_calldata` | Decode arbitrary calldata against contract ABI |
212
- | `dexe_decode_proposal` | Fetch and decode a full on-chain proposal |
213
- | `dexe_read_gov_state` | Read governance pool state from chain |
214
- | `dexe_list_gov_contract_types` | List known governance contract type names |
93
+ Most tools don't need the protocol checkout at all — read/proposal/vote/deploy builders only need an RPC URL. Only the dev-tooling group (`dexe_compile`, `dexe_test`, `dexe_coverage`, `dexe_lint`, and the introspection tools) depends on artifacts.
215
94
 
216
95
  ## Environment variables
217
96
 
218
- | Variable | Required | Purpose |
219
- |----------|----------|---------|
220
- | `DEXE_PROTOCOL_PATH` | no | Use an existing DeXe-Protocol checkout; disables auto clone/install |
221
- | `DEXE_RPC_URL` | no | JSON-RPC endpoint for `dexe_decode_proposal` and `dexe_read_gov_state` |
222
- | `DEXE_FORK_BLOCK` | no | Pin the fork to a specific block (Phase B) |
223
-
224
- ## Troubleshooting
225
-
226
- ### "`git` is not on PATH"
227
-
228
- Install git from <https://git-scm.com/downloads> and restart your MCP client. Alternatively, clone DeXe-Protocol manually and set `DEXE_PROTOCOL_PATH` to skip the clone step entirely.
229
-
230
- ### "`npm install` failed inside DeXe-Protocol"
231
-
232
- Usually means your Node install lacks a bundled `npm` (e.g. a stripped `node.exe` dropped on PATH without the rest of the install). Reinstall Node from <https://nodejs.org> or via nvm / nvm-windows and retry. dexe-mcp invokes npm via `process.execPath` so it uses whichever Node is running it — it does not need `npm` on the spawn PATH.
233
-
234
- ### "Failed to connect" in Claude Code (Windows)
235
-
236
- Run the direct stdio test from the "Verify the install" section first. If that prints a clean `serverInfo` response, the server is fine and the problem is in how your client is spawning it.
237
-
238
- The fix is almost always to switch to the **absolute-path** registration:
97
+ All optional. Tools that need a missing variable fail with a clear message pointing at exactly what to set. Full matrix + per-tool requirements → [`docs/ENVIRONMENT.md`](./docs/ENVIRONMENT.md).
98
+
99
+ | Variable | Required for | Purpose |
100
+ |----------|--------------|---------|
101
+ | `DEXE_PROTOCOL_PATH` | dev tooling (optional) | Use an existing DeXe-Protocol checkout; disables auto clone/install |
102
+ | `DEXE_RPC_URL` | reads / predict / deploy | JSON-RPC endpoint (BSC or any EVM chain where DeXe is deployed) |
103
+ | `DEXE_CHAIN_ID` | reads | Defaults to `56` (BSC mainnet). Override for other chains |
104
+ | `DEXE_CONTRACTS_REGISTRY` | reads (optional) | Override the ContractsRegistry root; defaults to the known per-chain address |
105
+ | `DEXE_PINATA_JWT` | IPFS uploads | Pinata JWT for pinning proposal/DAO metadata |
106
+ | `DEXE_IPFS_GATEWAY` | IPFS fetch | **Dedicated** gateway URL (Pinata provides one alongside your JWT; Filebase / Quicknode / self-hosted also work). Public gateways are unreliable and NOT defaulted |
107
+ | `DEXE_IPFS_GATEWAYS_FALLBACK` | IPFS fetch (optional) | Comma-separated public gateways tried sequentially after the primary |
108
+ | `DEXE_SUBGRAPH_INTERACTIONS_URL` | `dexe_proposal_voters` | The Graph endpoint for the DeXe interactions subgraph |
109
+ | `DEXE_SUBGRAPH_POOLS_URL`, `DEXE_SUBGRAPH_VALIDATORS_URL` | reserved | Additional subgraph endpoints for future tools |
110
+ | `DEXE_BACKEND_API_URL` | off-chain proposals | DeXe backend (e.g. `https://api.dexe.io`) |
111
+
112
+ ## Documentation
113
+
114
+ Full docs in [`docs/`](./docs):
115
+
116
+ - [`docs/TOOLS.md`](./docs/TOOLS.md) — complete catalog of all 111 tools, organized by category, with one-line descriptions and required envs per tool.
117
+ - [`docs/USAGE.md`](./docs/USAGE.md) 10 worked examples (deploy DAO, create proposals, vote, delegate, validator chamber, decode calldata, off-chain proposals, multicall batching). Copy-pasteable JSON.
118
+ - [`docs/ENVIRONMENT.md`](./docs/ENVIRONMENT.md) — full env-var reference: minimum block to get started, per-category requirements, calldata vs signer mode, chain-specific config, IPFS gateway rationale, subgraph migration, swarm harness envs, common pitfalls.
119
+
120
+ ## Tool surface (high-level)
121
+
122
+ | Group | Tools | What |
123
+ |-------|-------|------|
124
+ | Dev tooling | 4 | Hardhat wrappers: `dexe_compile`, `_test`, `_coverage`, `_lint` |
125
+ | Contract introspection | 10 | `_list_contracts`, `_get_abi`, `_get_methods`, `_get_selectors`, `_find_selector`, `_get_natspec`, `_get_source`, `_decode_calldata`, `_decode_proposal`, `_list_gov_contract_types` |
126
+ | DAO reads | 25 | `_dao_info`, `_dao_predict_addresses`, `_dao_registry_lookup`, `_proposal_state/_list/_voters`, `_vote_user_power/_get_votes`, `_read_*` family |
127
+ | IPFS | 6 | Pinata uploads, gateway fetch, CID computation |
128
+ | DAO deploy | 1 | `dexe_dao_build_deploy` (encodes `PoolFactory.deployGovPool` with full nested struct + predicted addr wiring) |
129
+ | Proposal catalog + primitives | 5 | `dexe_proposal_catalog` enumerates **all 33** types; primitives: `_build_external`, `_build_internal`, `_build_custom_abi`, `_build_offchain` |
130
+ | External proposal wrappers | 18 | Token transfer / distribution / sale, treasury withdraw, validators, experts, staking tier, math model, blacklist, reward multiplier, apply to DAO, modify profile, change voting settings, new proposal type, etc. |
131
+ | Internal validator wrappers | 4 | `_change_validator_balances`, `_change_validator_settings`, `_monthly_withdraw`, `_offchain_internal_proposal` |
132
+ | Off-chain backend | 8 | `_offchain_single_option/_multi_option/_for_against/_settings`, auth flow (`_auth_request_nonce`, `_auth_login_request`), `_offchain_build_vote/_cancel_vote` |
133
+ | Vote / stake / delegate / execute / claim | 16 | `_vote_build_*` family — every direct EOA write on GovPool / Validators |
134
+ | Composite signing flows | 4 | `_proposal_create`, `_proposal_vote_and_execute`, `_tx_send`, `_tx_status` (all opt-in via `DEXE_PRIVATE_KEY`) |
135
+ | Subgraph reads | 6 | DAO list, members, experts, user activity, delegation map, distribution status (decentralized network endpoints) |
136
+
137
+ Total: **~111**. Per-tool descriptions, args, return shapes → [`docs/TOOLS.md`](./docs/TOOLS.md).
138
+
139
+ ## Swarm test harness
140
+
141
+ `tests/swarm/` is a multi-agent DAO testing harness that exercises every dexe-mcp
142
+ tool against real BSC-testnet DAOs. Scenarios are JSON specs; the orchestrator
143
+ loads them, resolves agent wallets, and runs each step through either an inline
144
+ ethers dispatcher or the dexe-mcp stdio bridge.
145
+
146
+ **41 scenarios shipped** covering:
147
+
148
+ - Reset + delegation chains (S00, S01, S06, S14)
149
+ - Validator chamber pass / veto / full lifecycle (S02, S03, S07)
150
+ - Read-only snapshots: expert state, participation, validators, cross-DAO,
151
+ catalog, multi-proposal state, user activity (S04, S05, S09, S10, S11, S13, S15)
152
+ - Cancel-vote, decode-and-introspect (S08, S12)
153
+ - Build-only sanity for every proposal type in `dexe_proposal_catalog`
154
+ (token transfer, blacklist, withdraw treasury, apply to dao, token
155
+ distribution, token sale + recover, manage validators, change validator
156
+ balances/settings, monthly withdraw, add/remove expert (local + global),
157
+ delegate/revoke from expert, reward multiplier (4 modes), change voting
158
+ settings, new proposal type, change math model, custom ABI, manual calldata,
159
+ create staking tier, off-chain validator + for/against + settings) (S16–S40)
239
160
 
240
161
  ```bash
241
- claude mcp remove dexe
242
- claude mcp add dexe -- "C:\Program Files\nodejs\node.exe" "C:\Users\<you>\AppData\Roaming\nvm\<version>\node_modules\dexe-mcp\dist\index.js"
162
+ # 1) generate 9 wallets (8 agents + funder), fund the funder from your wallet
163
+ # 2) deploy fixture DAOs via dexe_dao_build_deploy (one 50% quorum + one with validators)
164
+ # 3) configure SWARM_DAOS_TESTNET / SWARM_TOKENS_TESTNET / SWARM_RPC_URL_TESTNET
165
+ npm run swarm:preflight # red/green table per wallet
166
+ npm run swarm:fund -- --confirm # broadcast top-ups from funder
167
+ npm run swarm:run # full sweep, all scenarios
168
+ npm run swarm:run -- --scenarios=S00-reset,S01-delegation-chain-3hop --dry-run
243
169
  ```
244
170
 
245
- Bare `dexe-mcp` and `cmd /c dexe-mcp` both rely on shim resolution that Claude Code's `CreateProcess`-based spawn does not always handle. The absolute-path form has zero shim resolution.
246
-
247
- ### `npm install -g dexe-mcp` reported success but `dexe-mcp` is nowhere to be found
248
-
249
- You're almost certainly on a stripped Node install whose `npm` silently no-ops. Check with `npm --version` — if it fails, install Node properly (see Prerequisites). If it prints a version, check `npm root -g` and look inside that directory; the package should be at `<npm-root>/dexe-mcp`.
250
-
251
- ### "Hardhat artifacts not found — run dexe_compile first"
252
-
253
- Introspection tools require compiled artifacts. Run `dexe_compile` once after the initial setup to populate them.
254
-
255
- ### "DEXE_PROTOCOL_PATH=… is missing node_modules"
256
-
257
- You pointed `DEXE_PROTOCOL_PATH` at a checkout that hasn't been installed yet. `cd` into it and run `npm install` once, then retry.
258
-
259
- ### "DEXE_RPC_URL is not set"
260
-
261
- The governance tools `dexe_decode_proposal` and `dexe_read_gov_state` require an Ethereum JSON-RPC endpoint. Add `DEXE_RPC_URL` to your MCP env config.
171
+ Setup runbook: [`tests/swarm/README.md`](tests/swarm/README.md).
172
+ Scenario schema: [`tests/swarm/scenarios/_schema.md`](tests/swarm/scenarios/_schema.md).
173
+ Per-role agent prompts: `tests/swarm/prompts/`.
262
174
 
263
175
  ## Contributing
264
176
 
@@ -271,10 +183,6 @@ npm run typecheck
271
183
  npm run dev # watch mode
272
184
  ```
273
185
 
274
- ## Roadmap
275
-
276
- Phase B (`dexe_simulate_vote` + Hardhat fork management) is planned for v0.2.0. See [FUTURE.md](./FUTURE.md) for all deferred features.
277
-
278
186
  ## License
279
187
 
280
188
  MIT. See [LICENSE](./LICENSE).
package/dist/config.d.ts CHANGED
@@ -3,8 +3,20 @@ export interface DexeConfig {
3
3
  protocolPath: string;
4
4
  /** Optional JSON-RPC endpoint for on-chain gov tools. */
5
5
  rpcUrl?: string;
6
+ /** Chain id the RPC points at. Defaults to 56 (BSC mainnet, DeXe home). */
7
+ chainId: number;
8
+ /** Override for `ContractsRegistry` root address. */
9
+ registryOverride?: string;
10
+ /** Pinata JWT for IPFS uploads (reads work without it via gateway). */
11
+ pinataJwt?: string;
12
+ /** GraphQL endpoint URLs for The Graph subgraphs. */
13
+ subgraphPoolsUrl?: string;
14
+ subgraphValidatorsUrl?: string;
15
+ subgraphInteractionsUrl?: string;
6
16
  /** Optional fork block pin (Phase B). */
7
17
  forkBlock?: number;
18
+ /** Private key for tx signing. When set, `dexe_tx_send` can broadcast. */
19
+ privateKey?: string;
8
20
  }
9
21
  /**
10
22
  * Reads environment and returns a frozen config. **Fast and side-effect-free**
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACzB,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,CA4BtD"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACzB,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,CAgEtD"}
package/dist/config.js CHANGED
@@ -19,6 +19,28 @@ export async function loadConfig() {
19
19
  process.stderr.write(`[dexe-mcp] DeXe-Protocol checkout at ${protocolPath} is incomplete (missing node_modules or hardhat.config) — will be prepared on first dexe_compile call.\n`);
20
20
  }
21
21
  const rpcUrl = process.env.DEXE_RPC_URL?.trim() || undefined;
22
+ let chainId = 56;
23
+ if (process.env.DEXE_CHAIN_ID) {
24
+ const n = Number(process.env.DEXE_CHAIN_ID);
25
+ if (!Number.isFinite(n) || n <= 0) {
26
+ fatal(`DEXE_CHAIN_ID must be a positive integer, got: ${process.env.DEXE_CHAIN_ID}`);
27
+ }
28
+ chainId = n;
29
+ }
30
+ const registryOverride = process.env.DEXE_CONTRACTS_REGISTRY?.trim() || undefined;
31
+ const pinataJwt = process.env.DEXE_PINATA_JWT?.trim() || undefined;
32
+ const subgraphPoolsUrl = process.env.DEXE_SUBGRAPH_POOLS_URL?.trim() || undefined;
33
+ const subgraphValidatorsUrl = process.env.DEXE_SUBGRAPH_VALIDATORS_URL?.trim() || undefined;
34
+ const subgraphInteractionsUrl = process.env.DEXE_SUBGRAPH_INTERACTIONS_URL?.trim() || undefined;
35
+ const privateKey = process.env.DEXE_PRIVATE_KEY?.trim() || undefined;
36
+ if (privateKey && !rpcUrl) {
37
+ fatal("DEXE_PRIVATE_KEY requires DEXE_RPC_URL to be set (signing needs an RPC endpoint).");
38
+ }
39
+ if (privateKey) {
40
+ const { Wallet } = await import("ethers");
41
+ const addr = new Wallet(privateKey).address;
42
+ process.stderr.write(`[dexe-mcp] signing enabled for ${addr}\n`);
43
+ }
22
44
  let forkBlock;
23
45
  if (process.env.DEXE_FORK_BLOCK) {
24
46
  const n = Number(process.env.DEXE_FORK_BLOCK);
@@ -27,7 +49,18 @@ export async function loadConfig() {
27
49
  }
28
50
  forkBlock = n;
29
51
  }
30
- return Object.freeze({ protocolPath, rpcUrl, forkBlock });
52
+ return Object.freeze({
53
+ protocolPath,
54
+ rpcUrl,
55
+ chainId,
56
+ registryOverride,
57
+ pinataJwt,
58
+ subgraphPoolsUrl,
59
+ subgraphValidatorsUrl,
60
+ subgraphInteractionsUrl,
61
+ forkBlock,
62
+ privateKey,
63
+ });
31
64
  }
32
65
  function fatal(msg) {
33
66
  // stderr only — stdout is the MCP protocol channel.