@rohan-protocol/mcp 0.5.3 → 0.6.1
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 +21 -0
- package/README.md +49 -189
- package/dist/firewall.js +2 -2
- package/dist/firewall.js.map +1 -1
- package/dist/gateway.d.ts +4 -8
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +7 -8
- package/dist/gateway.js.map +1 -1
- package/dist/server.d.ts +30 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +58 -79
- package/dist/server.js.map +1 -1
- package/package.json +30 -20
- package/server.json +25 -24
- package/smithery.yaml +1 -1
- package/src/firewall.ts +2 -2
- package/src/gateway.ts +7 -8
- package/src/server.ts +70 -93
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rohan Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,189 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Add the Rohan MCP server to your `claude_desktop_config.json`:
|
|
51
|
-
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
52
|
-
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
53
|
-
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
|
|
54
|
-
|
|
55
|
-
```json
|
|
56
|
-
{
|
|
57
|
-
"mcpServers": {
|
|
58
|
-
"rohan-zk-gateway": {
|
|
59
|
-
"command": "npx",
|
|
60
|
-
"args": ["-y", "@rohan-protocol/mcp"],
|
|
61
|
-
"env": {
|
|
62
|
-
"ROHAN_CONTRACT_ADDRESS": "6d2d603235f996424d76c85186a79cc403245ea8ee1ba9087e40967fe71bdc4d",
|
|
63
|
-
"ROHAN_RELAYER_URL": "https://api.rohanprotocol.network/api/v1/handshake/stream",
|
|
64
|
-
"ROHAN_API_KEY": "rohan_live_..."
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
> **Sandbox vs. Production**: The MCP server works out of the box with **10 free handshakes per day** without an API key. For continuous agent workflows, provide `ROHAN_API_KEY` in the environment configuration.
|
|
72
|
-
|
|
73
|
-
### 2. Cursor IDE Integration
|
|
74
|
-
|
|
75
|
-
In Cursor, navigate to **Settings > Features > MCP Servers > Add New MCP Server**:
|
|
76
|
-
- **Name**: `rohan-zk`
|
|
77
|
-
- **Type**: `command`
|
|
78
|
-
- **Command**: `npx -y @rohan-protocol/mcp`
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## 🛠️ Exposed MCP Tools
|
|
83
|
-
|
|
84
|
-
The server automatically registers the following tool in your LLM's context:
|
|
85
|
-
|
|
86
|
-
### `rohan_zk_handshake`
|
|
87
|
-
|
|
88
|
-
Executes a confidential, tamper-proof Zero-Knowledge handshake on Midnight with real-time streamable verification.
|
|
89
|
-
|
|
90
|
-
#### Input Schema:
|
|
91
|
-
|
|
92
|
-
```json
|
|
93
|
-
{
|
|
94
|
-
"agentId": {
|
|
95
|
-
"type": "string",
|
|
96
|
-
"description": "Decentralized Identifier (DID) of the initiator agent (e.g. did:midnight:agent-01)"
|
|
97
|
-
},
|
|
98
|
-
"intent": {
|
|
99
|
-
"type": "string",
|
|
100
|
-
"description": "Semantic action plan, financial intent, or agreement to seal in ZK"
|
|
101
|
-
},
|
|
102
|
-
"counterpartyId": {
|
|
103
|
-
"type": "string",
|
|
104
|
-
"description": "Optional DID of the target recipient agent"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
#### Example Agent Invocation Prompt:
|
|
110
|
-
|
|
111
|
-
> *"Claude, seal our data-sharing agreement with `did:midnight:agent-partner` using Rohan ZK Handshake."*
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
<a id="streamable-http-handshake-lifecycle"></a>
|
|
116
|
-
## ⚡ Streamable HTTP Handshake Lifecycle
|
|
117
|
-
|
|
118
|
-
During tool execution, the MCP server connects to the Relayer via Chunked Transfer-Encoding (NDJSON), processing the following sequential stages:
|
|
119
|
-
|
|
120
|
-
```text
|
|
121
|
-
📡 [LIVE CHUNK] stage: 'received' | Data: {"stage":"received","timestamp":1788903808207}
|
|
122
|
-
📡 [LIVE CHUNK] stage: 'firewall_approved' | Data: {"stage":"firewall_approved","v01":"passed"}
|
|
123
|
-
📡 [LIVE CHUNK] stage: 'subsidizing_gas' | Data: {"stage":"subsidizing_gas","gasPayer":"rohan-relayer-node-01"}
|
|
124
|
-
📡 [LIVE CHUNK] stage: 'confirmed' | Data: {"stage":"confirmed","status":"success","txHash":"0x7c92...","intentHash":"0916..."}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
#### Returned Structured Receipt to LLM:
|
|
128
|
-
|
|
129
|
-
```json
|
|
130
|
-
{
|
|
131
|
-
"status": "success",
|
|
132
|
-
"receipt": {
|
|
133
|
-
"stage": "confirmed",
|
|
134
|
-
"status": "success",
|
|
135
|
-
"contractAddress": "6d2d603235f996424d76c85186a79cc403245ea8ee1ba9087e40967fe71bdc4d",
|
|
136
|
-
"intentHash": "0916542f526dd3117104f23f113873a5331fdc2d885340081aef79dab0ee7393",
|
|
137
|
-
"txHash": "0x7c92f75ca7d3bc8c767953b69c29d87d3848084c68d401bbd7987ff1afdb8271",
|
|
138
|
-
"gasPaidBy": "rohan-relayer-node-01",
|
|
139
|
-
"timestamp": 1788903808208
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
<a id="security-architecture"></a>
|
|
147
|
-
## 🔒 Security Architecture (V-01 & V-02)
|
|
148
|
-
|
|
149
|
-
```text
|
|
150
|
-
┌────────────────────────────────────────────────────────┐
|
|
151
|
-
│ AI Agent (Claude / Cursor / Headless Bot) │
|
|
152
|
-
│ "Perform confidential handshake with Agent B" │
|
|
153
|
-
└──────────────────────────┬─────────────────────────────┘
|
|
154
|
-
│ 💬 MCP Tool Request: rohan_zk_handshake
|
|
155
|
-
▼
|
|
156
|
-
┌────────────────────────────────────────────────────────┐
|
|
157
|
-
│ 🛡️ PRE-PROVER SEMANTIC FIREWALL (V-01) │
|
|
158
|
-
│ - Inspects against indirect injection patterns │
|
|
159
|
-
│ - Validates schema and DID integrity │
|
|
160
|
-
└──────────────────────────┬─────────────────────────────┘
|
|
161
|
-
│ ✅ Filter Passed
|
|
162
|
-
▼
|
|
163
|
-
┌────────────────────────────────────────────────────────┐
|
|
164
|
-
│ 📦 @rohan-protocol/sdk (Local WASM Engine) │
|
|
165
|
-
│ - Computes ZK-Proof in isolated RAM │
|
|
166
|
-
│ - Multi-pass memory wipe destroys witness w (V-02) │
|
|
167
|
-
└──────────────────────────┬─────────────────────────────┘
|
|
168
|
-
│ 📡 Streamable HTTP (POST /api/v1/handshake/stream)
|
|
169
|
-
▼
|
|
170
|
-
┌────────────────────────────────────────────────────────┐
|
|
171
|
-
│ ⚡ Rohan Relayer & Gas Station (NDJSON Stream) │
|
|
172
|
-
│ - Chunk 1: stage: 'received' │
|
|
173
|
-
│ - Chunk 2: stage: 'firewall_approved' │
|
|
174
|
-
│ - Chunk 3: stage: 'subsidizing_gas' │
|
|
175
|
-
│ - Chunk 4: stage: 'confirmed' (on-chain finalization)│
|
|
176
|
-
└──────────────────────────┬─────────────────────────────┘
|
|
177
|
-
│
|
|
178
|
-
┌──────────────────────────▼─────────────────────────────┐
|
|
179
|
-
│ 🌌 Midnight Network Settlement Layer │
|
|
180
|
-
│ - Compact Smart Contract: rohan_handshake │
|
|
181
|
-
│ - Preprod Address: 6d2d603235f996424d76c85186a... │
|
|
182
|
-
└────────────────────────────────────────────────────────┘
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## 📄 License
|
|
188
|
-
|
|
189
|
-
MIT © Rohan Protocol. Part of the Private Agentic Economy.
|
|
1
|
+
@rohan-protocol/mcp
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
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
|
|
9
|
+
|
|
10
|
+
Pre-Prover Semantic Firewall (V-01): Defends autonomous agents from indirect prompt injections and malicious payload expansions.
|
|
11
|
+
|
|
12
|
+
Universal Tool Interface: Exposes standard-compliant rohan_zk_handshake tool schema for LLMs in 100% technical English.
|
|
13
|
+
|
|
14
|
+
Gasless L1 Anchoring: Routes state commitments through the Rohan Relayer Pool with sponsored $tDUST network gas.
|
|
15
|
+
|
|
16
|
+
Installation & Setup
|
|
17
|
+
Claude Desktop
|
|
18
|
+
|
|
19
|
+
Add to your claude_desktop_config.json:
|
|
20
|
+
code JSON
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"rohan-zk-shield": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "@rohan-protocol/mcp"],
|
|
27
|
+
"env": {
|
|
28
|
+
"ROHAN_RELAYER_URL": "https://api.rohanprotocol.network/api/v1/handshake",
|
|
29
|
+
"ROHAN_API_KEY": "rohan_live_..."
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
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.
|
package/dist/firewall.js
CHANGED
|
@@ -12,10 +12,10 @@ export class SemanticFirewall {
|
|
|
12
12
|
}
|
|
13
13
|
const serialized = JSON.stringify(intent.payload);
|
|
14
14
|
if (serialized.length > 8192) {
|
|
15
|
-
return false; // Denial-of-Service
|
|
15
|
+
return false; // Denial-of-Service Protection (Payload size cap)
|
|
16
16
|
}
|
|
17
17
|
if (this.INJECTION_REGEX.test(serialized)) {
|
|
18
|
-
return false; // Prompt Injection
|
|
18
|
+
return false; // Semantic Prompt Injection detected
|
|
19
19
|
}
|
|
20
20
|
return true;
|
|
21
21
|
}
|
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;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,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC1D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC,CAAC,
|
|
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,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC1D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,MAAM,GAAG,IAAI,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;CACF"}
|
package/dist/gateway.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RohanRelayerClient } from '
|
|
1
|
+
import { RohanRelayerClient } from '@rohan-protocol/sdk';
|
|
2
2
|
export interface RohanMcpGatewayOptions {
|
|
3
3
|
transport?: 'stdio' | 'streamable-http';
|
|
4
4
|
relayerUrl?: string;
|
|
@@ -6,7 +6,7 @@ export interface RohanMcpGatewayOptions {
|
|
|
6
6
|
apiKey?: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* RohanMcpGateway
|
|
10
10
|
* Connects AI Agent pipelines (Google ADK 2.0, Gemini, Claude, Cursor)
|
|
11
11
|
* to the Rohan Protocol Gas Station via Streamable HTTP (NDJSON) or Stdio.
|
|
12
12
|
*/
|
|
@@ -31,18 +31,14 @@ export declare class RohanMcpGateway {
|
|
|
31
31
|
type: string;
|
|
32
32
|
description: string;
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
type: string;
|
|
36
|
-
description: string;
|
|
37
|
-
};
|
|
38
|
-
publicInputs: {
|
|
34
|
+
counterpartyId: {
|
|
39
35
|
type: string;
|
|
40
36
|
description: string;
|
|
41
37
|
};
|
|
42
38
|
};
|
|
43
39
|
required: string[];
|
|
44
40
|
};
|
|
45
|
-
execute: (params: any) => Promise<
|
|
41
|
+
execute: (params: any) => Promise<import("@rohan-protocol/sdk").HandshakeReceipt>;
|
|
46
42
|
};
|
|
47
43
|
}
|
|
48
44
|
//# 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,
|
|
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"}
|
package/dist/gateway.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RohanRelayerClient } from '
|
|
1
|
+
import { RohanRelayerClient } from '@rohan-protocol/sdk';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* RohanMcpGateway
|
|
4
4
|
* Connects AI Agent pipelines (Google ADK 2.0, Gemini, Claude, Cursor)
|
|
5
5
|
* to the Rohan Protocol Gas Station via Streamable HTTP (NDJSON) or Stdio.
|
|
6
6
|
*/
|
|
@@ -11,7 +11,7 @@ export class RohanMcpGateway {
|
|
|
11
11
|
this.transport = options.transport || 'streamable-http';
|
|
12
12
|
this.relayerClient = new RohanRelayerClient({
|
|
13
13
|
relayerUrl: options.relayerUrl || 'http://127.0.0.1:4005/api/v1/handshake',
|
|
14
|
-
contractAddress: options.contractAddress || '
|
|
14
|
+
contractAddress: options.contractAddress || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e',
|
|
15
15
|
apiKey: options.apiKey,
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -25,15 +25,14 @@ export class RohanMcpGateway {
|
|
|
25
25
|
parameters: {
|
|
26
26
|
type: 'object',
|
|
27
27
|
properties: {
|
|
28
|
-
agentId: { type: 'string', description: 'Identifier of calling agent' },
|
|
29
|
-
intent: { type: 'string', description: 'Semantic action intent' },
|
|
30
|
-
|
|
31
|
-
publicInputs: { type: 'object', description: 'Public inputs for on-chain verification' },
|
|
28
|
+
agentId: { type: 'string', description: 'Decentralized Identifier (DID) of calling agent' },
|
|
29
|
+
intent: { type: 'string', description: 'Semantic action intent or agreement payload' },
|
|
30
|
+
counterpartyId: { type: 'string', description: 'Optional recipient agent identifier' },
|
|
32
31
|
},
|
|
33
32
|
required: ['agentId', 'intent'],
|
|
34
33
|
},
|
|
35
34
|
execute: async (params) => {
|
|
36
|
-
return await this.relayerClient.
|
|
35
|
+
return await this.relayerClient.submitHandshake(params);
|
|
37
36
|
},
|
|
38
37
|
};
|
|
39
38
|
}
|
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,
|
|
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"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export {
|
|
2
|
+
export declare const ROHAN_TOOL_SCHEMA: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
agentId: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
actionSummary: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
confidentialPayload: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
counterpartyId: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
intent: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
required: string[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
3
32
|
//# 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":";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"}
|
package/dist/server.js
CHANGED
|
@@ -3,59 +3,65 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import { SemanticFirewall } from './firewall.js';
|
|
6
|
-
import { RohanClient } from '
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const rohanClient = new RohanClient(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
import { RohanClient, sealActionIntent } from '@rohan-protocol/sdk';
|
|
7
|
+
const CONTRACT_ADDRESS = process.env.ROHAN_CONTRACT_ADDRESS || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
|
|
8
|
+
const RELAYER_URL = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
|
|
9
|
+
const API_KEY = process.env.ROHAN_API_KEY || '';
|
|
10
|
+
const rohanClient = new RohanClient({
|
|
11
|
+
contractAddress: CONTRACT_ADDRESS,
|
|
12
|
+
relayerUrl: RELAYER_URL,
|
|
13
|
+
apiKey: API_KEY,
|
|
14
|
+
});
|
|
15
15
|
const server = new Server({
|
|
16
16
|
name: 'rohan-protocol-mcp',
|
|
17
|
-
version: '0.
|
|
17
|
+
version: '0.6.1',
|
|
18
18
|
}, {
|
|
19
19
|
capabilities: {
|
|
20
20
|
tools: {},
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
counterpartyId: {
|
|
42
|
-
type: 'string',
|
|
43
|
-
description: 'Optionale ID des Empfänger-Agenten',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
required: ['agentId', 'intent'],
|
|
47
|
-
},
|
|
23
|
+
export const ROHAN_TOOL_SCHEMA = {
|
|
24
|
+
name: 'rohan_zk_handshake',
|
|
25
|
+
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
|
+
inputSchema: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
agentId: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'Decentralized Identifier (DID) of the initiating agent',
|
|
32
|
+
},
|
|
33
|
+
actionSummary: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: "Public high-level action label (e.g. 'Vendor Agreement Execution', 'Database Audit Anchor')",
|
|
36
|
+
},
|
|
37
|
+
confidentialPayload: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
description: 'OPTIONAL confidential parameters (budgets, deals, PII). Automatically canonicalized via RFC 8785 and hashed in local memory.',
|
|
48
40
|
},
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
counterpartyId: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'Optional counterparty agent identifier',
|
|
44
|
+
},
|
|
45
|
+
intent: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
description: 'Legacy fallback for actionSummary',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
required: ['agentId'],
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
54
|
+
return { tools: [ROHAN_TOOL_SCHEMA] };
|
|
51
55
|
});
|
|
52
|
-
// 2. Tool-Aufruf ausführen
|
|
53
56
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
54
57
|
if (request.params.name !== 'rohan_zk_handshake') {
|
|
55
|
-
throw new Error(`
|
|
58
|
+
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
56
59
|
}
|
|
57
60
|
const args = request.params.arguments;
|
|
58
|
-
|
|
61
|
+
const actionLabel = args.actionSummary || args.intent;
|
|
62
|
+
if (!actionLabel) {
|
|
63
|
+
throw new Error('Invalid arguments: Either actionSummary or intent is required.');
|
|
64
|
+
}
|
|
59
65
|
const isValid = SemanticFirewall.validate({
|
|
60
66
|
agentId: args.agentId,
|
|
61
67
|
action: 'rohan_zk_handshake',
|
|
@@ -63,59 +69,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
63
69
|
});
|
|
64
70
|
if (!isValid) {
|
|
65
71
|
return {
|
|
66
|
-
content: [
|
|
67
|
-
{
|
|
68
|
-
type: 'text',
|
|
69
|
-
text: JSON.stringify({
|
|
70
|
-
success: false,
|
|
71
|
-
error: 'Security Violation: Intent rejected by Semantic Firewall (V-01)',
|
|
72
|
-
}),
|
|
73
|
-
},
|
|
74
|
-
],
|
|
72
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Security Violation: Intent rejected by Semantic Firewall (V-01)' }) }],
|
|
75
73
|
isError: true,
|
|
76
74
|
};
|
|
77
75
|
}
|
|
78
76
|
try {
|
|
79
|
-
//
|
|
80
|
-
const
|
|
77
|
+
// Elegant & DRY: SDK handles RFC 8785 canonicalization and RAM hashing
|
|
78
|
+
const finalIntent = sealActionIntent(actionLabel, args.confidentialPayload);
|
|
79
|
+
const receipt = await rohanClient.submitHandshake({
|
|
81
80
|
agentId: args.agentId,
|
|
82
|
-
intent:
|
|
81
|
+
intent: finalIntent,
|
|
82
|
+
counterpartyId: args.counterpartyId,
|
|
83
83
|
});
|
|
84
|
-
// C. Proof an Relayer (Gas Station) übermitteln
|
|
85
|
-
const headers = { 'Content-Type': 'application/json' };
|
|
86
|
-
if (process.env.ROHAN_API_KEY) {
|
|
87
|
-
headers['x-rohan-api-key'] = process.env.ROHAN_API_KEY;
|
|
88
|
-
}
|
|
89
|
-
const response = await fetch(RELAYER_URL, {
|
|
90
|
-
method: 'POST',
|
|
91
|
-
headers,
|
|
92
|
-
body: JSON.stringify(proofData),
|
|
93
|
-
});
|
|
94
|
-
const receipt = await response.json();
|
|
95
84
|
return {
|
|
96
|
-
content: [
|
|
97
|
-
{
|
|
85
|
+
content: [{
|
|
98
86
|
type: 'text',
|
|
99
87
|
text: JSON.stringify({
|
|
100
88
|
status: 'success',
|
|
101
|
-
message: 'Zero-Knowledge Handshake
|
|
89
|
+
message: 'Zero-Knowledge Handshake successfully settled on Midnight Blockchain.',
|
|
102
90
|
receipt,
|
|
103
91
|
}, null, 2),
|
|
104
|
-
},
|
|
105
|
-
],
|
|
92
|
+
}],
|
|
106
93
|
};
|
|
107
94
|
}
|
|
108
95
|
catch (err) {
|
|
109
96
|
return {
|
|
110
|
-
content: [
|
|
111
|
-
{
|
|
112
|
-
type: 'text',
|
|
113
|
-
text: JSON.stringify({
|
|
114
|
-
success: false,
|
|
115
|
-
error: err.message || 'Handshake execution failed',
|
|
116
|
-
}),
|
|
117
|
-
},
|
|
118
|
-
],
|
|
97
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Handshake execution failed' }) }],
|
|
119
98
|
isError: true,
|
|
120
99
|
};
|
|
121
100
|
}
|
|
@@ -123,10 +102,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
123
102
|
async function run() {
|
|
124
103
|
const transport = new StdioServerTransport();
|
|
125
104
|
await server.connect(transport);
|
|
126
|
-
console.error('🛡️ Rohan Protocol MCP Server
|
|
105
|
+
console.error('🛡️ Rohan Protocol MCP Server running via stdio (v0.6.1)...');
|
|
127
106
|
}
|
|
128
107
|
run().catch((error) => {
|
|
129
|
-
console.error('
|
|
108
|
+
console.error('Fatal MCP server error:', error);
|
|
130
109
|
process.exit(1);
|
|
131
110
|
});
|
|
132
111
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAGA,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,MAAM,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rohan-protocol/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Model Context Protocol (MCP) Gateway for Rohan Protocol ZK-Handshakes",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@rohan-protocol/mcp",
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"description": "Model Context Protocol (MCP) Gateway for Rohan Protocol ZK-Handshakes",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"mcp",
|
|
10
|
+
"mcp-server",
|
|
11
|
+
"model-context-protocol",
|
|
12
|
+
"zero-knowledge",
|
|
13
|
+
"ai-agents",
|
|
14
|
+
"midnight-network",
|
|
15
|
+
"zk-handshake",
|
|
16
|
+
"semantic-firewall"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"start": "node dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
24
|
+
"@rohan-protocol/sdk": "^0.6.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "*",
|
|
28
|
+
"typescript": "^7.0.2"
|
|
29
|
+
},
|
|
30
|
+
"bin": "./dist/server.js"
|
|
21
31
|
}
|
package/server.json
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://static.modelcontextprotocol.io/
|
|
3
|
-
"name": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
"version": "0.5.1",
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schema/server.json",
|
|
3
|
+
"name": "rohan-protocol/mcp",
|
|
4
|
+
"version": "0.6.0",
|
|
5
|
+
"description": "Stateless zero-knowledge trust gateway and WebMCP shield for AI agents on Midnight.",
|
|
7
6
|
"repository": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/rohan-protocol/sdk.git"
|
|
10
9
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
"homepage": "https://rohanprotocol.network",
|
|
11
|
+
"bugs": "https://github.com/rohan-protocol/sdk/issues",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"runtime": "node",
|
|
14
|
+
"entrypoint": "packages/mcp/dist/server.js",
|
|
15
|
+
"transport": "stdio",
|
|
16
|
+
"tags": [
|
|
17
|
+
"zero-knowledge",
|
|
18
|
+
"privacy",
|
|
19
|
+
"security",
|
|
20
|
+
"midnight-network",
|
|
21
|
+
"handshake",
|
|
22
|
+
"ai-agents",
|
|
23
|
+
"webmcp",
|
|
24
|
+
"firewall"
|
|
22
25
|
],
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
]
|
|
26
|
+
"environment": {
|
|
27
|
+
"ROHAN_CONTRACT_ADDRESS": "585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e",
|
|
28
|
+
"ROHAN_RELAYER_URL": "https://api.rohanprotocol.network/api/v1/handshake"
|
|
29
|
+
}
|
|
29
30
|
}
|
package/smithery.yaml
CHANGED
|
@@ -14,7 +14,7 @@ startCommand:
|
|
|
14
14
|
args: ['-y', '@rohan-protocol/mcp@latest'],
|
|
15
15
|
env: {
|
|
16
16
|
ROHAN_FIREWALL_LEVEL: 'V-01_STRICT',
|
|
17
|
-
ROHAN_CONTRACT_ADDRESS: '
|
|
17
|
+
ROHAN_CONTRACT_ADDRESS: '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e',
|
|
18
18
|
ROHAN_RELAYER_URL: 'https://api.rohanprotocol.network/api/v1/handshake/stream',
|
|
19
19
|
...(config.rohanApiKey ? { ROHAN_API_KEY: config.rohanApiKey } : {})
|
|
20
20
|
}
|
package/src/firewall.ts
CHANGED
|
@@ -21,11 +21,11 @@ export class SemanticFirewall {
|
|
|
21
21
|
|
|
22
22
|
const serialized = JSON.stringify(intent.payload);
|
|
23
23
|
if (serialized.length > 8192) {
|
|
24
|
-
return false; // Denial-of-Service
|
|
24
|
+
return false; // Denial-of-Service Protection (Payload size cap)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (this.INJECTION_REGEX.test(serialized)) {
|
|
28
|
-
return false; // Prompt Injection
|
|
28
|
+
return false; // Semantic Prompt Injection detected
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return true;
|
package/src/gateway.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RohanRelayerClient } from '
|
|
1
|
+
import { RohanRelayerClient } from '@rohan-protocol/sdk';
|
|
2
2
|
|
|
3
3
|
export interface RohanMcpGatewayOptions {
|
|
4
4
|
transport?: 'stdio' | 'streamable-http';
|
|
@@ -8,7 +8,7 @@ export interface RohanMcpGatewayOptions {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* RohanMcpGateway
|
|
12
12
|
* Connects AI Agent pipelines (Google ADK 2.0, Gemini, Claude, Cursor)
|
|
13
13
|
* to the Rohan Protocol Gas Station via Streamable HTTP (NDJSON) or Stdio.
|
|
14
14
|
*/
|
|
@@ -20,7 +20,7 @@ export class RohanMcpGateway {
|
|
|
20
20
|
this.transport = options.transport || 'streamable-http';
|
|
21
21
|
this.relayerClient = new RohanRelayerClient({
|
|
22
22
|
relayerUrl: options.relayerUrl || 'http://127.0.0.1:4005/api/v1/handshake',
|
|
23
|
-
contractAddress: options.contractAddress || '
|
|
23
|
+
contractAddress: options.contractAddress || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e',
|
|
24
24
|
apiKey: options.apiKey,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -35,15 +35,14 @@ export class RohanMcpGateway {
|
|
|
35
35
|
parameters: {
|
|
36
36
|
type: 'object',
|
|
37
37
|
properties: {
|
|
38
|
-
agentId: { type: 'string', description: 'Identifier of calling agent' },
|
|
39
|
-
intent: { type: 'string', description: 'Semantic action intent' },
|
|
40
|
-
|
|
41
|
-
publicInputs: { type: 'object', description: 'Public inputs for on-chain verification' },
|
|
38
|
+
agentId: { type: 'string', description: 'Decentralized Identifier (DID) of calling agent' },
|
|
39
|
+
intent: { type: 'string', description: 'Semantic action intent or agreement payload' },
|
|
40
|
+
counterpartyId: { type: 'string', description: 'Optional recipient agent identifier' },
|
|
42
41
|
},
|
|
43
42
|
required: ['agentId', 'intent'],
|
|
44
43
|
},
|
|
45
44
|
execute: async (params: any) => {
|
|
46
|
-
return await this.relayerClient.
|
|
45
|
+
return await this.relayerClient.submitHandshake(params);
|
|
47
46
|
},
|
|
48
47
|
};
|
|
49
48
|
}
|
package/src/server.ts
CHANGED
|
@@ -9,22 +9,22 @@ import {
|
|
|
9
9
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
10
10
|
|
|
11
11
|
import { SemanticFirewall } from './firewall.js';
|
|
12
|
-
import { RohanClient } from '
|
|
12
|
+
import { RohanClient, sealActionIntent } from '@rohan-protocol/sdk';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
14
|
+
const CONTRACT_ADDRESS = process.env.ROHAN_CONTRACT_ADDRESS || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
|
|
15
|
+
const RELAYER_URL = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
|
|
16
|
+
const API_KEY = process.env.ROHAN_API_KEY || '';
|
|
17
17
|
|
|
18
|
-
const rohanClient = new RohanClient(
|
|
18
|
+
const rohanClient = new RohanClient({
|
|
19
|
+
contractAddress: CONTRACT_ADDRESS,
|
|
20
|
+
relayerUrl: RELAYER_URL,
|
|
21
|
+
apiKey: API_KEY,
|
|
22
|
+
});
|
|
19
23
|
|
|
20
|
-
/**
|
|
21
|
-
* 🛡️ ROHAN PROTOCOL MCP SERVER
|
|
22
|
-
* Ermöglicht KI-Agenten native Zero-Knowledge Handshakes über das Model Context Protocol.
|
|
23
|
-
*/
|
|
24
24
|
const server = new Server(
|
|
25
25
|
{
|
|
26
26
|
name: 'rohan-protocol-mcp',
|
|
27
|
-
version: '0.
|
|
27
|
+
version: '0.6.1',
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
capabilities: {
|
|
@@ -33,50 +33,60 @@ const server = new Server(
|
|
|
33
33
|
}
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
properties: {
|
|
47
|
-
agentId: {
|
|
48
|
-
type: 'string',
|
|
49
|
-
description: 'Die dezentrale Identität (DID) oder ID des initiierenden Agenten',
|
|
50
|
-
},
|
|
51
|
-
intent: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
description: 'Der semantische Aktionsplan oder Vereinbarungsinhalt, der im ZK-Proof versiegelt wird',
|
|
54
|
-
},
|
|
55
|
-
counterpartyId: {
|
|
56
|
-
type: 'string',
|
|
57
|
-
description: 'Optionale ID des Empfänger-Agenten',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
required: ['agentId', 'intent'],
|
|
61
|
-
},
|
|
36
|
+
export const ROHAN_TOOL_SCHEMA = {
|
|
37
|
+
name: 'rohan_zk_handshake',
|
|
38
|
+
description:
|
|
39
|
+
'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.',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
agentId: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'Decentralized Identifier (DID) of the initiating agent',
|
|
62
46
|
},
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
actionSummary: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: "Public high-level action label (e.g. 'Vendor Agreement Execution', 'Database Audit Anchor')",
|
|
50
|
+
},
|
|
51
|
+
confidentialPayload: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
description: 'OPTIONAL confidential parameters (budgets, deals, PII). Automatically canonicalized via RFC 8785 and hashed in local memory.',
|
|
54
|
+
},
|
|
55
|
+
counterpartyId: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'Optional counterparty agent identifier',
|
|
58
|
+
},
|
|
59
|
+
intent: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'Legacy fallback for actionSummary',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ['agentId'],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
69
|
+
return { tools: [ROHAN_TOOL_SCHEMA] };
|
|
65
70
|
});
|
|
66
71
|
|
|
67
|
-
// 2. Tool-Aufruf ausführen
|
|
68
72
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
69
73
|
if (request.params.name !== 'rohan_zk_handshake') {
|
|
70
|
-
throw new Error(`
|
|
74
|
+
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
const args = request.params.arguments as {
|
|
74
78
|
agentId: string;
|
|
75
|
-
|
|
79
|
+
actionSummary?: string;
|
|
80
|
+
confidentialPayload?: Record<string, unknown>;
|
|
76
81
|
counterpartyId?: string;
|
|
82
|
+
intent?: string;
|
|
77
83
|
};
|
|
78
84
|
|
|
79
|
-
|
|
85
|
+
const actionLabel = args.actionSummary || args.intent;
|
|
86
|
+
if (!actionLabel) {
|
|
87
|
+
throw new Error('Invalid arguments: Either actionSummary or intent is required.');
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
const isValid = SemanticFirewall.validate({
|
|
81
91
|
agentId: args.agentId,
|
|
82
92
|
action: 'rohan_zk_handshake',
|
|
@@ -85,67 +95,34 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
85
95
|
|
|
86
96
|
if (!isValid) {
|
|
87
97
|
return {
|
|
88
|
-
content: [
|
|
89
|
-
{
|
|
90
|
-
type: 'text',
|
|
91
|
-
text: JSON.stringify({
|
|
92
|
-
success: false,
|
|
93
|
-
error: 'Security Violation: Intent rejected by Semantic Firewall (V-01)',
|
|
94
|
-
}),
|
|
95
|
-
},
|
|
96
|
-
],
|
|
98
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Security Violation: Intent rejected by Semantic Firewall (V-01)' }) }],
|
|
97
99
|
isError: true,
|
|
98
100
|
};
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
try {
|
|
102
|
-
//
|
|
103
|
-
const
|
|
104
|
-
agentId: args.agentId,
|
|
105
|
-
intent: args.intent,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// C. Proof an Relayer (Gas Station) übermitteln
|
|
109
|
-
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
|
|
110
|
-
if (process.env.ROHAN_API_KEY) {
|
|
111
|
-
headers['x-rohan-api-key'] = process.env.ROHAN_API_KEY;
|
|
112
|
-
}
|
|
104
|
+
// Elegant & DRY: SDK handles RFC 8785 canonicalization and RAM hashing
|
|
105
|
+
const finalIntent = sealActionIntent(actionLabel, args.confidentialPayload);
|
|
113
106
|
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
107
|
+
const receipt = await rohanClient.submitHandshake({
|
|
108
|
+
agentId: args.agentId,
|
|
109
|
+
intent: finalIntent,
|
|
110
|
+
counterpartyId: args.counterpartyId,
|
|
118
111
|
});
|
|
119
112
|
|
|
120
|
-
const receipt = await response.json();
|
|
121
|
-
|
|
122
113
|
return {
|
|
123
|
-
content: [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
null,
|
|
133
|
-
2
|
|
134
|
-
),
|
|
135
|
-
},
|
|
136
|
-
],
|
|
114
|
+
content: [{
|
|
115
|
+
type: 'text',
|
|
116
|
+
text: JSON.stringify({
|
|
117
|
+
status: 'success',
|
|
118
|
+
message: 'Zero-Knowledge Handshake successfully settled on Midnight Blockchain.',
|
|
119
|
+
receipt,
|
|
120
|
+
}, null, 2),
|
|
121
|
+
}],
|
|
137
122
|
};
|
|
138
123
|
} catch (err: any) {
|
|
139
124
|
return {
|
|
140
|
-
content: [
|
|
141
|
-
{
|
|
142
|
-
type: 'text',
|
|
143
|
-
text: JSON.stringify({
|
|
144
|
-
success: false,
|
|
145
|
-
error: err.message || 'Handshake execution failed',
|
|
146
|
-
}),
|
|
147
|
-
},
|
|
148
|
-
],
|
|
125
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Handshake execution failed' }) }],
|
|
149
126
|
isError: true,
|
|
150
127
|
};
|
|
151
128
|
}
|
|
@@ -154,10 +131,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
154
131
|
async function run() {
|
|
155
132
|
const transport = new StdioServerTransport();
|
|
156
133
|
await server.connect(transport);
|
|
157
|
-
console.error('🛡️ Rohan Protocol MCP Server
|
|
134
|
+
console.error('🛡️ Rohan Protocol MCP Server running via stdio (v0.6.1)...');
|
|
158
135
|
}
|
|
159
136
|
|
|
160
137
|
run().catch((error) => {
|
|
161
|
-
console.error('
|
|
138
|
+
console.error('Fatal MCP server error:', error);
|
|
162
139
|
process.exit(1);
|
|
163
140
|
});
|