agentic-wallet-mcp 0.1.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 +165 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Zetrix Agentic Wallet MCP
|
|
2
|
+
|
|
3
|
+
An agent-facing **MCP server** that gives an AI agent a Zetrix wallet: it **proves identity**
|
|
4
|
+
(x401), **pays** (x402), and **obtains verifiable credentials** (via the MBI issuer) — by
|
|
5
|
+
orchestrating existing SDKs/MCPs. It is a thin composer: all heavy crypto and payment logic
|
|
6
|
+
lives in the imported libraries.
|
|
7
|
+
|
|
8
|
+
- **x401** proof → [`x401-zetrix-client`](https://www.npmjs.com/package/x401-zetrix-client) (npm)
|
|
9
|
+
- **x402** payment → [`x402-zetrix-client`](https://www.npmjs.com/package/x402-zetrix-client) (npm)
|
|
10
|
+
- **VC presentation** (BBS+ VP derivation) → MBI RS (`/v1/vp/ext/create` + `/v1/vp/ext/submit`, `includeVp: true` — BT-2357)
|
|
11
|
+
- **issuer key resolution** (for the OID4VP submit body) → the Zetrix ZID resolver (`https://zid-resolver[-sandbox].zetrix.com`)
|
|
12
|
+
- **holder key custody + signing** → Wallet BE softHSM (`/wallet/hsm/*`)
|
|
13
|
+
- **VC issuance** → MBI RS (`/v1/vc/pay/*`)
|
|
14
|
+
|
|
15
|
+
See [`docs/INTEGRATION_GUIDE.md`](docs/INTEGRATION_GUIDE.md) for the full config reference, tool
|
|
16
|
+
contracts, a live-verified usage flow, and a troubleshooting table for real-infra errors.
|
|
17
|
+
[`docs/CONTRACT_RECONCILIATION.md`](docs/CONTRACT_RECONCILIATION.md) has the authoritative
|
|
18
|
+
endpoint/contract map, [`docs/DEVELOPMENT_CHECKLIST.md`](docs/DEVELOPMENT_CHECKLIST.md) has status,
|
|
19
|
+
and [`docs/USAGE_FLOW.md`](docs/USAGE_FLOW.md) has a full end-to-end prompt script (onboarding →
|
|
20
|
+
VC issuance → identity proof → pay-per-use).
|
|
21
|
+
|
|
22
|
+
## Tools
|
|
23
|
+
|
|
24
|
+
| Tool | Does | Input |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| `wallet_status` | Report holder DID/address/network + client-supplied held VCs | `{ heldCredentials? }` |
|
|
27
|
+
| `prove_identity` | Answer an x401 `PROOF-REQUEST` → return the `PROOF-RESPONSE` header to replay | `{ proofRequest, vc, revealAttribute?, issuerKeys? }` |
|
|
28
|
+
| `pay_and_fetch` | Fetch a URL, auto-pay with x402 (self-pay via Wallet BE) on `402` | `{ url, method?, headers?, body? }` |
|
|
29
|
+
| `subscribe_and_issue` | Build the signed payload → pay x402 → MBI issues → return the VC | `{ templateId, attributes, expirationDate? }` |
|
|
30
|
+
| `create_holder_account` | Onboarding: create a new HSM account if `HOLDER_ADDRESS` isn't provisioned yet | `{ password, label?, purpose? }` |
|
|
31
|
+
|
|
32
|
+
> The wallet **never persists VCs** — the client holds them and passes them in (e.g. `vc` on
|
|
33
|
+
> `prove_identity`, `heldCredentials` on `wallet_status`). All Ed25519 signing goes through
|
|
34
|
+
> Wallet BE HSM; no plaintext private keys.
|
|
35
|
+
|
|
36
|
+
> `create_holder_account` mints a **brand-new** keypair — Wallet BE's `/account/create` has no
|
|
37
|
+
> way to provision a pre-chosen address. It returns the new `zetrixAddress`/`holderDid` for you
|
|
38
|
+
> to paste into `HOLDER_ADDRESS`/`HOLDER_DID`/`HSM_PASSWORD` yourself; the tool never writes your
|
|
39
|
+
> MCP config or restarts the server for you.
|
|
40
|
+
|
|
41
|
+
> `prove_identity` no longer takes a `bbsPublicKey` input at all. The OID4VP verifier
|
|
42
|
+
> (`openid4vp-verifier-be`) checks each VC's own issuer-signed proof(s) against the
|
|
43
|
+
> `bbs_public_key`/`ed25519_public_key` it's sent — and its own DID-resolution fallback isn't
|
|
44
|
+
> implemented server-side, so it needs the real issuer keys, not a holder key. The wallet now
|
|
45
|
+
> resolves them itself: it reads the VC's `issuer` DID and each `proof[].verificationMethod`,
|
|
46
|
+
> resolves the issuer's DID document via the Zetrix ZID resolver, and matches the BBS+
|
|
47
|
+
> (`publicKeyMultibase`) and Ed25519 (`publicKeyHex`) verification methods referenced by the VC's
|
|
48
|
+
> own proofs. See `docs/CONTRACT_RECONCILIATION.md §8` for the full trace through the verifier's
|
|
49
|
+
> source that led to this.
|
|
50
|
+
|
|
51
|
+
## Install & build
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install
|
|
55
|
+
npm test # 85 tests
|
|
56
|
+
npm run build # tsc + esbuild → dist/server-bundle.cjs (the bin)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Node ≥ 18 (built-in `fetch`). `x401-zetrix-client` is consumed as a normal npm dependency; the
|
|
60
|
+
`bin` runs the **esbuild bundle** (`dist/server-bundle.cjs`), which inlines it.
|
|
61
|
+
|
|
62
|
+
## Environment
|
|
63
|
+
|
|
64
|
+
| Variable | Required | Description |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `ZETRIX_NETWORK` | yes | `zetrix:testnet` or `zetrix:mainnet` — also selects the default `WALLET_BE_URL`/`MBI_BASE_URL`/`OID4VP_BASE_URL` below |
|
|
67
|
+
| `HOLDER_ADDRESS` | yes | Holder Zetrix address (the HSM account) |
|
|
68
|
+
| `HOLDER_DID` | yes | Holder DID |
|
|
69
|
+
| `HSM_PASSWORD` | no* | HSM password (may instead be supplied per tool-call) |
|
|
70
|
+
| `WALLET_BE_URL` | no | Wallet BE base URL override (HSM `/wallet/hsm/sign-blob`) — auto-derived from `ZETRIX_NETWORK` when not set |
|
|
71
|
+
| `MBI_BASE_URL` | no | MBI RS base URL override (`/v1/vc/pay/apply`) — auto-derived from `ZETRIX_NETWORK` when not set |
|
|
72
|
+
| `OID4VP_BASE_URL` | no | OID4VP verifier base URL override — auto-derived from `ZETRIX_NETWORK` by the x401 SDK when not set (BT-2368) |
|
|
73
|
+
| `ZETRIX_NODE_HOST` / `ZETRIX_NODE_PORT` | no | RPC node override (auto-derived from network) |
|
|
74
|
+
| `ZID_RESOLVER_BASE_URL` | no | ZID resolver override (auto-derived from network: sandbox for testnet, prod for mainnet) |
|
|
75
|
+
| `MAX_PAYMENT_AMOUNT` | no** | Per-asset x402 auto-pay cap — JSON `{ "<asset>": "<maxRawUnits>", "*": "<fallback>" }`, e.g. `{"ZTX":"1000000000","*":"0"}`. Unset = no cap enforced. |
|
|
76
|
+
|
|
77
|
+
\* sensitive — never logged.
|
|
78
|
+
|
|
79
|
+
\*\* **strongly recommended before pointing this wallet at mainnet/real funds.** `pay_and_fetch`
|
|
80
|
+
and `subscribe_and_issue` auto-pay whatever `maxAmountRequired` a remote server's 402 challenge
|
|
81
|
+
demands, with no built-in ceiling — a prompt-injected or misled agent calling either tool against
|
|
82
|
+
a hostile endpoint would pay whatever that endpoint asks for, bounded only by the HSM account
|
|
83
|
+
balance. `MAX_PAYMENT_AMOUNT` is a hard, code-enforced cap that holds regardless of what the
|
|
84
|
+
calling agent decides. Once set, it becomes an allowlist: an asset with no entry and no `"*"`
|
|
85
|
+
fallback is **denied**, not passed through uncapped.
|
|
86
|
+
|
|
87
|
+
You don't need to look up or fill in `WALLET_BE_URL`/`MBI_BASE_URL`/`OID4VP_BASE_URL` yourself —
|
|
88
|
+
just pick `zetrix:testnet` or `zetrix:mainnet` for `ZETRIX_NETWORK` and the MCP (and the x401 SDK
|
|
89
|
+
it wires up) uses the built-in default for that network:
|
|
90
|
+
|
|
91
|
+
| Network | `WALLET_BE_URL` default | `MBI_BASE_URL` default | `OID4VP_BASE_URL` default |
|
|
92
|
+
|---|---|---|---|
|
|
93
|
+
| `zetrix:testnet` | `https://wallet-api.myegdev.com/server` | `https://mbi-vc.myegdev.com` | `https://zid-oid4vp-sandbox.zetrix.com/api` |
|
|
94
|
+
| `zetrix:mainnet` | `https://wallet-api.zetrix.com/server` | `https://mbi-vc.zetrix.com` | `https://zid-oid4vp.zetrix.com/api` |
|
|
95
|
+
|
|
96
|
+
Only set `WALLET_BE_URL`/`MBI_BASE_URL`/`OID4VP_BASE_URL` explicitly if you run your own instance
|
|
97
|
+
of that service instead of the default one — an explicit value always wins over the network
|
|
98
|
+
default.
|
|
99
|
+
|
|
100
|
+
That's the complete list — no VC-MCP subprocess, no BaaS gateway key, no manually-configured
|
|
101
|
+
BBS+ key to set up (BT-2357 replaced that whole path — see `docs/CONTRACT_RECONCILIATION.md §8`).
|
|
102
|
+
|
|
103
|
+
## Configuring in Claude Desktop / Claude Code
|
|
104
|
+
|
|
105
|
+
> **Deployment model: single-holder, config-based.** One MCP instance serves one holder;
|
|
106
|
+
> all setup (infra URLs, holder identity, `HSM_PASSWORD`, VC-backend key) is set once in the
|
|
107
|
+
> `env` block below. Per-transaction data (the VC to present, attributes to request) is passed
|
|
108
|
+
> by the agent at call time. (Multi-user — passing secrets/identity per tool-call — is a future
|
|
109
|
+
> option, not built.)
|
|
110
|
+
|
|
111
|
+
A ready-to-edit template lives at [`mcp.json`](mcp.json) — copy it into your client config and fill
|
|
112
|
+
the `<...>` placeholders (don't commit a filled copy; `mcp.local.json` is gitignored). Add to
|
|
113
|
+
`claude_desktop_config.json` (Desktop) or `~/.claude/settings.json` (Code):
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"mcpServers": {
|
|
118
|
+
"agentic-wallet": {
|
|
119
|
+
"command": "node",
|
|
120
|
+
"args": ["/absolute/path/to/zetrix-agentic-wallet/dist/server-bundle.cjs"],
|
|
121
|
+
"env": {
|
|
122
|
+
"ZETRIX_NETWORK": "zetrix:testnet",
|
|
123
|
+
"HOLDER_ADDRESS": "ZTX3...",
|
|
124
|
+
"HOLDER_DID": "did:zid:...",
|
|
125
|
+
"HSM_PASSWORD": "your-hsm-password"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
> Prefer environment/secret managers over inline secrets for `HSM_PASSWORD` in production.
|
|
133
|
+
>
|
|
134
|
+
> Only add `WALLET_BE_URL` / `MBI_BASE_URL` / `OID4VP_BASE_URL` to the `env` block if you run your
|
|
135
|
+
> own instance of that service — otherwise leave them out and the MCP (and the x401 SDK) use the
|
|
136
|
+
> default for whichever `ZETRIX_NETWORK` you picked (see the table above).
|
|
137
|
+
|
|
138
|
+
## Example prompts
|
|
139
|
+
|
|
140
|
+
- *"Check my wallet status."* → `wallet_status`
|
|
141
|
+
- *"I got a 401 with this PROOF-REQUEST header — prove my identity and give me the PROOF-RESPONSE to replay."* → `prove_identity`
|
|
142
|
+
- *"Fetch `https://api.example/data` and pay automatically if it asks."* → `pay_and_fetch`
|
|
143
|
+
- *"Apply for the agent-identity credential with these attributes and pay for it."* → `subscribe_and_issue`
|
|
144
|
+
- *"My wallet_status call is failing — I don't have a holder account yet. Set one up."* → `create_holder_account` (asks you for a password, then returns the new address/DID to save)
|
|
145
|
+
|
|
146
|
+
For the full ordered script (onboarding → check → issue → prove → pay), see [`docs/USAGE_FLOW.md`](docs/USAGE_FLOW.md).
|
|
147
|
+
|
|
148
|
+
## Status
|
|
149
|
+
|
|
150
|
+
Milestone 2 (WBS 4.1–4.5) is code-complete **and live-verified end-to-end against the real
|
|
151
|
+
sandbox** — not just unit-tested. `subscribe_and_issue` issued a real VC and settled a real
|
|
152
|
+
payment; `prove_identity` got a real OID4VP verifier to return `VERIFIED`; `pay_and_fetch`
|
|
153
|
+
completed a real x402 payment against `ms-zetrix` (via `ms-public-proxy`) and got real chain data
|
|
154
|
+
back. This closed out the remaining G-checks from `docs/CONTRACT_RECONCILIATION.md §7`: the
|
|
155
|
+
OID4VP `ResponseWrapper`/wallet-auth submit contract (G6), the MBI `data` hex form (G3), and the
|
|
156
|
+
DCQL→`revealAttribute` mapping (G4, now VC-aware — resolves DCQL claim paths against the
|
|
157
|
+
presented VC's actual nested structure). See
|
|
158
|
+
[`docs/INTEGRATION_GUIDE.md`](docs/INTEGRATION_GUIDE.md) — its "Live verification record" section
|
|
159
|
+
has the exact evidence (VC ids, tx hashes, presentation ids), and its "Network reachability &
|
|
160
|
+
troubleshooting" section covers every real-infra error hit along the way and its fix.
|
|
161
|
+
|
|
162
|
+
One known item remains open, tracked as a follow-up (not a blocker): `verifiedClaims` came back
|
|
163
|
+
empty on a `VERIFIED` proof (likely a verifier echo behavior, not a wallet bug). Also unconfirmed:
|
|
164
|
+
Wallet BE's `/account/create` `publicKeyHex` format (raw vs Zetrix `b001…`-encoded —
|
|
165
|
+
`deriveHolderDid` handles both, but only one is real).
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agentic-wallet-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Agent-facing MCP wallet for Zetrix — orchestrates x401 identity proof, x402 payment, and MBI VC issuance",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"agentic-wallet-mcp": "dist/server-bundle.cjs"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc && esbuild src/index.ts --bundle --platform=node --target=node18 --format=cjs --external:zetrix-sdk-nodejs --outfile=dist/server-bundle.cjs",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
25
|
+
"x401-zetrix-client": "^0.2.1",
|
|
26
|
+
"x402-zetrix-client": "^0.2.2"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"esbuild": "^0.24.0",
|
|
31
|
+
"typescript": "^5.9.0",
|
|
32
|
+
"vitest": "^1.6.0"
|
|
33
|
+
}
|
|
34
|
+
}
|