@odatano/nightgate-mcp 0.8.0 → 0.9.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/CHANGELOG.md +36 -2
- package/README.md +114 -218
- package/dist/builder.d.ts +3 -0
- package/dist/builder.js +9 -3
- package/dist/builder.js.map +1 -1
- package/dist/config.d.ts +5 -1
- package/dist/config.js +8 -2
- package/dist/config.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/swap.d.ts +76 -0
- package/dist/swap.js +244 -0
- package/dist/swap.js.map +1 -0
- package/dist/tools.js +174 -7
- package/dist/tools.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,11 +3,45 @@
|
|
|
3
3
|
All notable changes to `@odatano/nightgate-mcp` are documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
-
The
|
|
7
|
-
version needs.
|
|
6
|
+
The README says which NIGHTGATE the current version needs.
|
|
8
7
|
|
|
9
8
|
## [Unreleased]
|
|
10
9
|
|
|
10
|
+
## [0.9.0] - 2026-09-30
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Shielded swap tools** (NIGHTGATE 0.29.0, `@odatano/nightgate-tx` 0.8.0):
|
|
15
|
+
- `get_swap_wallet`: address, public keys, per token type balance, free coins and
|
|
16
|
+
`spendable`; halves built here that have not landed.
|
|
17
|
+
- `read_swap_offer`: `gives`, `wants`, `inputs`, `outputs`, `bound` of an offer file or
|
|
18
|
+
base64 half, read from the transaction.
|
|
19
|
+
- `build_swap_offer(give, want, bind?)`: one proven half, as offer file (`swapoffer1...`).
|
|
20
|
+
- `take_swap_offer(offer, expect?, sponsorSessionId?, idempotencyKey?)`: the mirror half;
|
|
21
|
+
with a sponsor session it submits both halves. A refusal carries `halfId`.
|
|
22
|
+
- `sponsor_swap(makerHalf, takerHalf | halfId, sponsorSessionId, idempotencyKey?)`.
|
|
23
|
+
- `revert_swap_offer(id)`: releases the coins of a half built here.
|
|
24
|
+
- `NIGHTGATE_SWAP_STATE_FILE`, `NIGHTGATE_SWAP_MAX_INPUTS`.
|
|
25
|
+
- `get_attester_identity` returns `shieldedAddress`, `coinPublicKey`, `encryptionPublicKey`.
|
|
26
|
+
- `npm run integration` covers the swap tools (`scripts/integration-swap.mjs`).
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Peer dependency `@odatano/nightgate-tx` `>=0.8.0` (was `>=0.6.0`).
|
|
31
|
+
- Lockfile: one `@midnight-ntwrk/ledger-v8` (8.1.0) in the tree. Two copies made the local
|
|
32
|
+
builder fail with `expected instance of DustParameters`.
|
|
33
|
+
- `live:sponsor-unbound` verifies with the attester id.
|
|
34
|
+
- `NIGHTGATE_SEED_HEX` is 128 hex (a 64-byte BIP39 seed); 64 hex is refused at startup.
|
|
35
|
+
- `get_job_status` describes the `swap` result of a swap job.
|
|
36
|
+
|
|
37
|
+
## [0.8.1] - 2026-09-27
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- `get_job_status` describes `chainSegments` (NIGHTGATE 0.28.0): for a confirmed batch,
|
|
42
|
+
which calls applied. Tool errors carry the server's string `code` (`INVALID_ARGUMENT`, ...).
|
|
43
|
+
- README reorganized; compatibility names the current version only.
|
|
44
|
+
|
|
11
45
|
## [0.8.0] - 2026-09-23
|
|
12
46
|
|
|
13
47
|
### Added
|
package/README.md
CHANGED
|
@@ -8,248 +8,144 @@
|
|
|
8
8
|
# @odatano/nightgate-mcp
|
|
9
9
|
|
|
10
10
|
[](https://www.npmjs.com/package/@odatano/nightgate-mcp)
|
|
11
|
-
[](https://www.npmjs.com/package/@odatano/nightgate)
|
|
11
|
+
[](https://www.npmjs.com/package/@odatano/nightgate)
|
|
13
12
|
[](https://modelcontextprotocol.io/)
|
|
14
|
-
[](https://nodejs.org/)
|
|
15
13
|
[](LICENSE)
|
|
16
14
|
|
|
17
|
-
MCP server
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
```json
|
|
39
|
-
{
|
|
40
|
-
"mcpServers": {
|
|
41
|
-
"nightgate": {
|
|
42
|
-
"command": "npx",
|
|
43
|
-
"args": ["-y", "@odatano/nightgate-mcp"],
|
|
44
|
-
"env": { "ODATANO_ACCESS_KEY": "oda_..." }
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
or, with Claude Code: `claude mcp add nightgate --env ODATANO_ACCESS_KEY=oda_... -- npx -y @odatano/nightgate-mcp`
|
|
51
|
-
|
|
52
|
-
3. That is all: the gateway is the default URL. It sends the key as
|
|
53
|
-
`Authorization: Bearer`, swaps in the NIGHTGATE agent grant underneath
|
|
54
|
-
(sponsored writes on the platform pool included) and meters the key per
|
|
55
|
-
call; the verify lane and the prover keys under `/zk-config` are free.
|
|
56
|
-
The hosted NIGHTGATE runs on Midnight **preprod** today.
|
|
57
|
-
|
|
58
|
-
What the gateway does not offer, the key cannot reach: agent grants, wallet
|
|
59
|
-
sessions, contract deployment, dust registration and the sponsor pool status
|
|
60
|
-
answer 403 there; this server never calls them. A 402 from the gateway
|
|
61
|
-
(units exhausted) reaches the agent with the top-up hint.
|
|
62
|
-
|
|
63
|
-
## Requirements
|
|
64
|
-
|
|
65
|
-
- Node.js >= 20 (`npx` fetches the server, nothing to install)
|
|
66
|
-
- For `build_sponsorable_transaction`: `@odatano/nightgate-tx` installed next
|
|
67
|
-
to the server and `NIGHTGATE_SEED_HEX` set (see the sponsoring section)
|
|
68
|
-
|
|
69
|
-
## Writing on-chain: fee sponsoring
|
|
70
|
-
|
|
71
|
-
An agent does not need a wallet session of its own to write on-chain. Through
|
|
72
|
-
the gateway the key already carries a grant for `sponsorUnboundTransaction`
|
|
73
|
-
and `sponsorFinalizedTransaction` on the platform sponsor pool; against a
|
|
74
|
-
direct instance the grant is the `ngat_…` token. The flow is:
|
|
75
|
-
|
|
76
|
-
1. `build_sponsorable_transaction`: build, prove and sign the contract call
|
|
77
|
-
LOCALLY (the MCP server wraps the
|
|
78
|
-
[`@odatano/nightgate-tx`](https://www.npmjs.com/package/@odatano/nightgate-tx)
|
|
79
|
-
txbuilder; install it next to the MCP server, it is an optional peer
|
|
80
|
-
dependency because it carries the Midnight SDK). The seed comes from
|
|
81
|
-
`NIGHTGATE_SEED_HEX` in the server environment, the attestation secret is
|
|
82
|
-
derived from it, nothing secret leaves the machine; the result is ~7 KB of
|
|
83
|
-
base64 and the effect will carry this builder's attester id
|
|
84
|
-
(`get_attester_identity`). Proving runs in-process (20-60 s) or on a proof
|
|
85
|
-
server (`NIGHTGATE_PROOF_SERVER_URL`). Without the package or the seed the
|
|
86
|
-
tool answers with a clear error; an agent can still hand in bytes built
|
|
87
|
-
elsewhere with the txbuilder directly.
|
|
88
|
-
2. `sponsor_unbound_transaction` with the operator's sponsor session id, or
|
|
89
|
-
the platform pool id `00000000-0000-0000-0000-706f6f6c0000` when the host
|
|
90
|
-
runs a sponsor pool (the server picks a free pool sponsor and fails over).
|
|
91
|
-
3. Poll `get_job_status` with the `sessionId` the sponsor call RETURNED, then
|
|
92
|
-
`verify_attestation` to read it back crawler-free.
|
|
93
|
-
|
|
94
|
-
One sponsor wallet serves several agents at once (parallel channel, 0.18.0).
|
|
95
|
-
A job that ends `failed` with `CHAIN_EXECUTION_FAILED` landed on-chain but its
|
|
96
|
-
call did not apply (two calls on the same contract in one block): build again
|
|
97
|
-
against the current state and sponsor again; never resubmit the same bytes.
|
|
98
|
-
On a direct host behind transport auth set `ODATANO_ACCESS_USER` /
|
|
99
|
-
`ODATANO_ACCESS_PASSWORD` next to the token, the two combine.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
## Run your own instance (optional)
|
|
103
|
-
|
|
104
|
-
Point `ODATANO_ACCESS_URL` at any NIGHTGATE host app instead of the gateway
|
|
105
|
-
(see the compatibility table below for the version pairing). The fastest way
|
|
106
|
-
is the official Docker image; no Node setup, no host app (published from the
|
|
107
|
-
NIGHTGATE repo on every release, details in its `docs/docker.md`):
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
docker run -d --name nightgate -p 4004:4004 \
|
|
111
|
-
-e ENCRYPTION_KEY=$(openssl rand -hex 32) \
|
|
112
|
-
-e NIGHTGATE_HTTP_PASSWORD=change-me \
|
|
113
|
-
-v nightgate-data:/data \
|
|
114
|
-
ghcr.io/odatano/nightgate:latest
|
|
15
|
+
MCP server for [NIGHTGATE](https://github.com/ODATANO/NIGHTGATE), the Midnight
|
|
16
|
+
attestation layer: anchor documents, prove zero-knowledge claims over hidden
|
|
17
|
+
fields, manage disclosure grants, verify against live contract state. Agents
|
|
18
|
+
write through fee sponsoring: they build and prove locally, a sponsor pays.
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
Get an `oda_…` key at [api.preprod.odatano.dev](https://api.preprod.odatano.dev)
|
|
23
|
+
(Cardano wallet sign-in, giveaway code, or tADA over x402), then:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"mcpServers": {
|
|
28
|
+
"nightgate": {
|
|
29
|
+
"command": "npx",
|
|
30
|
+
"args": ["-y", "@odatano/nightgate-mcp"],
|
|
31
|
+
"env": { "ODATANO_ACCESS_KEY": "oda_..." }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
115
35
|
```
|
|
116
36
|
|
|
117
|
-
|
|
118
|
-
auth (`nightgate` / your password), persists its database in the
|
|
119
|
-
`nightgate-data` volume, and proves in-process (wasm), so no proof server
|
|
120
|
-
is needed to start. Point this MCP server at it with:
|
|
37
|
+
Claude Code: `claude mcp add nightgate --env ODATANO_ACCESS_KEY=oda_... -- npx -y @odatano/nightgate-mcp`
|
|
121
38
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
ODATANO_ACCESS_USER=nightgate
|
|
125
|
-
ODATANO_ACCESS_PASSWORD=change-me
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
For agent operation, create a scoped grant once (as the operator, e.g. via
|
|
129
|
-
curl against `createAgentGrant`) and hand the returned `ngat_...` token to
|
|
130
|
-
the agent as `ODATANO_ACCESS_KEY`; the write tools are then limited to the
|
|
131
|
-
grant's allowlist, budget and pinned session. Any CAP app using the
|
|
132
|
-
`@odatano/nightgate` plugin works too, e.g. the NIGHTGATE repo itself via
|
|
133
|
-
`npm run dev`.
|
|
134
|
-
|
|
135
|
-
## Compatibility
|
|
39
|
+
The hosted gateway is the default (Midnight preprod). The same key works for
|
|
40
|
+
`@odatano/core-mcp` (Cardano). Node.js >= 20.
|
|
136
41
|
|
|
137
|
-
|
|
138
|
-
cosmetic: from NIGHTGATE 0.16.0 on, content-tree leaves are SALTED, so every
|
|
139
|
-
field proof must carry its slot salt. An older MCP omits it and the server
|
|
140
|
-
rejects the call with 400.
|
|
141
|
-
|
|
142
|
-
| MCP | NIGHTGATE | Notes |
|
|
143
|
-
|---|---|---|
|
|
144
|
-
| **0.8.0** | **>= 0.24.0** | Current. Analytics tools over ODATANO ASTRA (`analytics_*`), registered when the gateway serves it; same key, one unit per read. Same server range as 0.7.0. |
|
|
145
|
-
| 0.7.0 | >= 0.24.0 | One connection env for both ODATANO MCP servers: `ODATANO_ACCESS_URL`, `ODATANO_ACCESS_KEY`, `ODATANO_ACCESS_USER` / `ODATANO_ACCESS_PASSWORD` replace `NIGHTGATE_BASE_URL`, `NIGHTGATE_TOKEN`, `NIGHTGATE_USERNAME` and `NIGHTGATE_PASSWORD`. Gateway error bodies (401 / 402 / 403 / 429) pass through to the agent. Same server range as 0.6.0. |
|
|
146
|
-
| 0.6.0 | >= 0.24.0 | Vault lineage 4 keys every record by attester AND payload: `verify_attestation` takes `attesterId` + `payloadHash` (or a bound `documentId`), `verify_predicate` takes `attesterId`, the `prove_*` tools accept an optional `attesterId` (the record the claim is proven against), `anchor_document` is one plain attest and returns `attesterId`. `prepare_anchor_commitment` and `commit_document_anchor` are gone (nothing to guard: no identity can take over another attester's record). Local building needs `@odatano/nightgate-tx` >= 0.6.0; the proof calls take `recordKey` or `payloadHash` (+ `attesterId`). Against a 0.23.x server the verify calls fail with 400 (unknown parameter). |
|
|
147
|
-
| 0.5.1 | >= 0.19.0 for width 32 | Accepts the 32-slot vault: schema and opening take 16 or 32 entries, `allowedMask` up to 32 bits, `k` up to 32, and the vacuity guard is checked against the SCHEMA instead of a fixed all-ones constant. Target it with `compiledArtifactRef: 'attestation-vault-32'`. Everything else is unchanged, so a 16-slot setup keeps working against any 0.18.x server. |
|
|
148
|
-
| 0.5.x | >= 0.18.0 | Adds the parallel sponsoring channel (`sponsor_unbound_transaction`, platform pool id) and LOCAL transaction building (`build_sponsorable_transaction`, `get_attester_identity`) via the optional `@odatano/nightgate-tx` >= 0.2.0 txbuilder; `sponsor_unbound_transaction` 404s against older servers. |
|
|
149
|
-
| 0.4.x | >= 0.17.0 | Cross-server fee sponsoring, serial channel only (`sponsor_finalized_transaction`), custom-token identity (`derive_token_type`). |
|
|
150
|
-
| 0.3.x | >= 0.16.0 (0.16.2 recommended) | Cross-root proofs, guarded anchoring, schema ids, per-field salts. Does NOT work against 0.15.x and older, which know no salt parameters. |
|
|
151
|
-
| 0.2.x | 0.15.x | Bytes equality and set membership on unsalted leaves. Against 0.16.0 and newer every field proof fails with "fieldSalt is required". |
|
|
152
|
-
| 0.1.x | 0.14.x | Anchoring, numeric field predicates, disclosure, agent provenance. |
|
|
153
|
-
|
|
154
|
-
The verification tools are the exception: they only read live contract state
|
|
155
|
-
and keep working across the whole range, they simply cannot express the
|
|
156
|
-
newer claim kinds on an older server.
|
|
157
|
-
|
|
158
|
-
## Development setup
|
|
159
|
-
|
|
160
|
-
```bash
|
|
161
|
-
npm install
|
|
162
|
-
npm run build
|
|
163
|
-
```
|
|
42
|
+
## Tools
|
|
164
43
|
|
|
165
|
-
|
|
44
|
+
| Tool | What it does |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `verify_attestation`, `verify_predicate`, `verify_predicate_attestation`, `verify_document` | Check records and ZK claims against live contract state; absent = `verified: false` |
|
|
47
|
+
| `prepare_document_proof`, `prepare_membership_set` | Build proof inputs: salted content tree, set root |
|
|
48
|
+
| `anchor_document`, `attest_agent_output` | Anchor a document hash or an agent-output envelope (async) |
|
|
49
|
+
| `prove_field_predicate`, `prove_field_equality`, `prove_field_membership` | ZK claims over one hidden field (async) |
|
|
50
|
+
| `prove_field_predicates_batch` | Up to 8 claims in one transaction (async) |
|
|
51
|
+
| `prove_document_integrity`, `prove_document_diff` | ZK claims across two documents (async) |
|
|
52
|
+
| `grant_disclosure`, `revoke_disclosure` | On-chain disclosure ACL (async) |
|
|
53
|
+
| `build_sponsorable_transaction`, `get_attester_identity` | Build, prove and sign locally; the attester id and shielded keys it builds under |
|
|
54
|
+
| `sponsor_unbound_transaction`, `sponsor_finalized_transaction` | Hand locally built bytes to a sponsor that pays and submits (async) |
|
|
55
|
+
| `get_swap_wallet`, `read_swap_offer` | Shielded coins of the local wallet; what an offer gives and wants |
|
|
56
|
+
| `build_swap_offer`, `take_swap_offer`, `revert_swap_offer` | Build one half of a shielded swap locally, take an offer, release a half |
|
|
57
|
+
| `sponsor_swap` | Hand both halves of a swap to a sponsor that merges, pays and submits (async) |
|
|
58
|
+
| `derive_token_type` | Token type a minting contract produces |
|
|
59
|
+
| `get_job_status` | Poll an async job; batches report `chainSegments`, swaps `swap` |
|
|
60
|
+
| `analytics_*` | Midnight aggregates via ODATANO ASTRA, when the host serves it |
|
|
61
|
+
|
|
62
|
+
Errors carry the server's HTTP status and `code` (`INVALID_ARGUMENT`, ...).
|
|
63
|
+
|
|
64
|
+
## Fee sponsoring
|
|
65
|
+
|
|
66
|
+
1. `build_sponsorable_transaction` builds and proves the call locally (needs
|
|
67
|
+
`@odatano/nightgate-tx` installed next to the server and `NIGHTGATE_SEED_HEX`).
|
|
68
|
+
2. `sponsor_unbound_transaction` with a sponsor session id or the platform pool
|
|
69
|
+
id `00000000-0000-0000-0000-706f6f6c0000`.
|
|
70
|
+
3. `get_job_status` with the returned `sessionId`, then `verify_attestation`.
|
|
71
|
+
|
|
72
|
+
`failed` / `CHAIN_EXECUTION_FAILED`: landed but not applied; build again, never
|
|
73
|
+
resubmit the same bytes.
|
|
74
|
+
|
|
75
|
+
## Shielded swaps
|
|
76
|
+
|
|
77
|
+
Two wallets exchange two shielded tokens without a contract. Each side builds
|
|
78
|
+
one half, the halves mirror each other, a sponsor merges them and pays the fee.
|
|
79
|
+
Needs `@odatano/nightgate-tx` >= 0.8.0 next to the server and `NIGHTGATE_SEED_HEX`.
|
|
80
|
+
|
|
81
|
+
1. `get_swap_wallet`: balance, free coins and `spendable` per token type. The
|
|
82
|
+
first call starts the sync of the shielded coins (about 5 minutes from
|
|
83
|
+
genesis, seconds with `NIGHTGATE_SWAP_STATE_FILE`).
|
|
84
|
+
2. Maker: `build_swap_offer` with `give` and `want` returns the offer file
|
|
85
|
+
(`swapoffer1...`) to publish.
|
|
86
|
+
3. Taker: `read_swap_offer`, then `take_swap_offer` with `expect` and a
|
|
87
|
+
`sponsorSessionId`. It builds the mirror half and submits both.
|
|
88
|
+
4. `get_job_status` with the returned `sessionId`; the result carries `swap`.
|
|
89
|
+
|
|
90
|
+
- One half spends at most `NIGHTGATE_SWAP_MAX_INPUTS` coins, the smallest that
|
|
91
|
+
fit. `give.amount` above `spendable` is refused before proving.
|
|
92
|
+
- An offer fills once. Its coins stay reserved in the maker's wallet until the
|
|
93
|
+
swap lands or `revert_swap_offer` releases them.
|
|
94
|
+
- A refused submission keeps the proven half: `sponsor_swap` with its `halfId`.
|
|
95
|
+
- The sponsor needs swaps switched on and both token types on its list; an
|
|
96
|
+
agent grant needs `sponsorSwap` in `allowedActions`.
|
|
97
|
+
- With `NIGHTGATE_PROOF_SERVER_URL` the proof server sees the coins a half
|
|
98
|
+
spends: use one you run yourself.
|
|
99
|
+
|
|
100
|
+
## Configuration
|
|
166
101
|
|
|
167
102
|
| Variable | Default | Purpose |
|
|
168
103
|
|---|---|---|
|
|
169
|
-
| `
|
|
170
|
-
| `
|
|
171
|
-
| `
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
104
|
+
| `ODATANO_ACCESS_KEY` | unset | `oda_…` key, or an `ngat_…` agent grant on a direct instance |
|
|
105
|
+
| `ODATANO_ACCESS_URL` | `https://api.preprod.odatano.dev` | Gateway or a direct NIGHTGATE host |
|
|
106
|
+
| `ODATANO_ACCESS_USER` / `_PASSWORD` | unset | Basic auth of a direct instance |
|
|
107
|
+
| `NIGHTGATE_SEED_HEX` | unset | Seed (128 hex) for local building and swaps; never a tool argument |
|
|
108
|
+
| `NIGHTGATE_NETWORK` | `preprod` | Network of the local builder |
|
|
109
|
+
| `NIGHTGATE_PROOF_SERVER_URL` | unset | Prove on a proof server instead of in-process |
|
|
110
|
+
| `NIGHTGATE_SWAP_STATE_FILE` | unset | File for the swap wallet's state; it holds the wallet's coins, keep it like a key |
|
|
111
|
+
| `NIGHTGATE_SWAP_MAX_INPUTS` | `4` | Most coins one swap half spends; the sponsor's limit applies |
|
|
174
112
|
| `NIGHTGATE_TIMEOUT_MS` | `30000` | Per-request timeout |
|
|
175
|
-
| `NIGHTGATE_SEED_HEX` | unset | Caller seed (64 or 128 hex) for `build_sponsorable_transaction`; never a tool argument. Needs `@odatano/nightgate-tx` installed |
|
|
176
|
-
| `NIGHTGATE_NETWORK` | `preprod` | Network the local builder targets (`preview`, `preprod`, `mainnet`) |
|
|
177
|
-
| `NIGHTGATE_INDEXER_HTTP_URL` / `NIGHTGATE_INDEXER_WS_URL` / `NIGHTGATE_NODE_URL` | public Midnight endpoints of the network | Builder's indexer + node |
|
|
178
|
-
| `NIGHTGATE_ZK_CONFIG_BASE_URL` | `<base url>/zk-config/attestation-vault` | Where the builder fetches prover keys (cached on disk, `NIGHTGATE_ZK_CACHE_DIR`) |
|
|
179
|
-
| `NIGHTGATE_PROOF_SERVER_URL` | unset | Prove contract circuits on a proof server instead of in-process wasm |
|
|
180
113
|
|
|
181
|
-
|
|
114
|
+
Also: `NIGHTGATE_SERVICE_PATH`, `ODATANO_ANALYTICS_URL`, `NIGHTGATE_INDEXER_HTTP_URL`,
|
|
115
|
+
`NIGHTGATE_INDEXER_WS_URL`, `NIGHTGATE_NODE_URL`, `NIGHTGATE_ZK_CONFIG_BASE_URL`,
|
|
116
|
+
`NIGHTGATE_ZK_CACHE_DIR`.
|
|
182
117
|
|
|
183
|
-
|
|
184
|
-
|---|---|
|
|
185
|
-
| `verify_attestation` | Live-state check that an attester's record of a payload hash stands in an AttestationVault: named by `attesterId` + `payloadHash` or by a bound `documentId` (crawler-free, optional content-root / schema check, optional cross-network read) |
|
|
186
|
-
| `verify_predicate` | Live-state check that a ZK claim was recorded true on-chain, id-free: `attesterId` + `payloadHash` name the record; numeric predicates, `bytesEquality` (+ `expectedDigest`), `setMembership` (+ `setRoot`) and the cross-root kinds `documentIntegrity` / `documentDiff` (+ `payloadHashB`, optional `attesterIdB`) |
|
|
187
|
-
| `verify_predicate_attestation` | Verify a server-issued predicate attestation by its row id |
|
|
188
|
-
| `verify_document` | Verify an anchored document by document id + sha256 |
|
|
189
|
-
| `prepare_document_proof` | Canonicalize a document into payloadHash + salted Merkle contentRoot + schemaId + per-field proof inputs (incl. each slot salt) + the full `opening` the cross-root proofs need (synchronous) |
|
|
190
|
-
| `prepare_membership_set` | Build the canonical allow-list set tree: setRoot for verifiers, inclusion path for provers (synchronous) |
|
|
191
|
-
| `attest_agent_output` | Anchor agent-output provenance (canonical envelope, third-party verifiable; async job, NIGHTGATE >= 0.14.0) |
|
|
192
|
-
| `anchor_document` | Anchor a document content hash on-chain as the session's own record, keyed by attester and hash; returns `attesterId` for verifiers (async job) |
|
|
193
|
-
| `prove_field_predicate` | ZK proof that a hidden document field satisfies a threshold, without revealing it (async job) |
|
|
194
|
-
| `prove_field_equality` | ZK proof that a string field carries exactly the value behind a public digest (async job) |
|
|
195
|
-
| `prove_field_membership` | ZK proof that a hidden string field is one of a public allow-list, without revealing which (async job) |
|
|
196
|
-
| `prove_field_predicates_batch` | Up to 8 claims on one document in ONE transaction, any mix of numeric / equality / membership / cross-root kinds (async job) |
|
|
197
|
-
| `prove_document_integrity` | ZK proof that a second document differs from the anchored one ONLY in a public slot mask, values hidden (async job) |
|
|
198
|
-
| `prove_document_diff` | ZK proof that two anchored documents differ at >= k of the vault's slots, without revealing which (async job) |
|
|
199
|
-
| `grant_disclosure` / `revoke_disclosure` | Attester-only on-chain disclosure ACL (async jobs) |
|
|
200
|
-
| `build_sponsorable_transaction` | Build, prove and sign an AttestationVault call LOCALLY with the seed from the server environment (attest, anchorContentRoot, grant/revokeDisclosure, register/bindPassport, the proveField* claims against any attester's record); returns the fee-unpaid bytes for the sponsor tools, unbound by default (synchronous, 20-60 s, needs `@odatano/nightgate-tx`) |
|
|
201
|
-
| `get_attester_identity` | The attester id this server builds under, derived from the seed (synchronous) |
|
|
202
|
-
| `sponsor_finalized_transaction` | Submit a transaction that was built, proven and signed ELSEWHERE (e.g. with the `@odatano/nightgate-tx` txbuilder, the builder's key never leaves its machine); the sponsor session pays the dust, the effect carries the builder's identity; serial per sponsor wallet (async job) |
|
|
203
|
-
| `sponsor_unbound_transaction` | Same trust shape for an UNBOUND (`bind: false`) caller transaction: the sponsor merges a dust spend from a locked backing, binds and submits, several per sponsor wallet in parallel; `sponsorSessionId` may be the platform pool id (async job) |
|
|
204
|
-
| `derive_token_type` | Derive the raw token type a minting contract produces, from contract address + domain separator (synchronous) |
|
|
205
|
-
| `get_job_status` | Poll an async NIGHTGATE job until succeeded/failed |
|
|
206
|
-
|
|
207
|
-
### Analytics (ODATANO ASTRA, registered when the host serves it)
|
|
208
|
-
|
|
209
|
-
Aggregates over the Midnight index, one unit per read, same key. Every tool pins the chain; the
|
|
210
|
-
Cardano server (`@odatano/core-mcp`) carries the same tools for its chain.
|
|
211
|
-
|
|
212
|
-
| Tool | What it does |
|
|
213
|
-
|---|---|
|
|
214
|
-
| `analytics_overview` | Network, tip, both lags, blocks and transactions of the last hour with change, fees of the last 24 h in DUST (total, median, p95), average block time |
|
|
215
|
-
| `analytics_key_figures` | Every chain-wide metric over one window (`1h`, `24h`, `7d`, `14d`, `30d`): value, previous window, change in % |
|
|
216
|
-
| `analytics_daily` | One row per UTC day: `blocks`, `transactions` (shielded, with proof, contract calls/deploys, failed, ...) or `fees` (paid, estimated, estimate error), newest first |
|
|
217
|
-
| `analytics_top_block_producers` | Block authors by blocks produced over a window |
|
|
218
|
-
| `analytics_metrics` | The metric catalogue: ids, kinds, units, descriptions |
|
|
219
|
-
| `analytics_metric` / `analytics_series` | One metric over a window (value, previous, change, percentiles) / as a time series in the window's resolution |
|
|
220
|
-
| `analytics_compare` | The same metric for Midnight and Cardano side by side |
|
|
221
|
-
| `analytics_anomalies` | Days far from their own baseline, in standard deviations, with every number the verdict rests on |
|
|
222
|
-
|
|
223
|
-
All verification tools return `verified: false` as a clean negative rather
|
|
224
|
-
than an error when the attestation or proof is absent. Write tools require
|
|
225
|
-
a connected wallet session (`sessionId`); creating sessions stays outside
|
|
226
|
-
MCP by design.
|
|
227
|
-
|
|
228
|
-
## Integration check
|
|
118
|
+
## Own instance
|
|
229
119
|
|
|
230
120
|
```bash
|
|
231
|
-
|
|
121
|
+
docker run -d -p 4004:4004 -e ENCRYPTION_KEY=$(openssl rand -hex 32) \
|
|
122
|
+
-e NIGHTGATE_HTTP_PASSWORD=change-me -v nightgate-data:/data ghcr.io/odatano/nightgate:latest
|
|
232
123
|
```
|
|
233
124
|
|
|
234
|
-
|
|
235
|
-
|
|
125
|
+
Then `ODATANO_ACCESS_URL=http://localhost:4004`, `ODATANO_ACCESS_USER=nightgate`,
|
|
126
|
+
`ODATANO_ACCESS_PASSWORD=change-me`. For agents, create a grant with
|
|
127
|
+
`createAgentGrant` and pass its `ngat_…` token as `ODATANO_ACCESS_KEY`.
|
|
128
|
+
|
|
129
|
+
## Compatibility
|
|
130
|
+
|
|
131
|
+
NIGHTGATE >= 0.24.0; `chainSegments` needs >= 0.28.0, swaps need >= 0.29.0.
|
|
132
|
+
`@odatano/nightgate-tx` >= 0.8.0 for local building. Per version: [CHANGELOG](CHANGELOG.md).
|
|
133
|
+
|
|
134
|
+
Local building needs ONE `@midnight-ntwrk/ledger-v8` in the install
|
|
135
|
+
(`npm ls @midnight-ntwrk/ledger-v8`). `expected instance of ...` means two:
|
|
136
|
+
`npm dedupe`.
|
|
137
|
+
|
|
138
|
+
## Development
|
|
236
139
|
|
|
237
140
|
```bash
|
|
238
|
-
|
|
239
|
-
NIGHTGATE_TEST_CONTRACT=<vault address> NIGHTGATE_TEST_PAYLOAD_HASH=<64 hex> \
|
|
240
|
-
npm run integration
|
|
141
|
+
npm install && npm run integration
|
|
241
142
|
```
|
|
242
143
|
|
|
243
|
-
|
|
244
|
-
tools with a grant token only: `get_attester_identity`,
|
|
245
|
-
`build_sponsorable_transaction` (local), `sponsor_unbound_transaction`,
|
|
246
|
-
`get_job_status`, `verify_attestation` (the attester id must be ours):
|
|
144
|
+
Live lanes:
|
|
247
145
|
|
|
248
146
|
```bash
|
|
249
|
-
|
|
250
|
-
NIGHTGATE_SEED_HEX=<
|
|
251
|
-
NIGHTGATE_VAULT=<vault address> NIGHTGATE_SPONSOR_SESSION_ID=<sponsor or pool id> \
|
|
252
|
-
npm run live:sponsor-unbound
|
|
147
|
+
NIGHTGATE_LIVE=1 NIGHTGATE_TEST_CONTRACT=<vault> NIGHTGATE_TEST_PAYLOAD_HASH=<64 hex> npm run integration
|
|
148
|
+
NIGHTGATE_SEED_HEX=<hex> NIGHTGATE_VAULT=<vault> NIGHTGATE_SPONSOR_SESSION_ID=<sponsor or pool id> npm run live:sponsor-unbound
|
|
253
149
|
```
|
|
254
150
|
|
|
255
151
|
## License
|
package/dist/builder.d.ts
CHANGED
|
@@ -52,6 +52,9 @@ export declare function buildSponsorable(config: NightgateMcpConfig, input: Buil
|
|
|
52
52
|
export declare function attesterIdentity(config: NightgateMcpConfig): Promise<{
|
|
53
53
|
attesterId: string;
|
|
54
54
|
network: string;
|
|
55
|
+
shieldedAddress?: string;
|
|
56
|
+
coinPublicKey?: string;
|
|
57
|
+
encryptionPublicKey?: string;
|
|
55
58
|
}>;
|
|
56
59
|
/** Test seam / shutdown: release every lineage's builder connections. */
|
|
57
60
|
export declare function closeBuilder(): Promise<void>;
|
package/dist/builder.js
CHANGED
|
@@ -67,7 +67,7 @@ async function loadModules(ref = DEFAULT_ARTIFACT) {
|
|
|
67
67
|
}
|
|
68
68
|
catch (err) {
|
|
69
69
|
modules.delete(ref);
|
|
70
|
-
throw new Error(`local building of '${ref}' needs @odatano/nightgate-tx >= 0.
|
|
70
|
+
throw new Error(`local building of '${ref}' needs @odatano/nightgate-tx >= 0.8.0 next to the MCP server ` +
|
|
71
71
|
'(npm install @odatano/nightgate-tx): ' + (err instanceof Error ? err.message : String(err)));
|
|
72
72
|
}
|
|
73
73
|
})();
|
|
@@ -90,7 +90,7 @@ function defaults(network) {
|
|
|
90
90
|
*/
|
|
91
91
|
async function getBuilder(config, ref = DEFAULT_ARTIFACT) {
|
|
92
92
|
if (!config.seedHex) {
|
|
93
|
-
throw new Error('local building needs NIGHTGATE_SEED_HEX (
|
|
93
|
+
throw new Error('local building needs NIGHTGATE_SEED_HEX (128 hex) in the MCP server environment; it is never a tool argument');
|
|
94
94
|
}
|
|
95
95
|
let entry = builders.get(ref);
|
|
96
96
|
if (!entry) {
|
|
@@ -245,7 +245,13 @@ export async function buildSponsorable(config, input) {
|
|
|
245
245
|
/** The caller's attester id (derived from the seed), without building anything. */
|
|
246
246
|
export async function attesterIdentity(config) {
|
|
247
247
|
const b = await getBuilder(config);
|
|
248
|
-
return {
|
|
248
|
+
return {
|
|
249
|
+
attesterId: String(b.attesterId),
|
|
250
|
+
network: config.network,
|
|
251
|
+
// from @odatano/nightgate-tx 0.8.0 on
|
|
252
|
+
...(b.addresses?.shielded ? { shieldedAddress: String(b.addresses.shielded) } : {}),
|
|
253
|
+
...(b.shieldedKeys ? { coinPublicKey: String(b.shieldedKeys.coinPublicKey), encryptionPublicKey: String(b.shieldedKeys.encryptionPublicKey) } : {}),
|
|
254
|
+
};
|
|
249
255
|
}
|
|
250
256
|
/** Test seam / shutdown: release every lineage's builder connections. */
|
|
251
257
|
export async function closeBuilder() {
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ;IACR,mBAAmB;IACnB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,oBAAoB;IACpB,sBAAsB;IACtB,4BAA4B;IAC5B,mBAAmB;CACX,CAAC;AAGX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,mBAAmB,EAAE,sBAAsB,CAAU,CAAC;AAE1F,MAAM,CAAC,MAAM,gBAAgB,GAAsB,mBAAmB,CAAC;AAmCvE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyC,CAAC;AACjE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmC,CAAC;AAE5D,KAAK,UAAU,WAAW,CAAC,MAAyB,gBAAgB;IAClE,IAAI,KAAK,GAAG,OAAO,CAA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,CAAC,CAAC,CAAC,YAAY,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpJ,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACjB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC;YAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface NightgateMcpConfig {
|
|
|
29
29
|
analyticsUrl: string;
|
|
30
30
|
/** Request timeout in milliseconds. */
|
|
31
31
|
timeoutMs: number;
|
|
32
|
-
/** Caller seed (64
|
|
32
|
+
/** Caller seed (128 hex, a 64-byte BIP39 seed) for local building and swaps; never a tool argument. */
|
|
33
33
|
seedHex?: string;
|
|
34
34
|
/** Midnight network the builder targets; default preprod. */
|
|
35
35
|
network: string;
|
|
@@ -42,5 +42,9 @@ export interface NightgateMcpConfig {
|
|
|
42
42
|
zkCacheDir?: string;
|
|
43
43
|
/** Set to prove contract circuits on a proof server instead of in-process wasm. */
|
|
44
44
|
proofServerUrl?: string;
|
|
45
|
+
/** File the swap wallet's state is kept in, so a restart resumes instead of syncing from genesis. It holds the wallet's coins. */
|
|
46
|
+
swapStateFile?: string;
|
|
47
|
+
/** Most coins one swap half spends; default the builder's (4, the sponsor's default). */
|
|
48
|
+
swapMaxInputs?: number;
|
|
45
49
|
}
|
|
46
50
|
export declare function loadConfig(env?: NodeJS.ProcessEnv): NightgateMcpConfig;
|
package/dist/config.js
CHANGED
|
@@ -9,8 +9,12 @@ export function loadConfig(env = process.env) {
|
|
|
9
9
|
throw new Error(`Invalid NIGHTGATE_NETWORK: ${network} (preview | preprod | mainnet)`);
|
|
10
10
|
}
|
|
11
11
|
const seedHex = env.NIGHTGATE_SEED_HEX || undefined;
|
|
12
|
-
if (seedHex && !/^
|
|
13
|
-
throw new Error('Invalid NIGHTGATE_SEED_HEX: expected
|
|
12
|
+
if (seedHex && !/^[0-9a-fA-F]{128}$/.test(seedHex)) {
|
|
13
|
+
throw new Error('Invalid NIGHTGATE_SEED_HEX: expected 128 hex characters (a 64-byte BIP39 seed)');
|
|
14
|
+
}
|
|
15
|
+
const swapMaxInputs = env.NIGHTGATE_SWAP_MAX_INPUTS ? Number(env.NIGHTGATE_SWAP_MAX_INPUTS) : undefined;
|
|
16
|
+
if (swapMaxInputs !== undefined && (!Number.isInteger(swapMaxInputs) || swapMaxInputs < 1)) {
|
|
17
|
+
throw new Error(`Invalid NIGHTGATE_SWAP_MAX_INPUTS: ${env.NIGHTGATE_SWAP_MAX_INPUTS} (a positive integer)`);
|
|
14
18
|
}
|
|
15
19
|
const analyticsUrl = (env.ODATANO_ANALYTICS_URL || `${baseUrl}/odata/v4/astra`).replace(/\/+$/, '');
|
|
16
20
|
return {
|
|
@@ -29,6 +33,8 @@ export function loadConfig(env = process.env) {
|
|
|
29
33
|
zkConfigBaseUrl: env.NIGHTGATE_ZK_CONFIG_BASE_URL || undefined,
|
|
30
34
|
zkCacheDir: env.NIGHTGATE_ZK_CACHE_DIR || undefined,
|
|
31
35
|
proofServerUrl: env.NIGHTGATE_PROOF_SERVER_URL || undefined,
|
|
36
|
+
swapStateFile: env.NIGHTGATE_SWAP_STATE_FILE || undefined,
|
|
37
|
+
swapMaxInputs,
|
|
32
38
|
};
|
|
33
39
|
}
|
|
34
40
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
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K,CAAC,sCAAsC,GAAG,CAAC,yBAAyB,uBAAuB,CAAC,CAAC;IAC9G,CAAC;IACD,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,qBAAqB,IAAI,GAAG,OAAO,iBAAiB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpG,OAAO;QACL,OAAO;QACP,KAAK,EAAE,GAAG,CAAC,kBAAkB,IAAI,SAAS;QAC1C,QAAQ,EAAE,GAAG,CAAC,mBAAmB,IAAI,SAAS;QAC9C,QAAQ,EAAE,GAAG,CAAC,uBAAuB,IAAI,SAAS;QAClD,WAAW,EAAE,GAAG,CAAC,sBAAsB,IAAI,mBAAmB;QAC9D,YAAY;QACZ,SAAS;QACT,OAAO;QACP,OAAO;QACP,cAAc,EAAE,GAAG,CAAC,0BAA0B,IAAI,SAAS;QAC3D,YAAY,EAAE,GAAG,CAAC,wBAAwB,IAAI,SAAS;QACvD,OAAO,EAAE,GAAG,CAAC,kBAAkB,IAAI,SAAS;QAC5C,eAAe,EAAE,GAAG,CAAC,4BAA4B,IAAI,SAAS;QAC9D,UAAU,EAAE,GAAG,CAAC,sBAAsB,IAAI,SAAS;QACnD,cAAc,EAAE,GAAG,CAAC,0BAA0B,IAAI,SAAS;QAC3D,aAAa,EAAE,GAAG,CAAC,yBAAyB,IAAI,SAAS;QACzD,aAAa;KACd,CAAC;AACJ,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -8,7 +8,7 @@ import { registerAnalyticsTools } from './analytics.js';
|
|
|
8
8
|
* host (schema inspection, tests) get a deterministic tool set.
|
|
9
9
|
*/
|
|
10
10
|
export function buildServer(config, caps = { analytics: false }) {
|
|
11
|
-
const server = new McpServer({ name: 'nightgate', version: '0.
|
|
11
|
+
const server = new McpServer({ name: 'nightgate', version: '0.9.0' });
|
|
12
12
|
const client = new NightgateClient(config);
|
|
13
13
|
registerTools(server, client, config);
|
|
14
14
|
if (caps.analytics)
|