@rohan-protocol/mcp 0.7.0 β 0.8.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/README.md +44 -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/handshake.d.ts +42 -0
- package/dist/identity/handshake.d.ts.map +1 -0
- package/dist/identity/handshake.js +74 -0
- package/dist/identity/handshake.js.map +1 -0
- package/dist/identity/keystore.d.ts +27 -0
- package/dist/identity/keystore.d.ts.map +1 -0
- package/dist/identity/keystore.js +336 -0
- package/dist/identity/keystore.js.map +1 -0
- 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 +15 -30
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +69 -45
- 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/handshake.ts +82 -0
- package/src/identity/keystore.ts +385 -0
- package/src/server.ts +81 -48
- package/tests/firewall.test.js +9 -0
- package/tests/gateway.test.js +27 -0
- package/tests/identity.test.js +170 -0
package/dist/server.js
CHANGED
|
@@ -5,57 +5,36 @@ 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 { resolveAgentIdentity } from './identity/keystore.js';
|
|
9
|
+
import { resolveHandshakeAgentId, ROHAN_HANDSHAKE_TOOL_SCHEMA, validateHandshakeArguments, } from './identity/handshake.js';
|
|
10
|
+
export { ROHAN_HANDSHAKE_TOOL_SCHEMA };
|
|
8
11
|
const CONTRACT_ADDRESS = process.env.ROHAN_CONTRACT_ADDRESS || '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
|
|
9
12
|
const RELAYER_URL = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
|
|
10
13
|
const API_KEY = process.env.ROHAN_API_KEY || '';
|
|
14
|
+
const loadedIdentity = await resolveAgentIdentity();
|
|
15
|
+
const configuredSigner = loadedIdentity.signer;
|
|
16
|
+
console.error(`π‘οΈ [MCP V-08] Agent identity active (${loadedIdentity.source}): ${loadedIdentity.did}`);
|
|
17
|
+
if (loadedIdentity.filePath) {
|
|
18
|
+
console.error(`π‘οΈ [MCP V-08] Keystore path: ${loadedIdentity.filePath}`);
|
|
19
|
+
}
|
|
11
20
|
const rohanClient = new RohanClient({
|
|
12
21
|
contractAddress: CONTRACT_ADDRESS,
|
|
13
22
|
relayerUrl: RELAYER_URL,
|
|
14
23
|
apiKey: API_KEY,
|
|
24
|
+
signer: configuredSigner,
|
|
15
25
|
});
|
|
16
26
|
const server = new Server({
|
|
17
27
|
name: 'rohan-protocol-mcp',
|
|
18
|
-
version: '0.
|
|
28
|
+
version: '0.8.1',
|
|
19
29
|
}, {
|
|
20
30
|
capabilities: {
|
|
21
31
|
tools: {},
|
|
22
32
|
},
|
|
23
33
|
});
|
|
24
|
-
// ββ Tool 1 Schema: Write / Settlement βββββββββββββββββββββββββββββββββββββββ
|
|
25
|
-
export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
|
|
26
|
-
name: 'rohan_zk_handshake',
|
|
27
|
-
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
|
-
inputSchema: {
|
|
29
|
-
type: 'object',
|
|
30
|
-
properties: {
|
|
31
|
-
agentId: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
description: 'Decentralized Identifier (DID) of the initiating agent',
|
|
34
|
-
},
|
|
35
|
-
actionSummary: {
|
|
36
|
-
type: 'string',
|
|
37
|
-
description: "Public high-level action label (e.g. 'Vendor Agreement Execution', 'Database Audit Anchor')",
|
|
38
|
-
},
|
|
39
|
-
confidentialPayload: {
|
|
40
|
-
type: 'object',
|
|
41
|
-
description: 'OPTIONAL confidential parameters (budgets, deals, PII). Automatically canonicalized via RFC 8785 and hashed in local memory.',
|
|
42
|
-
},
|
|
43
|
-
counterpartyId: {
|
|
44
|
-
type: 'string',
|
|
45
|
-
description: 'Optional counterparty agent identifier',
|
|
46
|
-
},
|
|
47
|
-
intent: {
|
|
48
|
-
type: 'string',
|
|
49
|
-
description: 'Legacy fallback for actionSummary',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
required: ['agentId'],
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
34
|
// ββ Tool 2 Schema: Audit / In-Memory Verification βββββββββββββββββββββββββββ
|
|
56
35
|
export const ROHAN_VERIFY_TOOL_SCHEMA = {
|
|
57
36
|
name: 'rohan_verify_commitment',
|
|
58
|
-
description: '
|
|
37
|
+
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
38
|
inputSchema: {
|
|
60
39
|
type: 'object',
|
|
61
40
|
properties: {
|
|
@@ -66,7 +45,7 @@ export const ROHAN_VERIFY_TOOL_SCHEMA = {
|
|
|
66
45
|
expectedDigest: {
|
|
67
46
|
type: 'string',
|
|
68
47
|
pattern: '^(?:sha256:|0x)?[0-9a-fA-F]{64}$',
|
|
69
|
-
description: 'The
|
|
48
|
+
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
49
|
},
|
|
71
50
|
},
|
|
72
51
|
required: ['payload', 'expectedDigest'],
|
|
@@ -81,12 +60,26 @@ export const ROHAN_LEDGER_STATE_TOOL_SCHEMA = {
|
|
|
81
60
|
properties: {},
|
|
82
61
|
},
|
|
83
62
|
};
|
|
63
|
+
export const ROHAN_HISTORY_TOOL_SCHEMA = {
|
|
64
|
+
name: 'rohan_get_transaction_history',
|
|
65
|
+
description: 'Lists historical settlement transactions and receipts anchored on Midnight Preprod L1.',
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
limit: {
|
|
70
|
+
type: 'integer',
|
|
71
|
+
description: 'Maximum number of historical transactions to return (default: 10, max: 50).',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
84
76
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
85
77
|
return {
|
|
86
78
|
tools: [
|
|
87
79
|
ROHAN_HANDSHAKE_TOOL_SCHEMA,
|
|
88
|
-
ROHAN_VERIFY_TOOL_SCHEMA,
|
|
89
80
|
ROHAN_LEDGER_STATE_TOOL_SCHEMA,
|
|
81
|
+
ROHAN_HISTORY_TOOL_SCHEMA,
|
|
82
|
+
ROHAN_VERIFY_TOOL_SCHEMA,
|
|
90
83
|
],
|
|
91
84
|
};
|
|
92
85
|
});
|
|
@@ -101,14 +94,26 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
101
94
|
}
|
|
102
95
|
const args = rawArgs;
|
|
103
96
|
// ββ Tool 1: rohan_zk_handshake ββββββββββββββββββββββββββββββββββββββββββββ
|
|
104
|
-
if (toolName === 'rohan_zk_handshake') {
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
|
|
97
|
+
if (toolName === 'rohan_execute_handshake' || toolName === 'rohan_zk_handshake') {
|
|
98
|
+
const argumentsError = validateHandshakeArguments(args);
|
|
99
|
+
if (argumentsError) {
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: argumentsError }) }],
|
|
102
|
+
isError: true,
|
|
103
|
+
};
|
|
108
104
|
}
|
|
105
|
+
const identity = resolveHandshakeAgentId(args.agentId, configuredSigner);
|
|
106
|
+
if ('error' in identity) {
|
|
107
|
+
return {
|
|
108
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: identity.error }) }],
|
|
109
|
+
isError: true,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const effectiveAgentId = identity.agentId;
|
|
113
|
+
const actionLabel = args.actionSummary;
|
|
109
114
|
const isValid = SemanticFirewall.validate({
|
|
110
|
-
agentId:
|
|
111
|
-
action: '
|
|
115
|
+
agentId: effectiveAgentId,
|
|
116
|
+
action: 'rohan_execute_handshake',
|
|
112
117
|
payload: args,
|
|
113
118
|
});
|
|
114
119
|
if (!isValid) {
|
|
@@ -120,7 +125,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
120
125
|
try {
|
|
121
126
|
const finalIntent = sealActionIntent(actionLabel, args.confidentialPayload);
|
|
122
127
|
const receipt = await rohanClient.submitHandshake({
|
|
123
|
-
agentId:
|
|
128
|
+
agentId: effectiveAgentId,
|
|
124
129
|
intent: finalIntent,
|
|
125
130
|
counterpartyId: args.counterpartyId,
|
|
126
131
|
});
|
|
@@ -129,7 +134,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
129
134
|
type: 'text',
|
|
130
135
|
text: JSON.stringify({
|
|
131
136
|
status: 'success',
|
|
132
|
-
message: 'Zero-Knowledge Handshake successfully settled on Midnight Blockchain.',
|
|
137
|
+
message: 'Zero-Knowledge Handshake successfully settled on Midnight Blockchain with Sovereign Identity (V-08).',
|
|
138
|
+
agentDid: effectiveAgentId,
|
|
133
139
|
receipt,
|
|
134
140
|
}, null, 2),
|
|
135
141
|
}],
|
|
@@ -176,7 +182,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
176
182
|
// Single Source of Truth: Canonicalization via @rohan-protocol/sdk
|
|
177
183
|
const canonicalPayload = canonicalizeJson(args.payload);
|
|
178
184
|
const computedDigest = crypto.createHash('sha256').update(canonicalPayload, 'utf8').digest('hex').toLowerCase();
|
|
179
|
-
const match = computedDigest
|
|
185
|
+
const match = crypto.timingSafeEqual(Buffer.from(computedDigest, 'hex'), Buffer.from(normalizedExpected, 'hex'));
|
|
180
186
|
return {
|
|
181
187
|
content: [{
|
|
182
188
|
type: 'text',
|
|
@@ -229,12 +235,30 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
229
235
|
};
|
|
230
236
|
}
|
|
231
237
|
}
|
|
238
|
+
if (toolName === 'rohan_get_transaction_history') {
|
|
239
|
+
try {
|
|
240
|
+
const rawLimit = Number(args.limit) || 10;
|
|
241
|
+
const history = await rohanClient.getTransactionHistory(rawLimit);
|
|
242
|
+
return {
|
|
243
|
+
content: [{
|
|
244
|
+
type: 'text',
|
|
245
|
+
text: JSON.stringify({ status: 'success', ...history }, null, 2),
|
|
246
|
+
}],
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
return {
|
|
251
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error: err.message || 'Failed to fetch transaction history' }) }],
|
|
252
|
+
isError: true,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
232
256
|
throw new Error(`Unknown tool: ${toolName}`);
|
|
233
257
|
});
|
|
234
258
|
async function run() {
|
|
235
259
|
const transport = new StdioServerTransport();
|
|
236
260
|
await server.connect(transport);
|
|
237
|
-
console.error('π‘οΈ Rohan Protocol MCP Server running via stdio (v0.
|
|
261
|
+
console.error('π‘οΈ Rohan Protocol MCP Server running via stdio (v0.8.1)...');
|
|
238
262
|
}
|
|
239
263
|
run().catch((error) => {
|
|
240
264
|
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,
|
|
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,EAAoB,MAAM,qBAAqB,CAAC;AACxG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,CAAC;AAEvC,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,kEAAkE,CAAC;AAClI,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,oDAAoD,CAAC;AAC1G,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;AAChD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,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.1",
|
|
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.1"
|
|
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.1",
|
|
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.1",
|
|
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 to override the auto-provisioned local identity. 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
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { AgentSigner } from '@rohan-protocol/sdk';
|
|
2
|
+
|
|
3
|
+
export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
|
|
4
|
+
name: 'rohan_execute_handshake',
|
|
5
|
+
description:
|
|
6
|
+
'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.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
actionSummary: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
minLength: 1,
|
|
13
|
+
description: 'Required public high-level action label.',
|
|
14
|
+
},
|
|
15
|
+
agentId: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: "Optional Sovereign Agent DID. Defaults to the local signer's DID and must match it when provided.",
|
|
18
|
+
},
|
|
19
|
+
confidentialPayload: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
description: 'Optional confidential parameters, canonicalized and hashed locally.',
|
|
22
|
+
},
|
|
23
|
+
counterpartyId: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Optional counterparty agent identifier.',
|
|
26
|
+
},
|
|
27
|
+
intent: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
deprecated: true,
|
|
30
|
+
description: 'Deprecated alias. actionSummary remains required.',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ['actionSummary'],
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
},
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
export function validateActionSummary(value: unknown): string | undefined {
|
|
39
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
40
|
+
return 'INVALID_ARGUMENTS: actionSummary is required and cannot be empty.';
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function validateHandshakeArguments(args: Record<string, unknown>): string | undefined {
|
|
46
|
+
const allowedProperties = new Set([
|
|
47
|
+
'actionSummary',
|
|
48
|
+
'agentId',
|
|
49
|
+
'confidentialPayload',
|
|
50
|
+
'counterpartyId',
|
|
51
|
+
'intent',
|
|
52
|
+
]);
|
|
53
|
+
if (Object.keys(args).some((key) => !allowedProperties.has(key))) {
|
|
54
|
+
return 'INVALID_ARGUMENTS: Handshake arguments contain unsupported properties.';
|
|
55
|
+
}
|
|
56
|
+
if (args.intent !== undefined && typeof args.intent !== 'string') {
|
|
57
|
+
return 'INVALID_ARGUMENTS: Deprecated intent must be a string when provided.';
|
|
58
|
+
}
|
|
59
|
+
return validateActionSummary(args.actionSummary);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function resolveHandshakeAgentId(
|
|
63
|
+
requestedAgentId: unknown,
|
|
64
|
+
signer?: AgentSigner
|
|
65
|
+
): { agentId: string } | { error: string } {
|
|
66
|
+
if (signer) {
|
|
67
|
+
if (requestedAgentId === undefined) return { agentId: signer.did };
|
|
68
|
+
if (typeof requestedAgentId !== 'string' || requestedAgentId !== signer.did) {
|
|
69
|
+
return {
|
|
70
|
+
error: 'IDENTITY_MISMATCH: Declared agentId does not match the armed Sovereign Signer DID.',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return { agentId: signer.did };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (typeof requestedAgentId !== 'string' || requestedAgentId.trim().length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
error: 'MISSING_AGENT_ID: An explicit agentId is required when no Sovereign Signer is armed.',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return { agentId: requestedAgentId };
|
|
82
|
+
}
|