@rohan-protocol/mcp 0.7.0 β 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -12
- package/dist/firewall.d.ts.map +1 -1
- package/dist/firewall.js +3 -1
- package/dist/firewall.js.map +1 -1
- package/dist/gateway.d.ts +26 -0
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +10 -1
- package/dist/gateway.js.map +1 -1
- package/dist/identity.d.ts +3 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +38 -0
- package/dist/identity.js.map +1 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +47 -9
- package/dist/server.js.map +1 -1
- package/package.json +8 -4
- package/server.json +41 -25
- package/src/firewall.ts +5 -1
- package/src/gateway.ts +11 -1
- package/src/identity.ts +56 -0
- package/src/server.ts +53 -9
- package/tests/firewall.test.js +9 -0
- package/tests/gateway.test.js +27 -0
- package/tests/identity.test.js +32 -0
package/README.md
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
# @rohan-protocol/mcp (v0.
|
|
1
|
+
# @rohan-protocol/mcp (v0.8.0)
|
|
2
2
|
|
|
3
3
|
Official Model Context Protocol (MCP) server providing confidential state transitions, ledger inspection, and cryptographic audit tools for Claude Desktop, Cursor, Cline, and Gemini.
|
|
4
4
|
|
|
5
|
-
[](https://glama.ai/mcp/servers/rohan-protocol/sdk)
|
|
6
6
|
[](https://smithery.ai/servers/rohanprotocol/shield)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
## π οΈ The
|
|
10
|
+
## π οΈ The 4 MCP Tools
|
|
11
11
|
|
|
12
|
-
### 1. `
|
|
12
|
+
### 1. `rohan_execute_handshake` (Write / Settlement)
|
|
13
13
|
Executes a confidential state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAMβnever exposed on-chain or in model logs.
|
|
14
|
-
* **Arguments:** `agentId` (string, required), `actionSummary` (string), `confidentialPayload` (object).
|
|
14
|
+
* **Arguments:** `agentId` (string, required), `actionSummary` (string), `confidentialPayload` (object). The legacy `rohan_zk_handshake` name remains accepted.
|
|
15
15
|
|
|
16
|
-
### 2. `
|
|
17
|
-
Cryptographically audits and verifies whether a plaintext payload matches an on-chain commitment using RFC 8785 JSON Canonicalization and SHA-256. Zero gas cost, executes instantly in local RAM.
|
|
18
|
-
* **Arguments:** `payload` (object, required), `expectedDigest` (string, required β accepts raw hex, `sha256:`, or `0x` prefixes).
|
|
19
|
-
|
|
20
|
-
### 3. `rohan_get_ledger_state` (Read / State Inspection)
|
|
16
|
+
### 2. `rohan_get_ledger_state` (Read / State Inspection)
|
|
21
17
|
Reads the current anchored state of the Rohan Protocol smart contract on Midnight Preprod L1. Returns state root, block height, and last mined transaction hash from memory cache.
|
|
22
18
|
* **Arguments:** None.
|
|
23
19
|
|
|
20
|
+
### 3. `rohan_get_transaction_history` (Read / Settlement History)
|
|
21
|
+
Lists recent settlement transactions and receipts recorded by the relayer.
|
|
22
|
+
* **Arguments:** `limit` (integer, optional β defaults to 10, maximum 50).
|
|
23
|
+
|
|
24
|
+
### 4. `rohan_verify_commitment` (Audit / Verify)
|
|
25
|
+
Verifies a plaintext confidential payload against its canonical SHA-256 digest in local memory.
|
|
26
|
+
* **Arguments:** `payload` (object, required), `expectedDigest` (string, required β accepts raw hex, `sha256:`, or `0x` prefixes). Supply the inner payload digest referenced in `actionSummary`, not the timestamp-salted outer on-chain `intentHash`.
|
|
27
|
+
|
|
24
28
|
---
|
|
25
29
|
|
|
26
30
|
## π Setup & Configuration
|
|
@@ -33,7 +37,7 @@ Add this to your `claude_desktop_config.json`:
|
|
|
33
37
|
"mcpServers": {
|
|
34
38
|
"rohan-shield": {
|
|
35
39
|
"command": "npx",
|
|
36
|
-
"args": ["-y", "@rohan-protocol/mcp@0.
|
|
40
|
+
"args": ["-y", "@rohan-protocol/mcp@0.8.0"],
|
|
37
41
|
"env": {
|
|
38
42
|
"ROHAN_API_KEY": ""
|
|
39
43
|
}
|
|
@@ -47,13 +51,28 @@ Add this to your `claude_desktop_config.json`:
|
|
|
47
51
|
2. Click **Add New MCP Server**:
|
|
48
52
|
* **Name:** `rohan-shield`
|
|
49
53
|
* **Type:** `command`
|
|
50
|
-
* **Command:** `npx -y @rohan-protocol/mcp@0.
|
|
54
|
+
* **Command:** `npx -y @rohan-protocol/mcp@0.8.0`
|
|
51
55
|
|
|
52
56
|
### Option C: Remote MCP (Smithery / Cloud Agents)
|
|
53
57
|
Connect directly to the hosted endpoint:
|
|
54
58
|
* **Server Card:** `https://api.rohanprotocol.network/.well-known/mcp/server-card.json`
|
|
55
59
|
* **JSON-RPC Endpoint:** `https://api.rohanprotocol.network/mcp`
|
|
56
60
|
|
|
61
|
+
### Optional local agent signing (V-08)
|
|
62
|
+
For a local stdio server, set `ROHAN_AGENT_PRIVATE_KEY` in the MCP process
|
|
63
|
+
environment to a 32-byte Ed25519 seed encoded as exactly 64 hexadecimal
|
|
64
|
+
characters (an optional `0x` prefix is accepted). The SDK derives the matching
|
|
65
|
+
public key and `did:key` from that seed; handshake requests are then signed
|
|
66
|
+
locally. If the variable is unset, the client remains unsigned. If it is set
|
|
67
|
+
but malformed or unusable, startup fails instead of silently falling back to
|
|
68
|
+
unsigned requests.
|
|
69
|
+
|
|
70
|
+
Keep the seed in the MCP host's secret store or protected process environment.
|
|
71
|
+
Never put it in tool arguments, prompts, source control, or logs. JavaScript
|
|
72
|
+
and WebCrypto do not guarantee erasure of every in-memory key copy. The `did:key`
|
|
73
|
+
proves control of a key, not a real-world identity, and a relayer must enforce
|
|
74
|
+
signature verification for signed mode to provide server-side authentication.
|
|
75
|
+
|
|
57
76
|
---
|
|
58
77
|
|
|
59
78
|
## π License
|
package/dist/firewall.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firewall.d.ts","sourceRoot":"","sources":["../src/firewall.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CACmI;IAE1K,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO;
|
|
1
|
+
{"version":3,"file":"firewall.d.ts","sourceRoot":"","sources":["../src/firewall.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CACmI;IAE1K,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO;CA0BlD"}
|
package/dist/firewall.js
CHANGED
|
@@ -4,7 +4,9 @@ export class SemanticFirewall {
|
|
|
4
4
|
if (!intent.agentId || typeof intent.agentId !== 'string' || intent.agentId.length > 128) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
|
-
if (!intent.action || (intent.action !== 'rohan_zk_handshake' &&
|
|
7
|
+
if (!intent.action || (intent.action !== 'rohan_zk_handshake' &&
|
|
8
|
+
intent.action !== 'rohan_execute_handshake' &&
|
|
9
|
+
intent.action !== 'verify_batched_handshakes')) {
|
|
8
10
|
return false;
|
|
9
11
|
}
|
|
10
12
|
if (!intent.payload || typeof intent.payload !== 'object') {
|
package/dist/firewall.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firewall.js","sourceRoot":"","sources":["../src/firewall.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,gBAAgB;IAC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AC,EAAE,CAAC;YAC1C,OAAO,KAAK,CAAC,CAAC,qCAAqC;QACrD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC"}
|
package/dist/gateway.d.ts
CHANGED
|
@@ -40,5 +40,31 @@ export declare class RohanMcpGateway {
|
|
|
40
40
|
};
|
|
41
41
|
execute: (params: any) => Promise<import("@rohan-protocol/sdk").HandshakeReceipt>;
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Generates the legacy tool name for integrations that have not migrated yet.
|
|
45
|
+
*/
|
|
46
|
+
asLegacyAdkTool(): {
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
parameters: {
|
|
50
|
+
type: string;
|
|
51
|
+
properties: {
|
|
52
|
+
agentId: {
|
|
53
|
+
type: string;
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
intent: {
|
|
57
|
+
type: string;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
counterpartyId: {
|
|
61
|
+
type: string;
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
required: string[];
|
|
66
|
+
};
|
|
67
|
+
execute: (params: any) => Promise<import("@rohan-protocol/sdk").HandshakeReceipt>;
|
|
68
|
+
};
|
|
43
69
|
}
|
|
44
70
|
//# sourceMappingURL=gateway.d.ts.map
|
package/dist/gateway.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,aAAa,EAAE,kBAAkB,CAAC;gBAEtC,OAAO,GAAE,sBAA2B;IAShD;;OAEG;IACH,SAAS;;;;;;;;;;;;;;;;;;;;;0BAamB,GAAG;;
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,aAAa,EAAE,kBAAkB,CAAC;gBAEtC,OAAO,GAAE,sBAA2B;IAShD;;OAEG;IACH,SAAS;;;;;;;;;;;;;;;;;;;;;0BAamB,GAAG;;IAM/B;;OAEG;IACH,eAAe;;;;;;;;;;;;;;;;;;;;;0BATa,GAAG;;CAehC"}
|
package/dist/gateway.js
CHANGED
|
@@ -20,7 +20,7 @@ export class RohanMcpGateway {
|
|
|
20
20
|
*/
|
|
21
21
|
asAdkTool() {
|
|
22
22
|
return {
|
|
23
|
-
name: '
|
|
23
|
+
name: 'rohan_execute_handshake',
|
|
24
24
|
description: 'Executes a zero-knowledge verifiable handshake proof on Midnight Network with zero plaintext leaks.',
|
|
25
25
|
parameters: {
|
|
26
26
|
type: 'object',
|
|
@@ -36,5 +36,14 @@ export class RohanMcpGateway {
|
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Generates the legacy tool name for integrations that have not migrated yet.
|
|
41
|
+
*/
|
|
42
|
+
asLegacyAdkTool() {
|
|
43
|
+
return {
|
|
44
|
+
...this.asAdkTool(),
|
|
45
|
+
name: 'rohan_zk_handshake',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
39
48
|
}
|
|
40
49
|
//# sourceMappingURL=gateway.js.map
|
package/dist/gateway.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASzD;;;;GAIG;AACH,MAAM,OAAO,eAAe;IACV,SAAS,CAAS;IAClB,aAAa,CAAqB;IAElD,YAAY,UAAkC,EAAE;QAC9C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAC;QACxD,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,CAAC;YAC1C,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,wCAAwC;YAC1E,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,kEAAkE;YAC9G,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO;YACL,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASzD;;;;GAIG;AACH,MAAM,OAAO,eAAe;IACV,SAAS,CAAS;IAClB,aAAa,CAAqB;IAElD,YAAY,UAAkC,EAAE;QAC9C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAC;QACxD,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,CAAC;YAC1C,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,wCAAwC;YAC1E,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,kEAAkE;YAC9G,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO;YACL,IAAI,EAAE,yBAAyB;YAC/B,WAAW,EAAE,qGAAqG;YAClH,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE;oBAC3F,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6CAA6C,EAAE;oBACtF,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qCAAqC,EAAE;iBACvF;gBACD,QAAQ,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;aAChC;YACD,OAAO,EAAE,KAAK,EAAE,MAAW,EAAE,EAAE;gBAC7B,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAC1D,CAAC;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO;YACL,GAAG,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,EAAE,oBAAoB;SAC3B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAM7B,wBAAsB,oBAAoB,CACxC,gBAAgB,qBAAsC,GACrD,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CA2ClC"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { webcrypto } from 'node:crypto';
|
|
2
|
+
import { InMemoryEd25519Signer, } from '@rohan-protocol/sdk';
|
|
3
|
+
const ED25519_PKCS8_PREFIX = new Uint8Array([
|
|
4
|
+
0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,
|
|
5
|
+
]);
|
|
6
|
+
export async function resolveSignerFromEnv(rawPrivateKeyHex = process.env.ROHAN_AGENT_PRIVATE_KEY) {
|
|
7
|
+
if (rawPrivateKeyHex === undefined || rawPrivateKeyHex.trim() === '') {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const normalizedHex = rawPrivateKeyHex.trim().replace(/^0x/i, '');
|
|
11
|
+
if (!/^[0-9a-f]{64}$/i.test(normalizedHex)) {
|
|
12
|
+
throw new Error('ROHAN_AGENT_PRIVATE_KEY must be exactly 32 bytes encoded as 64 hex characters.');
|
|
13
|
+
}
|
|
14
|
+
const privateKey = new Uint8Array(Buffer.from(normalizedHex, 'hex'));
|
|
15
|
+
const pkcs8Key = new Uint8Array(ED25519_PKCS8_PREFIX.length + privateKey.length);
|
|
16
|
+
pkcs8Key.set(ED25519_PKCS8_PREFIX);
|
|
17
|
+
pkcs8Key.set(privateKey, ED25519_PKCS8_PREFIX.length);
|
|
18
|
+
try {
|
|
19
|
+
const cryptoKey = await webcrypto.subtle.importKey('pkcs8', pkcs8Key, { name: 'Ed25519' }, true, ['sign']);
|
|
20
|
+
const jwk = await webcrypto.subtle.exportKey('jwk', cryptoKey);
|
|
21
|
+
if (!jwk.x) {
|
|
22
|
+
throw new Error('Could not derive the Ed25519 public key from ROHAN_AGENT_PRIVATE_KEY.');
|
|
23
|
+
}
|
|
24
|
+
const publicKey = new Uint8Array(Buffer.from(jwk.x, 'base64url'));
|
|
25
|
+
if (publicKey.length !== 32) {
|
|
26
|
+
throw new Error('Derived Ed25519 public key has an invalid length.');
|
|
27
|
+
}
|
|
28
|
+
return new InMemoryEd25519Signer(publicKey, privateKey);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new Error('Failed to initialize the Ed25519 signer from ROHAN_AGENT_PRIVATE_KEY.', { cause: error });
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
privateKey.fill(0);
|
|
35
|
+
pkcs8Key.fill(0);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,oBAAoB,GAAG,IAAI,UAAU,CAAC;IAC1C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CAC/F,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB;IAEtD,IAAI,gBAAgB,KAAK,SAAS,IAAI,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,oBAAoB,CAAC,MAAM,GAAG,UAAU,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
|
58
58
|
};
|
|
59
|
+
export declare const ROHAN_HISTORY_TOOL_SCHEMA: {
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: string;
|
|
64
|
+
properties: {
|
|
65
|
+
limit: {
|
|
66
|
+
type: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
59
72
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AA2CA,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BvC,CAAC;AAGF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;CAmBpC,CAAC;AAGF,eAAO,MAAM,8BAA8B;;;;;;;CAQ1C,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;CAarC,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -5,17 +5,23 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
5
5
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import { SemanticFirewall } from './firewall.js';
|
|
7
7
|
import { RohanClient, sealActionIntent, canonicalizeJson } from '@rohan-protocol/sdk';
|
|
8
|
+
import { resolveSignerFromEnv } from './identity.js';
|
|
8
9
|
const CONTRACT_ADDRESS = process.env.ROHAN_CONTRACT_ADDRESS || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
|
|
9
10
|
const RELAYER_URL = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
|
|
10
11
|
const API_KEY = process.env.ROHAN_API_KEY || '';
|
|
12
|
+
const configuredSigner = await resolveSignerFromEnv();
|
|
13
|
+
if (configuredSigner) {
|
|
14
|
+
console.error(`π‘οΈ [MCP V-08] Sovereign Agent Signer armed: ${configuredSigner.did}`);
|
|
15
|
+
}
|
|
11
16
|
const rohanClient = new RohanClient({
|
|
12
17
|
contractAddress: CONTRACT_ADDRESS,
|
|
13
18
|
relayerUrl: RELAYER_URL,
|
|
14
19
|
apiKey: API_KEY,
|
|
20
|
+
signer: configuredSigner,
|
|
15
21
|
});
|
|
16
22
|
const server = new Server({
|
|
17
23
|
name: 'rohan-protocol-mcp',
|
|
18
|
-
version: '0.
|
|
24
|
+
version: '0.8.0',
|
|
19
25
|
}, {
|
|
20
26
|
capabilities: {
|
|
21
27
|
tools: {},
|
|
@@ -23,7 +29,7 @@ const server = new Server({
|
|
|
23
29
|
});
|
|
24
30
|
// ββ Tool 1 Schema: Write / Settlement βββββββββββββββββββββββββββββββββββββββ
|
|
25
31
|
export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
|
|
26
|
-
name: '
|
|
32
|
+
name: 'rohan_execute_handshake',
|
|
27
33
|
description: 'Executes a confidential zero-knowledge state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAMβnever exposed on-chain or in model logs.',
|
|
28
34
|
inputSchema: {
|
|
29
35
|
type: 'object',
|
|
@@ -55,7 +61,7 @@ export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
|
|
|
55
61
|
// ββ Tool 2 Schema: Audit / In-Memory Verification βββββββββββββββββββββββββββ
|
|
56
62
|
export const ROHAN_VERIFY_TOOL_SCHEMA = {
|
|
57
63
|
name: 'rohan_verify_commitment',
|
|
58
|
-
description: '
|
|
64
|
+
description: 'Verifies a plaintext confidential payload against its SHA-256 digest using RFC 8785 JSON Canonicalization. Supply the inner payload digest, not the outer on-chain intentHash. Zero gas cost; runs in local memory.',
|
|
59
65
|
inputSchema: {
|
|
60
66
|
type: 'object',
|
|
61
67
|
properties: {
|
|
@@ -66,7 +72,7 @@ export const ROHAN_VERIFY_TOOL_SCHEMA = {
|
|
|
66
72
|
expectedDigest: {
|
|
67
73
|
type: 'string',
|
|
68
74
|
pattern: '^(?:sha256:|0x)?[0-9a-fA-F]{64}$',
|
|
69
|
-
description: 'The
|
|
75
|
+
description: 'The expected SHA-256 digest of the canonicalized confidential payload (the inner payload digest referenced as digest: sha256:<hash> in actionSummary), not the outer timestamp-salted on-chain intentHash. Accepts raw hex, 0x, or sha256: prefixes.',
|
|
70
76
|
},
|
|
71
77
|
},
|
|
72
78
|
required: ['payload', 'expectedDigest'],
|
|
@@ -81,12 +87,26 @@ export const ROHAN_LEDGER_STATE_TOOL_SCHEMA = {
|
|
|
81
87
|
properties: {},
|
|
82
88
|
},
|
|
83
89
|
};
|
|
90
|
+
export const ROHAN_HISTORY_TOOL_SCHEMA = {
|
|
91
|
+
name: 'rohan_get_transaction_history',
|
|
92
|
+
description: 'Lists historical settlement transactions and receipts anchored on Midnight Preprod L1.',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
limit: {
|
|
97
|
+
type: 'integer',
|
|
98
|
+
description: 'Maximum number of historical transactions to return (default: 10, max: 50).',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
84
103
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
85
104
|
return {
|
|
86
105
|
tools: [
|
|
87
106
|
ROHAN_HANDSHAKE_TOOL_SCHEMA,
|
|
88
|
-
ROHAN_VERIFY_TOOL_SCHEMA,
|
|
89
107
|
ROHAN_LEDGER_STATE_TOOL_SCHEMA,
|
|
108
|
+
ROHAN_HISTORY_TOOL_SCHEMA,
|
|
109
|
+
ROHAN_VERIFY_TOOL_SCHEMA,
|
|
90
110
|
],
|
|
91
111
|
};
|
|
92
112
|
});
|
|
@@ -101,14 +121,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
101
121
|
}
|
|
102
122
|
const args = rawArgs;
|
|
103
123
|
// ββ Tool 1: rohan_zk_handshake ββββββββββββββββββββββββββββββββββββββββββββ
|
|
104
|
-
if (toolName === 'rohan_zk_handshake') {
|
|
124
|
+
if (toolName === 'rohan_execute_handshake' || toolName === 'rohan_zk_handshake') {
|
|
105
125
|
const actionLabel = args.actionSummary || args.intent;
|
|
106
126
|
if (!actionLabel) {
|
|
107
127
|
throw new Error('Invalid arguments: Either actionSummary or intent is required.');
|
|
108
128
|
}
|
|
109
129
|
const isValid = SemanticFirewall.validate({
|
|
110
130
|
agentId: args.agentId,
|
|
111
|
-
action: '
|
|
131
|
+
action: 'rohan_execute_handshake',
|
|
112
132
|
payload: args,
|
|
113
133
|
});
|
|
114
134
|
if (!isValid) {
|
|
@@ -176,7 +196,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
176
196
|
// Single Source of Truth: Canonicalization via @rohan-protocol/sdk
|
|
177
197
|
const canonicalPayload = canonicalizeJson(args.payload);
|
|
178
198
|
const computedDigest = crypto.createHash('sha256').update(canonicalPayload, 'utf8').digest('hex').toLowerCase();
|
|
179
|
-
const match = computedDigest
|
|
199
|
+
const match = crypto.timingSafeEqual(Buffer.from(computedDigest, 'hex'), Buffer.from(normalizedExpected, 'hex'));
|
|
180
200
|
return {
|
|
181
201
|
content: [{
|
|
182
202
|
type: 'text',
|
|
@@ -229,12 +249,30 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
229
249
|
};
|
|
230
250
|
}
|
|
231
251
|
}
|
|
252
|
+
if (toolName === 'rohan_get_transaction_history') {
|
|
253
|
+
try {
|
|
254
|
+
const rawLimit = Number(args.limit) || 10;
|
|
255
|
+
const history = await rohanClient.getTransactionHistory(rawLimit);
|
|
256
|
+
return {
|
|
257
|
+
content: [{
|
|
258
|
+
type: 'text',
|
|
259
|
+
text: JSON.stringify({ status: 'success', ...history }, null, 2),
|
|
260
|
+
}],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
return {
|
|
265
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Failed to fetch transaction history' }) }],
|
|
266
|
+
isError: true,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
232
270
|
throw new Error(`Unknown tool: ${toolName}`);
|
|
233
271
|
});
|
|
234
272
|
async function run() {
|
|
235
273
|
const transport = new StdioServerTransport();
|
|
236
274
|
await server.connect(transport);
|
|
237
|
-
console.error('π‘οΈ Rohan Protocol MCP Server running via stdio (v0.
|
|
275
|
+
console.error('π‘οΈ Rohan Protocol MCP Server running via stdio (v0.8.0)...');
|
|
238
276
|
}
|
|
239
277
|
run().catch((error) => {
|
|
240
278
|
console.error('Fatal MCP server error:', error);
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAGA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAGA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACv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qB,CAAC,QAAQ,CAAC,CAAC;YAElE,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;qBACjE,CAAC;aACH,CAAC;QACJ,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,IAAI,qCAAqC,EAAE,CAAC,EAAE,CAAC;gBAClI,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;AAC/E,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACpB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rohan-protocol/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"mcpName": "io.github.rohan-protocol/mcp",
|
|
4
5
|
"description": "Model Context Protocol (MCP) Gateway for Rohan Protocol ZK-Handshakes",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
@@ -21,12 +22,15 @@
|
|
|
21
22
|
"test": "node --test tests/*.test.js"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@modelcontextprotocol/sdk": "^1.32.
|
|
25
|
-
"@rohan-protocol/sdk": "^0.
|
|
25
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
26
|
+
"@rohan-protocol/sdk": "^0.8.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/node": "^22.0.0",
|
|
29
30
|
"typescript": "^5.5.0"
|
|
30
31
|
},
|
|
31
|
-
"bin":
|
|
32
|
+
"bin": {
|
|
33
|
+
"rohan-shield": "./dist/server.js",
|
|
34
|
+
"mcp": "./dist/server.js"
|
|
35
|
+
}
|
|
32
36
|
}
|
package/server.json
CHANGED
|
@@ -1,30 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://static.modelcontextprotocol.io/
|
|
3
|
-
"name": "rohan-protocol/mcp",
|
|
4
|
-
"
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.rohan-protocol/mcp",
|
|
4
|
+
"title": "Rohan Protocol MCP",
|
|
5
5
|
"description": "Stateless zero-knowledge trust gateway and WebMCP shield for AI agents on Midnight.",
|
|
6
|
+
"version": "0.8.0",
|
|
7
|
+
"websiteUrl": "https://rohanprotocol.network",
|
|
6
8
|
"repository": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
+
"url": "https://github.com/rohan-protocol/sdk",
|
|
10
|
+
"source": "github",
|
|
11
|
+
"subfolder": "packages/mcp"
|
|
9
12
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"identifier": "@rohan-protocol/mcp",
|
|
17
|
+
"version": "0.8.0",
|
|
18
|
+
"transport": {
|
|
19
|
+
"type": "stdio"
|
|
20
|
+
},
|
|
21
|
+
"environmentVariables": [
|
|
22
|
+
{
|
|
23
|
+
"name": "ROHAN_AGENT_PRIVATE_KEY",
|
|
24
|
+
"description": "Optional 32-byte Ed25519 seed as 64 hex characters for local stdio request signing. Keep it in a secret store; never provide it as a tool argument.",
|
|
25
|
+
"default": "",
|
|
26
|
+
"isRequired": false,
|
|
27
|
+
"format": "string"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "ROHAN_CONTRACT_ADDRESS",
|
|
31
|
+
"description": "Midnight Preprod Contract Address for Rohan Trust Gateway",
|
|
32
|
+
"default": "585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e",
|
|
33
|
+
"isRequired": false,
|
|
34
|
+
"format": "string"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "ROHAN_RELAYER_URL",
|
|
38
|
+
"description": "Rohan Relayer API URL",
|
|
39
|
+
"default": "https://api.rohanprotocol.network/api/v1/handshake",
|
|
40
|
+
"isRequired": false,
|
|
41
|
+
"format": "string"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
]
|
|
30
46
|
}
|
package/src/firewall.ts
CHANGED
|
@@ -12,7 +12,11 @@ export class SemanticFirewall {
|
|
|
12
12
|
if (!intent.agentId || typeof intent.agentId !== 'string' || intent.agentId.length > 128) {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
|
-
if (!intent.action || (
|
|
15
|
+
if (!intent.action || (
|
|
16
|
+
intent.action !== 'rohan_zk_handshake' &&
|
|
17
|
+
intent.action !== 'rohan_execute_handshake' &&
|
|
18
|
+
intent.action !== 'verify_batched_handshakes'
|
|
19
|
+
)) {
|
|
16
20
|
return false;
|
|
17
21
|
}
|
|
18
22
|
if (!intent.payload || typeof intent.payload !== 'object') {
|
package/src/gateway.ts
CHANGED
|
@@ -30,7 +30,7 @@ export class RohanMcpGateway {
|
|
|
30
30
|
*/
|
|
31
31
|
asAdkTool() {
|
|
32
32
|
return {
|
|
33
|
-
name: '
|
|
33
|
+
name: 'rohan_execute_handshake',
|
|
34
34
|
description: 'Executes a zero-knowledge verifiable handshake proof on Midnight Network with zero plaintext leaks.',
|
|
35
35
|
parameters: {
|
|
36
36
|
type: 'object',
|
|
@@ -46,4 +46,14 @@ export class RohanMcpGateway {
|
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Generates the legacy tool name for integrations that have not migrated yet.
|
|
52
|
+
*/
|
|
53
|
+
asLegacyAdkTool() {
|
|
54
|
+
return {
|
|
55
|
+
...this.asAdkTool(),
|
|
56
|
+
name: 'rohan_zk_handshake',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
49
59
|
}
|
package/src/identity.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { webcrypto } from 'node:crypto';
|
|
2
|
+
import {
|
|
3
|
+
InMemoryEd25519Signer,
|
|
4
|
+
type AgentSigner,
|
|
5
|
+
} from '@rohan-protocol/sdk';
|
|
6
|
+
|
|
7
|
+
const ED25519_PKCS8_PREFIX = new Uint8Array([
|
|
8
|
+
0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
export async function resolveSignerFromEnv(
|
|
12
|
+
rawPrivateKeyHex = process.env.ROHAN_AGENT_PRIVATE_KEY
|
|
13
|
+
): Promise<AgentSigner | undefined> {
|
|
14
|
+
if (rawPrivateKeyHex === undefined || rawPrivateKeyHex.trim() === '') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const normalizedHex = rawPrivateKeyHex.trim().replace(/^0x/i, '');
|
|
19
|
+
if (!/^[0-9a-f]{64}$/i.test(normalizedHex)) {
|
|
20
|
+
throw new Error('ROHAN_AGENT_PRIVATE_KEY must be exactly 32 bytes encoded as 64 hex characters.');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const privateKey = new Uint8Array(Buffer.from(normalizedHex, 'hex'));
|
|
24
|
+
const pkcs8Key = new Uint8Array(ED25519_PKCS8_PREFIX.length + privateKey.length);
|
|
25
|
+
pkcs8Key.set(ED25519_PKCS8_PREFIX);
|
|
26
|
+
pkcs8Key.set(privateKey, ED25519_PKCS8_PREFIX.length);
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const cryptoKey = await webcrypto.subtle.importKey(
|
|
30
|
+
'pkcs8',
|
|
31
|
+
pkcs8Key,
|
|
32
|
+
{ name: 'Ed25519' },
|
|
33
|
+
true,
|
|
34
|
+
['sign']
|
|
35
|
+
);
|
|
36
|
+
const jwk = await webcrypto.subtle.exportKey('jwk', cryptoKey);
|
|
37
|
+
if (!jwk.x) {
|
|
38
|
+
throw new Error('Could not derive the Ed25519 public key from ROHAN_AGENT_PRIVATE_KEY.');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const publicKey = new Uint8Array(Buffer.from(jwk.x, 'base64url'));
|
|
42
|
+
if (publicKey.length !== 32) {
|
|
43
|
+
throw new Error('Derived Ed25519 public key has an invalid length.');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return new InMemoryEd25519Signer(publicKey, privateKey);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
'Failed to initialize the Ed25519 signer from ROHAN_AGENT_PRIVATE_KEY.',
|
|
50
|
+
{ cause: error }
|
|
51
|
+
);
|
|
52
|
+
} finally {
|
|
53
|
+
privateKey.fill(0);
|
|
54
|
+
pkcs8Key.fill(0);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -11,21 +11,27 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import { SemanticFirewall } from './firewall.js';
|
|
13
13
|
import { RohanClient, sealActionIntent, canonicalizeJson } from '@rohan-protocol/sdk';
|
|
14
|
+
import { resolveSignerFromEnv } from './identity.js';
|
|
14
15
|
|
|
15
16
|
const CONTRACT_ADDRESS = process.env.ROHAN_CONTRACT_ADDRESS || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
|
|
16
17
|
const RELAYER_URL = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
|
|
17
18
|
const API_KEY = process.env.ROHAN_API_KEY || '';
|
|
19
|
+
const configuredSigner = await resolveSignerFromEnv();
|
|
20
|
+
if (configuredSigner) {
|
|
21
|
+
console.error(`π‘οΈ [MCP V-08] Sovereign Agent Signer armed: ${configuredSigner.did}`);
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
const rohanClient = new RohanClient({
|
|
20
25
|
contractAddress: CONTRACT_ADDRESS,
|
|
21
26
|
relayerUrl: RELAYER_URL,
|
|
22
27
|
apiKey: API_KEY,
|
|
28
|
+
signer: configuredSigner,
|
|
23
29
|
});
|
|
24
30
|
|
|
25
31
|
const server = new Server(
|
|
26
32
|
{
|
|
27
33
|
name: 'rohan-protocol-mcp',
|
|
28
|
-
version: '0.
|
|
34
|
+
version: '0.8.0',
|
|
29
35
|
},
|
|
30
36
|
{
|
|
31
37
|
capabilities: {
|
|
@@ -36,7 +42,7 @@ const server = new Server(
|
|
|
36
42
|
|
|
37
43
|
// ββ Tool 1 Schema: Write / Settlement βββββββββββββββββββββββββββββββββββββββ
|
|
38
44
|
export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
|
|
39
|
-
name: '
|
|
45
|
+
name: 'rohan_execute_handshake',
|
|
40
46
|
description:
|
|
41
47
|
'Executes a confidential zero-knowledge state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAMβnever exposed on-chain or in model logs.',
|
|
42
48
|
inputSchema: {
|
|
@@ -71,7 +77,7 @@ export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
|
|
|
71
77
|
export const ROHAN_VERIFY_TOOL_SCHEMA = {
|
|
72
78
|
name: 'rohan_verify_commitment',
|
|
73
79
|
description:
|
|
74
|
-
'
|
|
80
|
+
'Verifies a plaintext confidential payload against its SHA-256 digest using RFC 8785 JSON Canonicalization. Supply the inner payload digest, not the outer on-chain intentHash. Zero gas cost; runs in local memory.',
|
|
75
81
|
inputSchema: {
|
|
76
82
|
type: 'object',
|
|
77
83
|
properties: {
|
|
@@ -82,7 +88,7 @@ export const ROHAN_VERIFY_TOOL_SCHEMA = {
|
|
|
82
88
|
expectedDigest: {
|
|
83
89
|
type: 'string',
|
|
84
90
|
pattern: '^(?:sha256:|0x)?[0-9a-fA-F]{64}$',
|
|
85
|
-
description: 'The
|
|
91
|
+
description: 'The expected SHA-256 digest of the canonicalized confidential payload (the inner payload digest referenced as digest: sha256:<hash> in actionSummary), not the outer timestamp-salted on-chain intentHash. Accepts raw hex, 0x, or sha256: prefixes.',
|
|
86
92
|
},
|
|
87
93
|
},
|
|
88
94
|
required: ['payload', 'expectedDigest'],
|
|
@@ -100,12 +106,28 @@ export const ROHAN_LEDGER_STATE_TOOL_SCHEMA = {
|
|
|
100
106
|
},
|
|
101
107
|
};
|
|
102
108
|
|
|
109
|
+
export const ROHAN_HISTORY_TOOL_SCHEMA = {
|
|
110
|
+
name: 'rohan_get_transaction_history',
|
|
111
|
+
description:
|
|
112
|
+
'Lists historical settlement transactions and receipts anchored on Midnight Preprod L1.',
|
|
113
|
+
inputSchema: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
limit: {
|
|
117
|
+
type: 'integer',
|
|
118
|
+
description: 'Maximum number of historical transactions to return (default: 10, max: 50).',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
103
124
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
104
125
|
return {
|
|
105
126
|
tools: [
|
|
106
127
|
ROHAN_HANDSHAKE_TOOL_SCHEMA,
|
|
107
|
-
ROHAN_VERIFY_TOOL_SCHEMA,
|
|
108
128
|
ROHAN_LEDGER_STATE_TOOL_SCHEMA,
|
|
129
|
+
ROHAN_HISTORY_TOOL_SCHEMA,
|
|
130
|
+
ROHAN_VERIFY_TOOL_SCHEMA,
|
|
109
131
|
],
|
|
110
132
|
};
|
|
111
133
|
});
|
|
@@ -123,7 +145,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
123
145
|
const args = rawArgs as Record<string, any>;
|
|
124
146
|
|
|
125
147
|
// ββ Tool 1: rohan_zk_handshake ββββββββββββββββββββββββββββββββββββββββββββ
|
|
126
|
-
if (toolName === 'rohan_zk_handshake') {
|
|
148
|
+
if (toolName === 'rohan_execute_handshake' || toolName === 'rohan_zk_handshake') {
|
|
127
149
|
const actionLabel = args.actionSummary || args.intent;
|
|
128
150
|
if (!actionLabel) {
|
|
129
151
|
throw new Error('Invalid arguments: Either actionSummary or intent is required.');
|
|
@@ -131,7 +153,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
131
153
|
|
|
132
154
|
const isValid = SemanticFirewall.validate({
|
|
133
155
|
agentId: args.agentId,
|
|
134
|
-
action: '
|
|
156
|
+
action: 'rohan_execute_handshake',
|
|
135
157
|
payload: args,
|
|
136
158
|
});
|
|
137
159
|
|
|
@@ -207,7 +229,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
207
229
|
// Single Source of Truth: Canonicalization via @rohan-protocol/sdk
|
|
208
230
|
const canonicalPayload = canonicalizeJson(args.payload);
|
|
209
231
|
const computedDigest = crypto.createHash('sha256').update(canonicalPayload, 'utf8').digest('hex').toLowerCase();
|
|
210
|
-
const match =
|
|
232
|
+
const match = crypto.timingSafeEqual(
|
|
233
|
+
Buffer.from(computedDigest, 'hex'),
|
|
234
|
+
Buffer.from(normalizedExpected, 'hex')
|
|
235
|
+
);
|
|
211
236
|
|
|
212
237
|
return {
|
|
213
238
|
content: [{
|
|
@@ -262,13 +287,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
262
287
|
}
|
|
263
288
|
}
|
|
264
289
|
|
|
290
|
+
if (toolName === 'rohan_get_transaction_history') {
|
|
291
|
+
try {
|
|
292
|
+
const rawLimit = Number(args.limit) || 10;
|
|
293
|
+
const history = await rohanClient.getTransactionHistory(rawLimit);
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
content: [{
|
|
297
|
+
type: 'text',
|
|
298
|
+
text: JSON.stringify({ status: 'success', ...history }, null, 2),
|
|
299
|
+
}],
|
|
300
|
+
};
|
|
301
|
+
} catch (err: any) {
|
|
302
|
+
return {
|
|
303
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Failed to fetch transaction history' }) }],
|
|
304
|
+
isError: true,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
265
309
|
throw new Error(`Unknown tool: ${toolName}`);
|
|
266
310
|
});
|
|
267
311
|
|
|
268
312
|
async function run() {
|
|
269
313
|
const transport = new StdioServerTransport();
|
|
270
314
|
await server.connect(transport);
|
|
271
|
-
console.error('π‘οΈ Rohan Protocol MCP Server running via stdio (v0.
|
|
315
|
+
console.error('π‘οΈ Rohan Protocol MCP Server running via stdio (v0.8.0)...');
|
|
272
316
|
}
|
|
273
317
|
|
|
274
318
|
run().catch((error) => {
|
package/tests/firewall.test.js
CHANGED
|
@@ -11,6 +11,15 @@ test('SemanticFirewall: valid intent passes validation', () => {
|
|
|
11
11
|
assert.equal(SemanticFirewall.validate(intent), true);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
+
test('SemanticFirewall: standardized execute handshake action passes validation', () => {
|
|
15
|
+
const intent = {
|
|
16
|
+
agentId: 'agent-12345',
|
|
17
|
+
action: 'rohan_execute_handshake',
|
|
18
|
+
payload: { state: 'ready', amount: 100 }
|
|
19
|
+
};
|
|
20
|
+
assert.equal(SemanticFirewall.validate(intent), true);
|
|
21
|
+
});
|
|
22
|
+
|
|
14
23
|
test('SemanticFirewall: verify_batched_handshakes passes validation', () => {
|
|
15
24
|
const intent = {
|
|
16
25
|
agentId: 'agent-batcher',
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { RohanMcpGateway } from '../dist/gateway.js';
|
|
4
|
+
|
|
5
|
+
test('ADK tool defaults to the standardized execute-handshake name', () => {
|
|
6
|
+
const gateway = new RohanMcpGateway();
|
|
7
|
+
|
|
8
|
+
assert.equal(gateway.asAdkTool().name, 'rohan_execute_handshake');
|
|
9
|
+
assert.equal(gateway.asLegacyAdkTool().name, 'rohan_zk_handshake');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('standard and legacy ADK tool names share the same execution behavior', async () => {
|
|
13
|
+
const gateway = new RohanMcpGateway();
|
|
14
|
+
let submittedPayload;
|
|
15
|
+
gateway.relayerClient.submitHandshake = async (payload) => {
|
|
16
|
+
submittedPayload = payload;
|
|
17
|
+
return { status: 'confirmed' };
|
|
18
|
+
};
|
|
19
|
+
const params = { agentId: 'agent-1', intent: 'test intent' };
|
|
20
|
+
|
|
21
|
+
const standardResult = await gateway.asAdkTool().execute(params);
|
|
22
|
+
const legacyResult = await gateway.asLegacyAdkTool().execute(params);
|
|
23
|
+
|
|
24
|
+
assert.deepEqual(submittedPayload, params);
|
|
25
|
+
assert.deepEqual(standardResult, { status: 'confirmed' });
|
|
26
|
+
assert.deepEqual(legacyResult, { status: 'confirmed' });
|
|
27
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import {
|
|
4
|
+
publicKeyFromDidKey,
|
|
5
|
+
verifyEd25519Signature,
|
|
6
|
+
} from '@rohan-protocol/sdk';
|
|
7
|
+
import { resolveSignerFromEnv } from '../dist/identity.js';
|
|
8
|
+
|
|
9
|
+
const TEST_SEED_HEX = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
|
|
10
|
+
|
|
11
|
+
test('derives a matching Ed25519 signer from a 32-byte hex seed', async () => {
|
|
12
|
+
const signer = await resolveSignerFromEnv(TEST_SEED_HEX);
|
|
13
|
+
assert.ok(signer);
|
|
14
|
+
|
|
15
|
+
const message = new TextEncoder().encode('Rohan Protocol V-08 Verification');
|
|
16
|
+
const signature = await signer.sign(message);
|
|
17
|
+
const publicKey = publicKeyFromDidKey(signer.did);
|
|
18
|
+
|
|
19
|
+
assert.equal(await verifyEd25519Signature(publicKey, signature, message), true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('does not configure a signer when no private key is provided', async () => {
|
|
23
|
+
assert.equal(await resolveSignerFromEnv(undefined), undefined);
|
|
24
|
+
assert.equal(await resolveSignerFromEnv(' '), undefined);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('fails explicitly when a configured private key is malformed', async () => {
|
|
28
|
+
await assert.rejects(
|
|
29
|
+
resolveSignerFromEnv('not-a-private-key'),
|
|
30
|
+
/ROHAN_AGENT_PRIVATE_KEY must be exactly 32 bytes/
|
|
31
|
+
);
|
|
32
|
+
});
|