@rohan-protocol/mcp 0.6.1 β†’ 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 CHANGED
@@ -1,49 +1,80 @@
1
- @rohan-protocol/mcp
1
+ # @rohan-protocol/mcp (v0.8.0)
2
2
 
3
- ![Bild](https://img.shields.io/badge/NPM-v0.6.0-blue?style=for-the-badge)
4
- ![Bild](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)
3
+ Official Model Context Protocol (MCP) server providing confidential state transitions, ledger inspection, and cryptographic audit tools for Claude Desktop, Cursor, Cline, and Gemini.
5
4
 
6
- Official Model Context Protocol (MCP) server for Rohan Protocol.
7
- Equips autonomous AI agents (Claude Desktop, Cursor, Gemini, Google ADK) with confidential Zero-Knowledge state transitions on Midnight Blockchain.
8
- Features
5
+ [![Rohan Shield MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/rohan-protocol/sdk/badges/card.svg)](https://glama.ai/mcp/servers/rohan-protocol/sdk)
6
+ [![Smithery Verified](https://img.shields.io/badge/Smithery-Verified-green?style=flat-square)](https://smithery.ai/servers/rohanprotocol/shield)
9
7
 
10
- Pre-Prover Semantic Firewall (V-01): Defends autonomous agents from indirect prompt injections and malicious payload expansions.
8
+ ---
11
9
 
12
- Universal Tool Interface: Exposes standard-compliant rohan_zk_handshake tool schema for LLMs in 100% technical English.
10
+ ## πŸ› οΈ The 4 MCP Tools
13
11
 
14
- Gasless L1 Anchoring: Routes state commitments through the Rohan Relayer Pool with sponsored $tDUST network gas.
12
+ ### 1. `rohan_execute_handshake` (Write / Settlement)
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). The legacy `rohan_zk_handshake` name remains accepted.
15
15
 
16
- Installation & Setup
17
- Claude Desktop
16
+ ### 2. `rohan_get_ledger_state` (Read / State Inspection)
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.
18
+ * **Arguments:** None.
18
19
 
19
- Add to your claude_desktop_config.json:
20
- code JSON
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).
21
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
+
28
+ ---
29
+
30
+ ## πŸš€ Setup & Configuration
31
+
32
+ ### Option A: Claude Desktop Setup
33
+ Add this to your `claude_desktop_config.json`:
34
+
35
+ ```json
22
36
  {
23
37
  "mcpServers": {
24
- "rohan-zk-shield": {
38
+ "rohan-shield": {
25
39
  "command": "npx",
26
- "args": ["-y", "@rohan-protocol/mcp"],
40
+ "args": ["-y", "@rohan-protocol/mcp@0.8.0"],
27
41
  "env": {
28
- "ROHAN_RELAYER_URL": "https://api.rohanprotocol.network/api/v1/handshake",
29
- "ROHAN_API_KEY": "rohan_live_..."
42
+ "ROHAN_API_KEY": ""
30
43
  }
31
44
  }
32
45
  }
33
46
  }
34
-
35
- Cursor IDE
36
-
37
- Open Settings β†’ Features β†’ MCP Servers β†’ Add New MCP Server:
38
-
39
- Name: rohan-shield
40
-
41
- Type: command
42
-
43
- Command: npx -y @rohan-protocol/mcp
44
-
45
- Environment: ROHAN_API_KEY=rohan_live_...
46
-
47
- License
48
-
49
- MIT Β© Rohan Protocol.
47
+ ```
48
+
49
+ ### Option B: Cursor MCP Setup
50
+ 1. Go to **Settings β†’ Features β†’ MCP**.
51
+ 2. Click **Add New MCP Server**:
52
+ * **Name:** `rohan-shield`
53
+ * **Type:** `command`
54
+ * **Command:** `npx -y @rohan-protocol/mcp@0.8.0`
55
+
56
+ ### Option C: Remote MCP (Smithery / Cloud Agents)
57
+ Connect directly to the hosted endpoint:
58
+ * **Server Card:** `https://api.rohanprotocol.network/.well-known/mcp/server-card.json`
59
+ * **JSON-RPC Endpoint:** `https://api.rohanprotocol.network/mcp`
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
+
76
+ ---
77
+
78
+ ## πŸ“œ License
79
+
80
+ Apache-2.0
@@ -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,CAqBhD;CACF"}
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' && intent.action !== 'verify_batched_handshakes')) {
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') {
@@ -1 +1 @@
1
- {"version":3,"file":"firewall.js","sourceRoot":"","sources":["../src/firewall.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAU,eAAe,GACrC,uKAAuK,CAAC;IAE1K,MAAM,CAAC,QAAQ,CAAC,MAAuB;QACrC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACzF,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,oBAAoB,IAAI,MAAM,CAAC,MAAM,KAAK,2BAA2B,CAAC,EAAE,CAAC;YAChH,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO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I,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC,CAAC,kDAAkD;QAClE,CAAC;QAED,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,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
@@ -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;IAElD,YAAY,OAAO,GAAE,sBAA2B,EAO/C;IAED;;OAEG;IACH,SAAS;QAEL,IAAI;QACJ,WAAW;QACX,UAAU;YACR,IAAI;YACJ,UAAU;gBACR,OAAO;oBAAI,IAAI;oBAAY,WAAW;;gBACtC,MAAM;oBAAI,IAAI;oBAAY,WAAW;;gBACrC,cAAc;oBAAI,IAAI;oBAAY,WAAW;;;YAE/C,QAAQ;;QAEV,OAAO,WAAiB,GAAG;MAI9B;CACF"}
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: 'rohan_zk_handshake',
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
@@ -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,OAAO,GAA2B,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,oBAAoB;YAC1B,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;CACF"}
1
+ {"version":3,"file":"gateway.js","sourceRoot":"","sources":["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} from '@rohan-protocol/sdk';
2
+ export declare function resolveSignerFromEnv(rawPrivateKeyHex?: string | undefined): Promise<AgentSigner | undefined>;
3
+ //# sourceMappingURL=identity.d.ts.map
@@ -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"}
@@ -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,CA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ACT,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;AACH,CAAC"}
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- export declare const ROHAN_TOOL_SCHEMA: {
2
+ export declare const ROHAN_HANDSHAKE_TOOL_SCHEMA: {
3
3
  name: string;
4
4
  description: string;
5
5
  inputSchema: {
@@ -29,4 +29,44 @@ export declare const ROHAN_TOOL_SCHEMA: {
29
29
  required: string[];
30
30
  };
31
31
  };
32
+ export declare const ROHAN_VERIFY_TOOL_SCHEMA: {
33
+ name: string;
34
+ description: string;
35
+ inputSchema: {
36
+ type: string;
37
+ properties: {
38
+ payload: {
39
+ type: string;
40
+ description: string;
41
+ };
42
+ expectedDigest: {
43
+ type: string;
44
+ pattern: string;
45
+ description: string;
46
+ };
47
+ };
48
+ required: string[];
49
+ };
50
+ };
51
+ export declare const ROHAN_LEDGER_STATE_TOOL_SCHEMA: {
52
+ name: string;
53
+ description: string;
54
+ inputSchema: {
55
+ type: string;
56
+ properties: {};
57
+ };
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
+ };
32
72
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAmCA,eAAO,MAAM,iBAAiB;IAC5B,IAAI;IACJ,WAAW;IAEX,WAAW;QACT,IAAI;QACJ,UAAU;YACR,OAAO;gBACL,IAAI;gBACJ,WAAW;;YAEb,aAAa;gBACX,IAAI;gBACJ,WAAW;;YAEb,mBAAmB;gBACjB,IAAI;gBACJ,WAAW;;YAEb,cAAc;gBACZ,IAAI;gBACJ,WAAW;;YAEb,MAAM;gBACJ,IAAI;gBACJ,WAAW;;;QAGf,QAAQ;;CAEX,CAAC"}
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
@@ -1,27 +1,35 @@
1
1
  #!/usr/bin/env node
2
+ import crypto from 'node:crypto';
2
3
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
5
  import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
6
  import { SemanticFirewall } from './firewall.js';
6
- import { RohanClient, sealActionIntent } from '@rohan-protocol/sdk';
7
+ import { RohanClient, sealActionIntent, canonicalizeJson } from '@rohan-protocol/sdk';
8
+ import { resolveSignerFromEnv } from './identity.js';
7
9
  const CONTRACT_ADDRESS = process.env.ROHAN_CONTRACT_ADDRESS || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
8
10
  const RELAYER_URL = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
9
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
+ }
10
16
  const rohanClient = new RohanClient({
11
17
  contractAddress: CONTRACT_ADDRESS,
12
18
  relayerUrl: RELAYER_URL,
13
19
  apiKey: API_KEY,
20
+ signer: configuredSigner,
14
21
  });
15
22
  const server = new Server({
16
23
  name: 'rohan-protocol-mcp',
17
- version: '0.6.1',
24
+ version: '0.8.0',
18
25
  }, {
19
26
  capabilities: {
20
27
  tools: {},
21
28
  },
22
29
  });
23
- export const ROHAN_TOOL_SCHEMA = {
24
- name: 'rohan_zk_handshake',
30
+ // ── Tool 1 Schema: Write / Settlement ───────────────────────────────────────
31
+ export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
32
+ name: 'rohan_execute_handshake',
25
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.',
26
34
  inputSchema: {
27
35
  type: 'object',
@@ -50,59 +58,221 @@ export const ROHAN_TOOL_SCHEMA = {
50
58
  required: ['agentId'],
51
59
  },
52
60
  };
61
+ // ── Tool 2 Schema: Audit / In-Memory Verification ───────────────────────────
62
+ export const ROHAN_VERIFY_TOOL_SCHEMA = {
63
+ name: 'rohan_verify_commitment',
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.',
65
+ inputSchema: {
66
+ type: 'object',
67
+ properties: {
68
+ payload: {
69
+ type: 'object',
70
+ description: 'The plaintext contract, agreement, or intent data to be verified.',
71
+ },
72
+ expectedDigest: {
73
+ type: 'string',
74
+ pattern: '^(?:sha256:|0x)?[0-9a-fA-F]{64}$',
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.',
76
+ },
77
+ },
78
+ required: ['payload', 'expectedDigest'],
79
+ },
80
+ };
81
+ // ── Tool 3 Schema: Read / Ledger State Inspection ───────────────────────────
82
+ export const ROHAN_LEDGER_STATE_TOOL_SCHEMA = {
83
+ name: 'rohan_get_ledger_state',
84
+ description: 'Reads the current anchored state of the Rohan Protocol smart contract on Midnight Preprod L1. Returns the state root, block height, and last mined transaction hash from memory cache.',
85
+ inputSchema: {
86
+ type: 'object',
87
+ properties: {},
88
+ },
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
+ };
53
103
  server.setRequestHandler(ListToolsRequestSchema, async () => {
54
- return { tools: [ROHAN_TOOL_SCHEMA] };
104
+ return {
105
+ tools: [
106
+ ROHAN_HANDSHAKE_TOOL_SCHEMA,
107
+ ROHAN_LEDGER_STATE_TOOL_SCHEMA,
108
+ ROHAN_HISTORY_TOOL_SCHEMA,
109
+ ROHAN_VERIFY_TOOL_SCHEMA,
110
+ ],
111
+ };
55
112
  });
56
113
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
57
- if (request.params.name !== 'rohan_zk_handshake') {
58
- throw new Error(`Unknown tool: ${request.params.name}`);
59
- }
60
- const args = request.params.arguments;
61
- const actionLabel = args.actionSummary || args.intent;
62
- if (!actionLabel) {
63
- throw new Error('Invalid arguments: Either actionSummary or intent is required.');
64
- }
65
- const isValid = SemanticFirewall.validate({
66
- agentId: args.agentId,
67
- action: 'rohan_zk_handshake',
68
- payload: args,
69
- });
70
- if (!isValid) {
114
+ const toolName = request.params.name;
115
+ const rawArgs = request.params?.arguments;
116
+ if (!rawArgs || typeof rawArgs !== 'object' || Array.isArray(rawArgs)) {
71
117
  return {
72
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Security Violation: Intent rejected by Semantic Firewall (V-01)' }) }],
118
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'INVALID_ARGUMENTS: Expected a valid arguments object.' }) }],
73
119
  isError: true,
74
120
  };
75
121
  }
76
- try {
77
- // Elegant & DRY: SDK handles RFC 8785 canonicalization and RAM hashing
78
- const finalIntent = sealActionIntent(actionLabel, args.confidentialPayload);
79
- const receipt = await rohanClient.submitHandshake({
122
+ const args = rawArgs;
123
+ // ── Tool 1: rohan_zk_handshake ────────────────────────────────────────────
124
+ if (toolName === 'rohan_execute_handshake' || toolName === 'rohan_zk_handshake') {
125
+ const actionLabel = args.actionSummary || args.intent;
126
+ if (!actionLabel) {
127
+ throw new Error('Invalid arguments: Either actionSummary or intent is required.');
128
+ }
129
+ const isValid = SemanticFirewall.validate({
80
130
  agentId: args.agentId,
81
- intent: finalIntent,
82
- counterpartyId: args.counterpartyId,
131
+ action: 'rohan_execute_handshake',
132
+ payload: args,
83
133
  });
84
- return {
85
- content: [{
86
- type: 'text',
87
- text: JSON.stringify({
88
- status: 'success',
89
- message: 'Zero-Knowledge Handshake successfully settled on Midnight Blockchain.',
90
- receipt,
91
- }, null, 2),
92
- }],
93
- };
134
+ if (!isValid) {
135
+ return {
136
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Security Violation: Intent rejected by Semantic Firewall (V-01)' }) }],
137
+ isError: true,
138
+ };
139
+ }
140
+ try {
141
+ const finalIntent = sealActionIntent(actionLabel, args.confidentialPayload);
142
+ const receipt = await rohanClient.submitHandshake({
143
+ agentId: args.agentId,
144
+ intent: finalIntent,
145
+ counterpartyId: args.counterpartyId,
146
+ });
147
+ return {
148
+ content: [{
149
+ type: 'text',
150
+ text: JSON.stringify({
151
+ status: 'success',
152
+ message: 'Zero-Knowledge Handshake successfully settled on Midnight Blockchain.',
153
+ receipt,
154
+ }, null, 2),
155
+ }],
156
+ };
157
+ }
158
+ catch (err) {
159
+ return {
160
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Handshake execution failed' }) }],
161
+ isError: true,
162
+ };
163
+ }
94
164
  }
95
- catch (err) {
96
- return {
97
- content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Handshake execution failed' }) }],
98
- isError: true,
99
- };
165
+ // ── Tool 2: rohan_verify_commitment ───────────────────────────────────────
166
+ if (toolName === 'rohan_verify_commitment') {
167
+ // Payload-Size-Guard (Max 256 KB im RAM)
168
+ const payloadString = JSON.stringify(args.payload);
169
+ if (payloadString.length > 256 * 1024) {
170
+ return {
171
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'PAYLOAD_TOO_LARGE: Plaintext exceeds maximum allowed size of 256 KB.' }) }],
172
+ isError: true,
173
+ };
174
+ }
175
+ if (!args.payload || typeof args.payload !== 'object' || Array.isArray(args.payload)) {
176
+ return {
177
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Invalid argument: payload must be a non-null object.' }) }],
178
+ isError: true,
179
+ };
180
+ }
181
+ if (!args.expectedDigest || typeof args.expectedDigest !== 'string') {
182
+ return {
183
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Invalid argument: expectedDigest must be a string.' }) }],
184
+ isError: true,
185
+ };
186
+ }
187
+ try {
188
+ // LLM Prefix Tolerance: Strips 'sha256:' or '0x'
189
+ const normalizedExpected = args.expectedDigest.replace(/^(?:sha256:|0x)/i, '').toLowerCase();
190
+ if (!/^[0-9a-f]{64}$/.test(normalizedExpected)) {
191
+ return {
192
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Invalid expectedDigest: must resolve to a 64-character hexadecimal SHA-256 hash.' }) }],
193
+ isError: true,
194
+ };
195
+ }
196
+ // Single Source of Truth: Canonicalization via @rohan-protocol/sdk
197
+ const canonicalPayload = canonicalizeJson(args.payload);
198
+ const computedDigest = crypto.createHash('sha256').update(canonicalPayload, 'utf8').digest('hex').toLowerCase();
199
+ const match = crypto.timingSafeEqual(Buffer.from(computedDigest, 'hex'), Buffer.from(normalizedExpected, 'hex'));
200
+ return {
201
+ content: [{
202
+ type: 'text',
203
+ text: JSON.stringify({
204
+ status: 'success',
205
+ valid: match,
206
+ match,
207
+ expectedDigest: normalizedExpected,
208
+ computedDigest,
209
+ algorithm: 'SHA-256 (RFC 8785 JCS)',
210
+ verifiedAt: Date.now(),
211
+ }, null, 2),
212
+ }],
213
+ };
214
+ }
215
+ catch (err) {
216
+ return {
217
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Verification execution failed' }) }],
218
+ isError: true,
219
+ };
220
+ }
221
+ }
222
+ // ── Tool 3: rohan_get_ledger_state ────────────────────────────────────────
223
+ if (toolName === 'rohan_get_ledger_state') {
224
+ try {
225
+ const ledgerState = await rohanClient.getLedgerState();
226
+ const cacheAgeMs = Date.now() - (ledgerState.fetchedAt || Date.now());
227
+ return {
228
+ content: [{
229
+ type: 'text',
230
+ text: JSON.stringify({
231
+ status: 'success',
232
+ contractAddress: ledgerState.contractAddress,
233
+ currentStateRoot: ledgerState.currentStateRoot,
234
+ blockHeight: ledgerState.blockHeight ?? null,
235
+ lastTxHash: ledgerState.lastTxHash ?? null,
236
+ network: ledgerState.network || 'midnight-preprod',
237
+ isMinedOnChain: ledgerState.isMinedOnChain ?? true,
238
+ cacheAgeMs: ledgerState.cacheAgeMs ?? cacheAgeMs,
239
+ cacheTtlMs: ledgerState.cacheTtlMs ?? 15000,
240
+ fetchedAt: ledgerState.fetchedAt,
241
+ }, null, 2),
242
+ }],
243
+ };
244
+ }
245
+ catch (err) {
246
+ return {
247
+ content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Failed to fetch ledger state' }) }],
248
+ isError: true,
249
+ };
250
+ }
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
+ }
100
269
  }
270
+ throw new Error(`Unknown tool: ${toolName}`);
101
271
  });
102
272
  async function run() {
103
273
  const transport = new StdioServerTransport();
104
274
  await server.connect(transport);
105
- console.error('πŸ›‘οΈ Rohan Protocol MCP Server running via stdio (v0.6.1)...');
275
+ console.error('πŸ›‘οΈ Rohan Protocol MCP Server running via stdio (v0.8.0)...');
106
276
  }
107
277
  run().catch((error) => {
108
278
  console.error('Fatal MCP server error:', error);