@odatano/nightgate-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/LICENSE +178 -0
- package/README.md +128 -0
- package/dist/client.d.ts +29 -0
- package/dist/client.js +112 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.js +16 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +10 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +8 -0
- package/dist/tools.js +341 -0
- package/dist/tools.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
Copyright [2026] [Max Weber]
|
|
177
|
+
|
|
178
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @odatano/nightgate-mcp
|
|
2
|
+
|
|
3
|
+
MCP server that lets AI agents use [NIGHTGATE](https://github.com/ODATANO/NIGHTGATE),
|
|
4
|
+
the Midnight blockchain attestation layer: anchor documents, prove
|
|
5
|
+
zero-knowledge predicates over hidden fields, manage disclosure grants,
|
|
6
|
+
verify everything against live contract state, and poll async jobs.
|
|
7
|
+
Wallet lifecycle (connect, send, deploy) is deliberately not exposed.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Node.js >= 20
|
|
12
|
+
- A running NIGHTGATE instance (>= 0.14.0 for the full tool set)
|
|
13
|
+
|
|
14
|
+
## Getting a NIGHTGATE instance
|
|
15
|
+
|
|
16
|
+
The fastest way is the official Docker image; no Node setup, no host app
|
|
17
|
+
(published from the NIGHTGATE repo on every release, details in its
|
|
18
|
+
`docs/docker.md`):
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
docker run -d --name nightgate -p 4004:4004 \
|
|
22
|
+
-e ENCRYPTION_KEY=$(openssl rand -hex 32) \
|
|
23
|
+
-e NIGHTGATE_HTTP_PASSWORD=change-me \
|
|
24
|
+
-v nightgate-data:/data \
|
|
25
|
+
ghcr.io/odatano/nightgate:latest
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
That container targets Midnight preprod by default, serves with HTTP basic
|
|
29
|
+
auth (`nightgate` / your password), persists its database in the
|
|
30
|
+
`nightgate-data` volume, and proves in-process (wasm), so no proof server
|
|
31
|
+
is needed to start. Point this MCP server at it with:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
NIGHTGATE_BASE_URL=http://localhost:4004
|
|
35
|
+
NIGHTGATE_USERNAME=nightgate
|
|
36
|
+
NIGHTGATE_PASSWORD=change-me
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For agent operation, create a scoped grant once (as the operator, e.g. via
|
|
40
|
+
curl against `createAgentGrant`) and hand the returned `ngat_...` token to
|
|
41
|
+
the agent as `NIGHTGATE_TOKEN`; the write tools are then limited to the
|
|
42
|
+
grant's allowlist, budget and pinned session.
|
|
43
|
+
|
|
44
|
+
Alternatively any CAP app using the `@odatano/nightgate` plugin works,
|
|
45
|
+
e.g. the NIGHTGATE repo itself via `npm run dev`.
|
|
46
|
+
|
|
47
|
+
## Setup
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install
|
|
51
|
+
npm run build
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Configuration is environment-driven:
|
|
55
|
+
|
|
56
|
+
| Variable | Default | Purpose |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `NIGHTGATE_BASE_URL` | `http://localhost:4004` | NIGHTGATE host app |
|
|
59
|
+
| `NIGHTGATE_USERNAME` / `NIGHTGATE_PASSWORD` | unset | Basic auth (CAP dev/mocked auth) |
|
|
60
|
+
| `NIGHTGATE_TOKEN` | unset | `ngat_...` agent-grant token (sent as `x-agent-token`, combinable with basic auth) or a plain bearer token |
|
|
61
|
+
| `NIGHTGATE_SERVICE_PATH` | `/api/v1/nightgate` | OData service path |
|
|
62
|
+
| `NIGHTGATE_TIMEOUT_MS` | `30000` | Per-request timeout |
|
|
63
|
+
|
|
64
|
+
## Use with Claude Code
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
claude mcp add nightgate \
|
|
68
|
+
--env NIGHTGATE_BASE_URL=http://localhost:4004 \
|
|
69
|
+
--env NIGHTGATE_USERNAME=alice \
|
|
70
|
+
-- node /path/to/NIGHTGATE-MCP/dist/index.js
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Or in a project `.mcp.json`:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"mcpServers": {
|
|
78
|
+
"nightgate": {
|
|
79
|
+
"command": "node",
|
|
80
|
+
"args": ["/path/to/NIGHTGATE-MCP/dist/index.js"],
|
|
81
|
+
"env": {
|
|
82
|
+
"NIGHTGATE_BASE_URL": "http://localhost:4004",
|
|
83
|
+
"NIGHTGATE_USERNAME": "alice"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Tools
|
|
91
|
+
|
|
92
|
+
| Tool | What it does |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `verify_attestation` | Live-state check that a payload hash is attested in an AttestationVault (crawler-free, optional content-root check, optional cross-network read) |
|
|
95
|
+
| `verify_predicate` | Live-state check that a ZK predicate proof was recorded true on-chain, id-free (plain or field-bound) |
|
|
96
|
+
| `verify_predicate_attestation` | Verify a server-issued predicate attestation by its row id |
|
|
97
|
+
| `verify_document` | Verify an anchored document by document id + sha256 |
|
|
98
|
+
| `prepare_document_proof` | Canonicalize a document into payloadHash + Merkle contentRoot + per-field proof inputs (synchronous, NIGHTGATE >= 0.14.0) |
|
|
99
|
+
| `attest_agent_output` | Anchor agent-output provenance (canonical envelope, third-party verifiable; async job, NIGHTGATE >= 0.14.0) |
|
|
100
|
+
| `anchor_document` | Anchor a document content hash on-chain (async job) |
|
|
101
|
+
| `prove_field_predicate` | ZK proof that a hidden document field satisfies a threshold, without revealing it (async job) |
|
|
102
|
+
| `prove_field_predicates_batch` | Up to 8 field predicates on one document in ONE transaction (async job) |
|
|
103
|
+
| `grant_disclosure` / `revoke_disclosure` | Attester-only on-chain disclosure ACL (async jobs) |
|
|
104
|
+
| `get_job_status` | Poll an async NIGHTGATE job until succeeded/failed |
|
|
105
|
+
|
|
106
|
+
All verification tools return `verified: false` as a clean negative rather
|
|
107
|
+
than an error when the attestation or proof is absent. Write tools require
|
|
108
|
+
a connected wallet session (`sessionId`); creating sessions stays outside
|
|
109
|
+
MCP by design.
|
|
110
|
+
|
|
111
|
+
## Integration check
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm run integration
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Runs an in-memory MCP client against the server: asserts the tool set,
|
|
118
|
+
schemas, and argument validation. Optional live round-trip:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
NIGHTGATE_LIVE=1 NIGHTGATE_BASE_URL=... NIGHTGATE_USERNAME=... \
|
|
122
|
+
NIGHTGATE_TEST_CONTRACT=<vault address> NIGHTGATE_TEST_PAYLOAD_HASH=<64 hex> \
|
|
123
|
+
npm run integration
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
Apache-2.0
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { NightgateMcpConfig } from './config.js';
|
|
2
|
+
/** Error carrying the OData error body of a failed NIGHTGATE call. */
|
|
3
|
+
export declare class NightgateApiError extends Error {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly code: string | undefined;
|
|
6
|
+
constructor(status: number, code: string | undefined, message: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Marker for an OData Int64 URL literal: rendered unquoted so precision
|
|
10
|
+
* is preserved beyond Number.MAX_SAFE_INTEGER.
|
|
11
|
+
*/
|
|
12
|
+
export interface Int64Literal {
|
|
13
|
+
$int64: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function int64(value: string | number): Int64Literal;
|
|
16
|
+
/**
|
|
17
|
+
* Minimal OData V4 client for the Nightgate service. Two verbs only:
|
|
18
|
+
* unbound functions (GET, parameters inline in the URL) and unbound
|
|
19
|
+
* actions (POST, JSON body), which is all the MCP tools need.
|
|
20
|
+
*/
|
|
21
|
+
export declare class NightgateClient {
|
|
22
|
+
private readonly config;
|
|
23
|
+
constructor(config: NightgateMcpConfig);
|
|
24
|
+
/** GET <service>/<name>(p1=...,p2=...) with only the provided parameters. */
|
|
25
|
+
callFunction(name: string, params: Record<string, string | number | Int64Literal | undefined>): Promise<unknown>;
|
|
26
|
+
/** POST <service>/<name> with the provided parameters as JSON body. */
|
|
27
|
+
callAction(name: string, params: Record<string, unknown>): Promise<unknown>;
|
|
28
|
+
private request;
|
|
29
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** Error carrying the OData error body of a failed NIGHTGATE call. */
|
|
2
|
+
export class NightgateApiError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
code;
|
|
5
|
+
constructor(status, code, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.name = 'NightgateApiError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function int64(value) {
|
|
13
|
+
const digits = String(value);
|
|
14
|
+
if (!/^\d+$/.test(digits))
|
|
15
|
+
throw new Error(`not a non-negative integer: ${value}`);
|
|
16
|
+
return { $int64: digits };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Minimal OData V4 client for the Nightgate service. Two verbs only:
|
|
20
|
+
* unbound functions (GET, parameters inline in the URL) and unbound
|
|
21
|
+
* actions (POST, JSON body), which is all the MCP tools need.
|
|
22
|
+
*/
|
|
23
|
+
export class NightgateClient {
|
|
24
|
+
config;
|
|
25
|
+
constructor(config) {
|
|
26
|
+
this.config = config;
|
|
27
|
+
}
|
|
28
|
+
/** GET <service>/<name>(p1=...,p2=...) with only the provided parameters. */
|
|
29
|
+
async callFunction(name, params) {
|
|
30
|
+
const parts = [];
|
|
31
|
+
for (const [key, value] of Object.entries(params)) {
|
|
32
|
+
if (value === undefined || value === null || value === '')
|
|
33
|
+
continue;
|
|
34
|
+
parts.push(`${key}=${odataLiteral(value)}`);
|
|
35
|
+
}
|
|
36
|
+
const url = `${this.config.baseUrl}${this.config.servicePath}/${name}(${parts.join(',')})`;
|
|
37
|
+
return this.request('GET', url);
|
|
38
|
+
}
|
|
39
|
+
/** POST <service>/<name> with the provided parameters as JSON body. */
|
|
40
|
+
async callAction(name, params) {
|
|
41
|
+
const body = {};
|
|
42
|
+
for (const [key, value] of Object.entries(params)) {
|
|
43
|
+
if (value === undefined)
|
|
44
|
+
continue;
|
|
45
|
+
body[key] = value;
|
|
46
|
+
}
|
|
47
|
+
const url = `${this.config.baseUrl}${this.config.servicePath}/${name}`;
|
|
48
|
+
return this.request('POST', url, body);
|
|
49
|
+
}
|
|
50
|
+
async request(method, url, body) {
|
|
51
|
+
const headers = { Accept: 'application/json' };
|
|
52
|
+
if (this.config.token?.startsWith('ngat_')) {
|
|
53
|
+
// NIGHTGATE agent-grant token (0.14.0): travels in its own header so it
|
|
54
|
+
// never collides with the host app's transport auth. Basic credentials
|
|
55
|
+
// may accompany it when the host requires transport authentication.
|
|
56
|
+
headers['x-agent-token'] = this.config.token;
|
|
57
|
+
if (this.config.username) {
|
|
58
|
+
const basic = Buffer.from(`${this.config.username}:${this.config.password ?? ''}`).toString('base64');
|
|
59
|
+
headers.Authorization = `Basic ${basic}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (this.config.token) {
|
|
63
|
+
headers.Authorization = `Bearer ${this.config.token}`;
|
|
64
|
+
}
|
|
65
|
+
else if (this.config.username) {
|
|
66
|
+
const basic = Buffer.from(`${this.config.username}:${this.config.password ?? ''}`).toString('base64');
|
|
67
|
+
headers.Authorization = `Basic ${basic}`;
|
|
68
|
+
}
|
|
69
|
+
if (body !== undefined)
|
|
70
|
+
headers['Content-Type'] = 'application/json';
|
|
71
|
+
const response = await fetch(url, {
|
|
72
|
+
method,
|
|
73
|
+
headers,
|
|
74
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
75
|
+
signal: AbortSignal.timeout(this.config.timeoutMs),
|
|
76
|
+
});
|
|
77
|
+
const text = await response.text();
|
|
78
|
+
let payload;
|
|
79
|
+
try {
|
|
80
|
+
payload = text ? JSON.parse(text) : {};
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
payload = { raw: text };
|
|
84
|
+
}
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
const err = payload.error;
|
|
87
|
+
throw new NightgateApiError(response.status, err?.code, err?.message ?? `NIGHTGATE request failed with HTTP ${response.status}`);
|
|
88
|
+
}
|
|
89
|
+
return stripODataNoise(payload);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Encode a JS value as an OData URL literal (strings quoted, '' -> escaped). */
|
|
93
|
+
function odataLiteral(value) {
|
|
94
|
+
if (typeof value === 'number')
|
|
95
|
+
return String(value);
|
|
96
|
+
if (typeof value === 'object')
|
|
97
|
+
return value.$int64;
|
|
98
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
99
|
+
}
|
|
100
|
+
/** Drop @odata.* metadata keys so tool output stays clean for the model. */
|
|
101
|
+
function stripODataNoise(payload) {
|
|
102
|
+
if (payload === null || typeof payload !== 'object' || Array.isArray(payload))
|
|
103
|
+
return payload;
|
|
104
|
+
const out = {};
|
|
105
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
106
|
+
if (key.startsWith('@odata'))
|
|
107
|
+
continue;
|
|
108
|
+
out[key] = value;
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAExB;IACA;IAFlB,YACkB,MAAc,EACd,IAAwB,EACxC,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAoB;QAIxC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAUD,MAAM,UAAU,KAAK,CAAC,KAAsB;IAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,OA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K,CAAC,MAAM,CAAC;IACnD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AAC1C,CAAC;AAED,4EAA4E;AAC5E,SAAS,eAAe,CAAC,OAAgB;IACvC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAC9F,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAkC,CAAC,EAAE,CAAC;QAC9E,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,SAAS;QACvC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server configuration, environment-driven so the same binary works for
|
|
3
|
+
* local dev (basic auth against a `cds watch` instance) and for a deployed
|
|
4
|
+
* NIGHTGATE behind a reverse proxy (bearer token, phase B agent grants).
|
|
5
|
+
*/
|
|
6
|
+
export interface NightgateMcpConfig {
|
|
7
|
+
/** Base URL of the NIGHTGATE host app, e.g. http://localhost:4004 */
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* Token credential. An `ngat_...` value is a NIGHTGATE agent-grant token
|
|
11
|
+
* (sent as `x-agent-token`, optionally alongside basic transport auth);
|
|
12
|
+
* anything else is sent as a plain `Authorization: Bearer` header.
|
|
13
|
+
*/
|
|
14
|
+
token?: string;
|
|
15
|
+
/** Basic-auth credentials for dev/mocked CAP auth. */
|
|
16
|
+
username?: string;
|
|
17
|
+
password?: string;
|
|
18
|
+
/** OData service path of the main Nightgate service. */
|
|
19
|
+
servicePath: string;
|
|
20
|
+
/** Request timeout in milliseconds. */
|
|
21
|
+
timeoutMs: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function loadConfig(env?: NodeJS.ProcessEnv): NightgateMcpConfig;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function loadConfig(env = process.env) {
|
|
2
|
+
const baseUrl = (env.NIGHTGATE_BASE_URL ?? 'http://localhost:4004').replace(/\/+$/, '');
|
|
3
|
+
const timeoutMs = Number(env.NIGHTGATE_TIMEOUT_MS ?? 30000);
|
|
4
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
5
|
+
throw new Error(`Invalid NIGHTGATE_TIMEOUT_MS: ${env.NIGHTGATE_TIMEOUT_MS}`);
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
baseUrl,
|
|
9
|
+
token: env.NIGHTGATE_TOKEN || undefined,
|
|
10
|
+
username: env.NIGHTGATE_USERNAME || undefined,
|
|
11
|
+
password: env.NIGHTGATE_PASSWORD || undefined,
|
|
12
|
+
servicePath: env.NIGHTGATE_SERVICE_PATH ?? '/api/v1/nightgate',
|
|
13
|
+
timeoutMs,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAuBA,MAAM,UAAU,UAAU,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC7D,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,kBAAkB,IAAI,uBAAuB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACxF,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,IAAI,KAAK,CAAC,CAAC;IAC5D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO;QACL,OAAO;QACP,KAAK,EAAE,GAAG,CAAC,eAAe,IAAI,SAAS;QACvC,QAAQ,EAAE,GAAG,CAAC,kBAAkB,IAAI,SAAS;QAC7C,QAAQ,EAAE,GAAG,CAAC,kBAAkB,IAAI,SAAS;QAC7C,WAAW,EAAE,GAAG,CAAC,sBAAsB,IAAI,mBAAmB;QAC9D,SAAS;KACV,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { buildServer } from './server.js';
|
|
4
|
+
import { loadConfig } from './config.js';
|
|
5
|
+
async function main() {
|
|
6
|
+
const config = loadConfig();
|
|
7
|
+
const server = buildServer(config);
|
|
8
|
+
// stdio transport: stdout is the protocol channel, diagnostics go to stderr
|
|
9
|
+
console.error(`nightgate-mcp: connecting tools to ${config.baseUrl}${config.servicePath}`);
|
|
10
|
+
await server.connect(new StdioServerTransport());
|
|
11
|
+
}
|
|
12
|
+
main().catch((err) => {
|
|
13
|
+
console.error('nightgate-mcp failed to start:', err);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,4EAA4E;IAC5E,OAAO,CAAC,KAAK,CAAC,sCAAsC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3F,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;IACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { NightgateMcpConfig } from './config.js';
|
|
3
|
+
/** Build the MCP server with all tools registered; transport is the caller's choice. */
|
|
4
|
+
export declare function buildServer(config: NightgateMcpConfig): McpServer;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { NightgateClient } from './client.js';
|
|
3
|
+
import { registerTools } from './tools.js';
|
|
4
|
+
/** Build the MCP server with all tools registered; transport is the caller's choice. */
|
|
5
|
+
export function buildServer(config) {
|
|
6
|
+
const server = new McpServer({ name: 'nightgate', version: '0.1.0' });
|
|
7
|
+
registerTools(server, new NightgateClient(config));
|
|
8
|
+
return server;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,MAA0B;IACpD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACtE,aAAa,CAAC,MAAM,EAAE,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { NightgateClient } from './client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Phase A tool set: crawler-free verification, job polling, and the
|
|
5
|
+
* curated write path (anchoring, field predicates, disclosure).
|
|
6
|
+
* Wallet lifecycle actions are deliberately never exposed over MCP.
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerTools(server: McpServer, client: NightgateClient): void;
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { int64, NightgateApiError } from './client.js';
|
|
3
|
+
const HEX64 = /^[0-9a-fA-F]{64}$/;
|
|
4
|
+
const hex64 = (what) => z.string().regex(HEX64, `${what} must be 64 hex characters`);
|
|
5
|
+
/** Scaled non-negative integer, as string (preferred, exact) or JS number. */
|
|
6
|
+
const scaledInt = (what) => z.union([
|
|
7
|
+
z.string().regex(/^\d+$/, `${what} must be a non-negative integer (decimal string)`),
|
|
8
|
+
z.number().int().nonnegative(),
|
|
9
|
+
]);
|
|
10
|
+
const merkleSiblings = z.array(hex64('sibling')).length(4)
|
|
11
|
+
.describe('Depth-4 Merkle inclusion path: exactly 4 sibling digests (64 hex each)');
|
|
12
|
+
const merkleDirs = z.array(z.boolean()).length(4)
|
|
13
|
+
.describe('Exactly 4 booleans; true means the current node is the LEFT child');
|
|
14
|
+
const POLL_HINT = 'Async: returns { jobId, status } immediately; poll get_job_status until succeeded or failed.';
|
|
15
|
+
/**
|
|
16
|
+
* Phase A tool set: crawler-free verification, job polling, and the
|
|
17
|
+
* curated write path (anchoring, field predicates, disclosure).
|
|
18
|
+
* Wallet lifecycle actions are deliberately never exposed over MCP.
|
|
19
|
+
*/
|
|
20
|
+
export function registerTools(server, client) {
|
|
21
|
+
const run = wrapHandler(client);
|
|
22
|
+
server.registerTool('verify_attestation', {
|
|
23
|
+
description: 'Verify against LIVE Midnight contract state that a payload hash is attested in an ' +
|
|
24
|
+
'AttestationVault (crawler-free, no txHash needed). Optionally also checks that the ' +
|
|
25
|
+
'anchored content root matches. Returns verified:false (not an error) when absent.',
|
|
26
|
+
inputSchema: {
|
|
27
|
+
contractAddress: z.string().min(1).describe('AttestationVault contract address'),
|
|
28
|
+
payloadHash: hex64('payloadHash').describe('The attested payload hash (sha256, 64 hex)'),
|
|
29
|
+
contentRoot: hex64('contentRoot').optional().describe('Optional anchored content root to check (64 hex)'),
|
|
30
|
+
network: z.enum(['preview', 'preprod', 'mainnet']).optional()
|
|
31
|
+
.describe('Read from another network public indexer instead of the configured one'),
|
|
32
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
33
|
+
},
|
|
34
|
+
}, run(async (args) => client.callFunction('verifyAttestationState', {
|
|
35
|
+
contractAddress: args.contractAddress,
|
|
36
|
+
payloadHash: args.payloadHash,
|
|
37
|
+
contentRoot: args.contentRoot,
|
|
38
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
39
|
+
network: args.network,
|
|
40
|
+
})));
|
|
41
|
+
server.registerTool('verify_predicate', {
|
|
42
|
+
description: 'Verify against LIVE Midnight contract state that a ZK predicate proof (e.g. "hidden value ' +
|
|
43
|
+
'<= threshold") was recorded true on-chain. Id-free: works for proofs NIGHTGATE never saw. ' +
|
|
44
|
+
'threshold must be the SAME scaled integer the circuit hashed (scaling mismatch yields ' +
|
|
45
|
+
'verified:false). Supply fieldKey for a field-bound proof, omit it for a plain one.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
contractAddress: z.string().min(1).describe('AttestationVault contract address'),
|
|
48
|
+
payloadHash: hex64('payloadHash').describe('The attestation payload hash (64 hex)'),
|
|
49
|
+
predicate: z.enum(['lessOrEqual', 'greaterOrEqual']).describe('Predicate operator'),
|
|
50
|
+
threshold: scaledInt('threshold').describe('Scaled circuit integer threshold (same scaling the circuit hashed)'),
|
|
51
|
+
fieldKey: hex64('fieldKey').optional().describe('Optional field key (64 hex) for field-bound proofs'),
|
|
52
|
+
network: z.enum(['preview', 'preprod', 'mainnet']).optional()
|
|
53
|
+
.describe('Read from another network public indexer instead of the configured one'),
|
|
54
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
55
|
+
},
|
|
56
|
+
}, run(async (args) => client.callFunction('verifyPredicateState', {
|
|
57
|
+
contractAddress: args.contractAddress,
|
|
58
|
+
payloadHash: args.payloadHash,
|
|
59
|
+
fieldKey: args.fieldKey,
|
|
60
|
+
predicate: args.predicate,
|
|
61
|
+
threshold: int64(args.threshold),
|
|
62
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
63
|
+
network: args.network,
|
|
64
|
+
})));
|
|
65
|
+
server.registerTool('verify_predicate_attestation', {
|
|
66
|
+
description: 'Verify a server-issued predicate attestation by its NIGHTGATE row id (UUID). ' +
|
|
67
|
+
'Confirms the proving transaction succeeded, with a crawler-free live-state fallback. ' +
|
|
68
|
+
'Use verify_predicate instead when you only have on-chain coordinates.',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
predicateAttestationId: z.string().uuid().describe('PredicateAttestations row id'),
|
|
71
|
+
},
|
|
72
|
+
}, run(async (args) => client.callFunction('verifyPredicateAttestation', {
|
|
73
|
+
predicateAttestationId: args.predicateAttestationId,
|
|
74
|
+
})));
|
|
75
|
+
server.registerTool('verify_document', {
|
|
76
|
+
description: 'Verify an anchored document by its NIGHTGATE document id: compares the provided sha256 ' +
|
|
77
|
+
'against the anchored original and confirms the anchoring transaction, with a crawler-free ' +
|
|
78
|
+
'live-state fallback when contractAddress is supplied.',
|
|
79
|
+
inputSchema: {
|
|
80
|
+
documentId: z.string().uuid().describe('Documents row id'),
|
|
81
|
+
providedSha256: hex64('providedSha256').describe('sha256 of the document to check (64 hex)'),
|
|
82
|
+
contractAddress: z.string().optional().describe('Optional vault address, enables the crawler-free fallback'),
|
|
83
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
84
|
+
},
|
|
85
|
+
}, run(async (args) => client.callFunction('verifyDocument', {
|
|
86
|
+
documentId: args.documentId,
|
|
87
|
+
providedSha256: args.providedSha256,
|
|
88
|
+
contractAddress: args.contractAddress,
|
|
89
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
90
|
+
})));
|
|
91
|
+
server.registerTool('prepare_document_proof', {
|
|
92
|
+
description: 'Turn a structured document into everything the proof tools need: canonical JSON and its ' +
|
|
93
|
+
'payloadHash (what anchor_document anchors), a Merkle contentRoot over an ORDERED list of ' +
|
|
94
|
+
'up to 16 proof fields, and per-field inclusion paths ready for prove_field_predicate. ' +
|
|
95
|
+
'Keep the field order stable across anchor and proof: it is part of the tree identity. ' +
|
|
96
|
+
'Compute-only and synchronous, nothing is stored server-side. The returned fields carry ' +
|
|
97
|
+
'witness material (scaled values): treat as sensitive. Store canonicalDocument at your ' +
|
|
98
|
+
'storageRef; re-serializing with different key order will not re-hash equal.',
|
|
99
|
+
inputSchema: {
|
|
100
|
+
document: z.record(z.unknown())
|
|
101
|
+
.describe('The full document as a JSON object; all of it goes into payloadHash'),
|
|
102
|
+
proofFields: z.array(z.object({
|
|
103
|
+
field: z.string().min(1)
|
|
104
|
+
.describe('Dot-separated path into the document (e.g. invoice.total); a literal top-level key containing dots wins'),
|
|
105
|
+
scale: z.number().int().min(1).max(1_000_000_000).optional()
|
|
106
|
+
.describe('Value scale (default 1000: milli-units)'),
|
|
107
|
+
})).min(1).max(16).describe('ORDERED list of fields to make provable (leaf index = position)'),
|
|
108
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
109
|
+
},
|
|
110
|
+
}, run(async (args) => client.callAction('prepareDocumentProof', {
|
|
111
|
+
documentJson: JSON.stringify(args.document),
|
|
112
|
+
proofFieldsJson: JSON.stringify(args.proofFields),
|
|
113
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
114
|
+
})));
|
|
115
|
+
server.registerTool('attest_agent_output', {
|
|
116
|
+
description: 'Anchor agent-output provenance on the Midnight chain: "agent X produced output O from ' +
|
|
117
|
+
'input I at time T". Builds the canonical v1 envelope server-side, hashes it and anchors ' +
|
|
118
|
+
'it; the response returns the envelopeJson any third party can re-hash and check via ' +
|
|
119
|
+
'verify_attestation, without trusting this server. ' + POLL_HINT,
|
|
120
|
+
inputSchema: {
|
|
121
|
+
agentId: z.string().min(1).max(200).describe('Agent identity, ideally a registered grantee id'),
|
|
122
|
+
inputHash: hex64('inputHash').describe('Commitment to the agent input (64 hex)'),
|
|
123
|
+
outputHash: hex64('outputHash').describe('Commitment to the produced output (64 hex)'),
|
|
124
|
+
sessionId: z.string().uuid().describe('Wallet session id that signs and submits'),
|
|
125
|
+
contractAddress: z.string().min(1).describe('AttestationVault deployment'),
|
|
126
|
+
modelId: z.string().max(200).optional().describe('Optional model identifier'),
|
|
127
|
+
policyHash: hex64('policyHash').optional().describe('Optional commitment to the governing policy (64 hex)'),
|
|
128
|
+
producedAt: z.string().datetime().optional().describe('Optional ISO-8601 production time, defaults to now'),
|
|
129
|
+
storageRef: z.string().optional().describe('Where output/envelope live, defaults to agent-output://<agentId>'),
|
|
130
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
131
|
+
idempotencyKey: z.string().optional().describe('Dedupes retries'),
|
|
132
|
+
sponsorSessionId: z.string().uuid().optional().describe('Optional second session that pays the dust fee'),
|
|
133
|
+
},
|
|
134
|
+
}, run(async (args) => client.callAction('attestAgentOutput', {
|
|
135
|
+
agentId: args.agentId,
|
|
136
|
+
inputHash: args.inputHash,
|
|
137
|
+
outputHash: args.outputHash,
|
|
138
|
+
modelId: args.modelId,
|
|
139
|
+
policyHash: args.policyHash,
|
|
140
|
+
producedAt: args.producedAt,
|
|
141
|
+
storageRef: args.storageRef,
|
|
142
|
+
sessionId: args.sessionId,
|
|
143
|
+
contractAddress: args.contractAddress,
|
|
144
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
145
|
+
idempotencyKey: args.idempotencyKey,
|
|
146
|
+
sponsorSessionId: args.sponsorSessionId,
|
|
147
|
+
})));
|
|
148
|
+
server.registerTool('anchor_document', {
|
|
149
|
+
description: 'Anchor a document content hash on the Midnight chain via the AttestationVault attest ' +
|
|
150
|
+
'circuit. Commits only the sha256 + public metadata; you are responsible for storing the ' +
|
|
151
|
+
'actual bytes at storageRef. Attestation is first-come-first-served per hash. ' + POLL_HINT +
|
|
152
|
+
' Also returns documentId for verify_document.',
|
|
153
|
+
inputSchema: {
|
|
154
|
+
sha256: hex64('sha256').describe('sha256 of the document content (64 hex), becomes the on-chain payload hash'),
|
|
155
|
+
storageRef: z.string().min(1).describe('Where the bytes live, e.g. file://, s3://, ipfs://'),
|
|
156
|
+
sessionId: z.string().uuid().describe('Wallet session id that signs and submits'),
|
|
157
|
+
contractAddress: z.string().min(1).describe('AttestationVault deployment to anchor into'),
|
|
158
|
+
contentType: z.string().optional().describe('MIME type, informational'),
|
|
159
|
+
size: z.number().int().nonnegative().optional().describe('Content size in bytes, informational'),
|
|
160
|
+
metadata: z.record(z.unknown()).optional().describe('Public metadata object; its hash is anchored alongside'),
|
|
161
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
162
|
+
idempotencyKey: z.string().optional().describe('Dedupes retries of the same anchor request'),
|
|
163
|
+
sponsorSessionId: z.string().uuid().optional().describe('Optional second session that pays the dust fee'),
|
|
164
|
+
},
|
|
165
|
+
}, run(async (args) => client.callAction('anchorDocument', {
|
|
166
|
+
sha256: args.sha256,
|
|
167
|
+
contentType: args.contentType,
|
|
168
|
+
size: args.size,
|
|
169
|
+
storageRef: args.storageRef,
|
|
170
|
+
metadata: args.metadata === undefined ? undefined : JSON.stringify(args.metadata),
|
|
171
|
+
sessionId: args.sessionId,
|
|
172
|
+
contractAddress: args.contractAddress,
|
|
173
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
174
|
+
idempotencyKey: args.idempotencyKey,
|
|
175
|
+
sponsorSessionId: args.sponsorSessionId,
|
|
176
|
+
})));
|
|
177
|
+
server.registerTool('prove_field_predicate', {
|
|
178
|
+
description: 'Issue a zero-knowledge field-bound predicate proof: prove that a hidden field of an ' +
|
|
179
|
+
'anchored document satisfies "value <= threshold" or "value >= threshold" WITHOUT revealing ' +
|
|
180
|
+
'the value. Needs the depth-4 Merkle inclusion path of the field in the anchored content ' +
|
|
181
|
+
'root. value/threshold are scaled integers (decimal strings); the value is a witness and ' +
|
|
182
|
+
'never persisted. If contentRoot is supplied it is anchored first. A false predicate fails ' +
|
|
183
|
+
'at local proving time, nothing is submitted. ' + POLL_HINT,
|
|
184
|
+
inputSchema: {
|
|
185
|
+
payloadHash: hex64('payloadHash').describe('Attestation payload hash (64 hex)'),
|
|
186
|
+
fieldKey: hex64('fieldKey').describe('Canonical field id (64 hex, public)'),
|
|
187
|
+
value: z.string().regex(/^\d+$/, 'value must be a non-negative integer (decimal string)')
|
|
188
|
+
.describe('Scaled integer field value (witness only, never persisted)'),
|
|
189
|
+
siblings: merkleSiblings,
|
|
190
|
+
dirs: merkleDirs,
|
|
191
|
+
predicate: z.enum(['lessOrEqual', 'greaterOrEqual']).describe('Predicate operator'),
|
|
192
|
+
threshold: scaledInt('threshold').describe('Scaled integer threshold (same scaling as value)'),
|
|
193
|
+
sessionId: z.string().uuid().describe('Wallet session id that signs and submits'),
|
|
194
|
+
contractAddress: z.string().min(1).describe('AttestationVault deployment'),
|
|
195
|
+
contentRoot: hex64('contentRoot').optional().describe('Optional Merkle root (64 hex) to anchor first'),
|
|
196
|
+
unit: z.string().optional().describe('Informational unit, e.g. kWh'),
|
|
197
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
198
|
+
idempotencyKey: z.string().optional().describe('Dedupes retries'),
|
|
199
|
+
sponsorSessionId: z.string().uuid().optional().describe('Optional second session that pays the dust fee'),
|
|
200
|
+
},
|
|
201
|
+
}, run(async (args) => client.callAction('issueFieldPredicateAttestation', {
|
|
202
|
+
payloadHash: args.payloadHash,
|
|
203
|
+
fieldKey: args.fieldKey,
|
|
204
|
+
value: args.value,
|
|
205
|
+
contentRoot: args.contentRoot,
|
|
206
|
+
siblingsJson: JSON.stringify(args.siblings),
|
|
207
|
+
dirsJson: JSON.stringify(args.dirs),
|
|
208
|
+
predicate: args.predicate,
|
|
209
|
+
threshold: String(args.threshold),
|
|
210
|
+
unit: args.unit,
|
|
211
|
+
sessionId: args.sessionId,
|
|
212
|
+
contractAddress: args.contractAddress,
|
|
213
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
214
|
+
idempotencyKey: args.idempotencyKey,
|
|
215
|
+
sponsorSessionId: args.sponsorSessionId,
|
|
216
|
+
})));
|
|
217
|
+
server.registerTool('prove_field_predicates_batch', {
|
|
218
|
+
description: 'Batch variant of prove_field_predicate: prove up to 8 field-bound predicates on ONE ' +
|
|
219
|
+
'anchored document in ONE transaction (7 if contentRoot is supplied, since the anchor ' +
|
|
220
|
+
'occupies one call slot). Duplicate claim tuples are dropped server-side. One false ' +
|
|
221
|
+
'predicate aborts the whole batch at local proving time with zero on-chain effect. After ' +
|
|
222
|
+
'submission the chain can finalize a PARTIAL_SUCCESS subset; verify per claim via ' +
|
|
223
|
+
'verify_predicate_attestation instead of assuming all-or-nothing. ' + POLL_HINT,
|
|
224
|
+
inputSchema: {
|
|
225
|
+
payloadHash: hex64('payloadHash').describe('Shared attestation payload hash (64 hex)'),
|
|
226
|
+
claims: z.array(z.object({
|
|
227
|
+
fieldKey: hex64('fieldKey'),
|
|
228
|
+
value: z.string().regex(/^\d+$/, 'value must be a non-negative integer (decimal string)'),
|
|
229
|
+
siblings: merkleSiblings,
|
|
230
|
+
dirs: merkleDirs,
|
|
231
|
+
predicate: z.enum(['lessOrEqual', 'greaterOrEqual']),
|
|
232
|
+
threshold: scaledInt('threshold'),
|
|
233
|
+
unit: z.string().optional(),
|
|
234
|
+
})).min(1).max(8).describe('1-8 claims on the same payload hash'),
|
|
235
|
+
sessionId: z.string().uuid().describe('Wallet session id that signs and submits'),
|
|
236
|
+
contractAddress: z.string().min(1).describe('AttestationVault deployment'),
|
|
237
|
+
contentRoot: hex64('contentRoot').optional().describe('Optional Merkle root anchored as first call of the same batch'),
|
|
238
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
239
|
+
idempotencyKey: z.string().optional().describe('Dedupes retries'),
|
|
240
|
+
sponsorSessionId: z.string().uuid().optional().describe('Optional second session that pays the dust fee'),
|
|
241
|
+
},
|
|
242
|
+
}, run(async (args) => {
|
|
243
|
+
if (args.contentRoot && args.claims.length > 7) {
|
|
244
|
+
throw new Error('with contentRoot the anchor occupies one slot: max 7 claims');
|
|
245
|
+
}
|
|
246
|
+
return client.callAction('issueFieldPredicateAttestationBatch', {
|
|
247
|
+
payloadHash: args.payloadHash,
|
|
248
|
+
contentRoot: args.contentRoot,
|
|
249
|
+
claimsJson: JSON.stringify(args.claims.map((c) => ({ ...c, threshold: String(c.threshold) }))),
|
|
250
|
+
sessionId: args.sessionId,
|
|
251
|
+
contractAddress: args.contractAddress,
|
|
252
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
253
|
+
idempotencyKey: args.idempotencyKey,
|
|
254
|
+
sponsorSessionId: args.sponsorSessionId,
|
|
255
|
+
});
|
|
256
|
+
}));
|
|
257
|
+
server.registerTool('grant_disclosure', {
|
|
258
|
+
description: 'Grant a disclosure level for an attestation to a grantee identity, on-chain via the ' +
|
|
259
|
+
'AttestationVault. Attester-only: the transaction is rejected in-circuit unless the ' +
|
|
260
|
+
'session wallet is the original attester. level: 0=public, 1=legitimate-interest, ' +
|
|
261
|
+
'2=authority. ' + POLL_HINT,
|
|
262
|
+
inputSchema: {
|
|
263
|
+
payloadHash: hex64('payloadHash').describe('The attestation payload hash (64 hex)'),
|
|
264
|
+
grantee: hex64('grantee').describe('Grantee identity (64 hex Bytes<32>)'),
|
|
265
|
+
level: z.union([z.literal(0), z.literal(1), z.literal(2)])
|
|
266
|
+
.describe('0=public, 1=legitimate-interest, 2=authority'),
|
|
267
|
+
sessionId: z.string().uuid().describe('Wallet session id (must be the attester)'),
|
|
268
|
+
contractAddress: z.string().min(1).describe('AttestationVault deployment'),
|
|
269
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
270
|
+
idempotencyKey: z.string().optional().describe('Dedupes retries'),
|
|
271
|
+
sponsorSessionId: z.string().uuid().optional().describe('Optional second session that pays the dust fee'),
|
|
272
|
+
},
|
|
273
|
+
}, run(async (args) => client.callAction('grantDisclosure', {
|
|
274
|
+
payloadHash: args.payloadHash,
|
|
275
|
+
grantee: args.grantee,
|
|
276
|
+
level: args.level,
|
|
277
|
+
sessionId: args.sessionId,
|
|
278
|
+
contractAddress: args.contractAddress,
|
|
279
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
280
|
+
idempotencyKey: args.idempotencyKey,
|
|
281
|
+
sponsorSessionId: args.sponsorSessionId,
|
|
282
|
+
})));
|
|
283
|
+
server.registerTool('revoke_disclosure', {
|
|
284
|
+
description: 'Revoke a previously granted disclosure on-chain (removes the grantee entry). ' +
|
|
285
|
+
'Attester-only, enforced in-circuit. ' + POLL_HINT,
|
|
286
|
+
inputSchema: {
|
|
287
|
+
payloadHash: hex64('payloadHash').describe('The attestation payload hash (64 hex)'),
|
|
288
|
+
grantee: hex64('grantee').describe('Grantee identity (64 hex Bytes<32>)'),
|
|
289
|
+
sessionId: z.string().uuid().describe('Wallet session id (must be the attester)'),
|
|
290
|
+
contractAddress: z.string().min(1).describe('AttestationVault deployment'),
|
|
291
|
+
compiledArtifactRef: z.string().optional().describe("Contract artifact ref, defaults to 'attestation-vault'"),
|
|
292
|
+
idempotencyKey: z.string().optional().describe('Dedupes retries'),
|
|
293
|
+
sponsorSessionId: z.string().uuid().optional().describe('Optional second session that pays the dust fee'),
|
|
294
|
+
},
|
|
295
|
+
}, run(async (args) => client.callAction('revokeDisclosure', {
|
|
296
|
+
payloadHash: args.payloadHash,
|
|
297
|
+
grantee: args.grantee,
|
|
298
|
+
sessionId: args.sessionId,
|
|
299
|
+
contractAddress: args.contractAddress,
|
|
300
|
+
compiledArtifactRef: args.compiledArtifactRef,
|
|
301
|
+
idempotencyKey: args.idempotencyKey,
|
|
302
|
+
sponsorSessionId: args.sponsorSessionId,
|
|
303
|
+
})));
|
|
304
|
+
server.registerTool('get_job_status', {
|
|
305
|
+
description: 'Poll the status of an async NIGHTGATE job (all submit actions return a jobId). ' +
|
|
306
|
+
'status: pending | running | external_execution | submitted | reconciliation_required | ' +
|
|
307
|
+
'succeeded | failed. Poll every few seconds until succeeded or failed; result carries ' +
|
|
308
|
+
'the job outcome JSON, chainStatus tracks on-chain finalization independently.',
|
|
309
|
+
inputSchema: {
|
|
310
|
+
jobId: z.string().uuid().describe('Job id returned by a submit action'),
|
|
311
|
+
sessionId: z.string().uuid().describe('Wallet session id the job belongs to'),
|
|
312
|
+
},
|
|
313
|
+
}, run(async (args) => client.callAction('getJobStatus', {
|
|
314
|
+
jobId: args.jobId,
|
|
315
|
+
sessionId: args.sessionId,
|
|
316
|
+
})));
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Uniform handler wrapper: JSON success payloads, API errors reported as
|
|
320
|
+
* tool errors (isError) with status + OData code so the agent can react
|
|
321
|
+
* (e.g. 401 -> credentials, 429 -> back off) instead of crashing the call.
|
|
322
|
+
*/
|
|
323
|
+
function wrapHandler(_client) {
|
|
324
|
+
return function run(fn) {
|
|
325
|
+
return async (args) => {
|
|
326
|
+
try {
|
|
327
|
+
const result = await fn(args);
|
|
328
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
if (err instanceof NightgateApiError) {
|
|
332
|
+
const detail = { httpStatus: err.status, code: err.code ?? null, message: err.message };
|
|
333
|
+
return { content: [{ type: 'text', text: JSON.stringify(detail, null, 2) }], isError: true };
|
|
334
|
+
}
|
|
335
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
336
|
+
return { content: [{ type: 'text', text: message }], isError: true };
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAmB,MAAM,aAAa,CAAC;AAExE,MAAM,KAAK,GAAG,mBAAmB,CAAC;AAClC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAC7B,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,IAAI,4BAA4B,CAAC,CAAC;AAE/D,8EAA8E;AAC9E,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE,CACjC,CAAC,CAAC,KAAK,CAAC;IACN,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,kDAAkD,CAAC;IACpF,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;CAC/B,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,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YACvE,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@odatano/nightgate-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server exposing NIGHTGATE (Midnight blockchain attestation layer) to AI agents",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"nightgate-mcp": "dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"start": "node dist/index.js",
|
|
22
|
+
"integration": "npm run build && node scripts/integration-mcp.mjs",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/ODATANO/NIGHTGATE-MCP.git"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"mcp",
|
|
31
|
+
"model-context-protocol",
|
|
32
|
+
"midnight",
|
|
33
|
+
"blockchain",
|
|
34
|
+
"attestation",
|
|
35
|
+
"zero-knowledge",
|
|
36
|
+
"odata",
|
|
37
|
+
"sap-cap"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
41
|
+
"zod": "^3.23.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^20.0.0",
|
|
45
|
+
"typescript": "^5.5.0"
|
|
46
|
+
}
|
|
47
|
+
}
|