@rohan-protocol/mcp 0.8.0 → 0.8.2
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 +49 -61
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +304 -0
- package/dist/cli.js.map +1 -0
- 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/mcp-app.d.ts +136 -0
- package/dist/mcp-app.d.ts.map +1 -0
- package/dist/mcp-app.js +401 -0
- package/dist/mcp-app.js.map +1 -0
- package/dist/server.d.ts +37 -64
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +50 -270
- package/dist/server.js.map +1 -1
- package/package.json +6 -2
- package/server.json +0 -46
- package/smithery.yaml +0 -23
- package/src/firewall.ts +0 -37
- package/src/gateway.ts +0 -59
- package/src/identity.ts +0 -56
- package/src/index.ts +0 -2
- package/src/server.ts +0 -321
- package/tests/firewall.test.js +0 -75
- package/tests/gateway.test.js +0 -27
- package/tests/identity.test.js +0 -32
- package/tsconfig.json +0 -17
package/dist/mcp-app.js
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { sealActionIntent, canonicalizeJson, verifyAuditBundle, } from '@rohan-protocol/sdk';
|
|
5
|
+
import { SemanticFirewall } from './firewall.js';
|
|
6
|
+
import { resolveHandshakeAgentId, ROHAN_HANDSHAKE_TOOL_SCHEMA, validateHandshakeArguments, } from './identity/handshake.js';
|
|
7
|
+
export const ROHAN_MCP_VERSION = '0.8.2';
|
|
8
|
+
export const ROHAN_MCP_INSTRUCTIONS = `
|
|
9
|
+
Rohan Protocol provides gas-free confidential commitments and Ed25519 (W3C did:key) non-repudiation on Midnight Network (Ledger v9).
|
|
10
|
+
|
|
11
|
+
CORE RULES FOR AGENTS:
|
|
12
|
+
1. PRIVACY BOUNDARY: Always place sensitive parameters (budgets, prices, counterparties, PII, contract terms) inside \`confidentialPayload\`. Keep \`actionSummary\` generic and non-sensitive (e.g., "Vendor Procurement Authorization").
|
|
13
|
+
2. PRIVATE KEYS: Never ask the user for private keys or pass private keys in tool arguments. Local stdio identity is managed automatically (~/.rohan/agent-identity.json or ROHAN_AGENT_PRIVATE_KEY). Do not invent an \`agentId\` when a local signer is active.
|
|
14
|
+
3. IDENTITY & STATUS: To check your active \`did:key\`, network, or relayer health, read \`rohan://identity\` or call \`rohan_get_agent_status\`.
|
|
15
|
+
4. AUDIT VERIFICATION: \`rohan_verify_commitment\` checks plaintext against the **inner \`payloadDigest\`** (RFC 8785 JCS + SHA-256, referenced in \`actionSummary\` or \`auditBundle.payloadDigest\`), NOT the outer timestamp-salted \`intentHash\`. You can also pass an entire \`auditBundle\` to verify signature and binding offline.
|
|
16
|
+
5. ERROR RECOVERY:
|
|
17
|
+
- \`REPLAY_DETECTED\` (409): Do NOT retry the same payload/nonce. Call \`rohan_get_transaction_history\` to inspect existing settlements.
|
|
18
|
+
- \`STALE_TIMESTAMP\` (401): Retry with a fresh tool invocation.
|
|
19
|
+
- \`INVALID_SIGNATURE\` (401): Call \`rohan_get_agent_status\` to verify the active identity and relayer status before retrying.
|
|
20
|
+
- \`IDENTITY_MISMATCH\` (403): Omit \`agentId\` so the active signer's DID is used automatically.
|
|
21
|
+
`.trim();
|
|
22
|
+
// ── Tool Schemas with MCP Annotations ───────────────────────────────────────
|
|
23
|
+
export const ROHAN_EXECUTE_TOOL_WITH_ANNOTATIONS = {
|
|
24
|
+
...ROHAN_HANDSHAKE_TOOL_SCHEMA,
|
|
25
|
+
annotations: {
|
|
26
|
+
title: 'Execute Confidential ZK Handshake',
|
|
27
|
+
readOnlyHint: false,
|
|
28
|
+
destructiveHint: false,
|
|
29
|
+
idempotentHint: false,
|
|
30
|
+
openWorldHint: true,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const ROHAN_VERIFY_TOOL_SCHEMA = {
|
|
34
|
+
name: 'rohan_verify_commitment',
|
|
35
|
+
description: 'Cryptographically audits a plaintext payload and/or a portable RohanAuditBundle offline in local memory (0 gas). Provide either expectedDigest with payload, or auditBundle (with optional payload for plaintext verification). Never pass the outer timestamp-salted intentHash as expectedDigest.',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
payload: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
description: 'Plaintext contract, agreement, or confidential data object to verify.',
|
|
42
|
+
},
|
|
43
|
+
expectedDigest: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
pattern: '^(?:sha256:|0x)?[0-9a-fA-F]{64}$',
|
|
46
|
+
description: 'Expected inner SHA-256 digest of the canonicalized payload (from actionSummary digest: sha256:<hash> or auditBundle.payloadDigest). Accepts raw hex, 0x, or sha256: prefixes.',
|
|
47
|
+
},
|
|
48
|
+
auditBundle: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
description: 'Optional portable RohanAuditBundle (schema: rohan-audit-bundle/v1) returned by rohan_execute_handshake. Verifies Ed25519 signature, intentHash binding, and payloadDigest.',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
required: [],
|
|
54
|
+
},
|
|
55
|
+
annotations: {
|
|
56
|
+
title: 'Verify Commitment & Audit Bundle',
|
|
57
|
+
readOnlyHint: true,
|
|
58
|
+
destructiveHint: false,
|
|
59
|
+
idempotentHint: true,
|
|
60
|
+
openWorldHint: false,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const ROHAN_LEDGER_STATE_TOOL_SCHEMA = {
|
|
64
|
+
name: 'rohan_get_ledger_state',
|
|
65
|
+
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.',
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {},
|
|
69
|
+
},
|
|
70
|
+
annotations: {
|
|
71
|
+
title: 'Get Midnight Ledger State',
|
|
72
|
+
readOnlyHint: true,
|
|
73
|
+
destructiveHint: false,
|
|
74
|
+
idempotentHint: true,
|
|
75
|
+
openWorldHint: true,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
export const ROHAN_HISTORY_TOOL_SCHEMA = {
|
|
79
|
+
name: 'rohan_get_transaction_history',
|
|
80
|
+
description: 'Lists historical settlement transactions and receipts anchored on Midnight Preprod L1.',
|
|
81
|
+
inputSchema: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
limit: {
|
|
85
|
+
type: 'integer',
|
|
86
|
+
description: 'Maximum number of historical transactions to return (default: 10, max: 50).',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
annotations: {
|
|
91
|
+
title: 'Get Transaction History',
|
|
92
|
+
readOnlyHint: true,
|
|
93
|
+
destructiveHint: false,
|
|
94
|
+
idempotentHint: true,
|
|
95
|
+
openWorldHint: true,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
export const ROHAN_AGENT_STATUS_TOOL_SCHEMA = {
|
|
99
|
+
name: 'rohan_get_agent_status',
|
|
100
|
+
description: 'Returns the local Sovereign Agent identity (W3C did:key), signing mode, configured network, and live relayer reachability/block height (gracefully degrades if relayer is offline). Never exposes private keys.',
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {},
|
|
104
|
+
},
|
|
105
|
+
annotations: {
|
|
106
|
+
title: 'Get Sovereign Agent Status',
|
|
107
|
+
readOnlyHint: true,
|
|
108
|
+
destructiveHint: false,
|
|
109
|
+
idempotentHint: true,
|
|
110
|
+
openWorldHint: true,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
// ── Response Builders (Always provide both content[] and structuredContent) ──
|
|
114
|
+
function buildSuccessResult(payload) {
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
|
|
117
|
+
structuredContent: payload,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function buildErrorResult(code, message, retryable, recoveryAction) {
|
|
121
|
+
const payload = {
|
|
122
|
+
success: false,
|
|
123
|
+
code,
|
|
124
|
+
retryable,
|
|
125
|
+
error: message,
|
|
126
|
+
recoveryAction,
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
|
|
130
|
+
structuredContent: payload,
|
|
131
|
+
isError: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function classifyRelayerError(errMessage) {
|
|
135
|
+
const msg = errMessage || 'Unknown execution error';
|
|
136
|
+
if (/nonce.*already.*used|REPLAY_DETECTED|409/i.test(msg)) {
|
|
137
|
+
return buildErrorResult('REPLAY_DETECTED', msg, false, 'Nonce already consumed. Call rohan_get_transaction_history to retrieve the existing settlement receipt instead of retrying.');
|
|
138
|
+
}
|
|
139
|
+
if (/STALE_TIMESTAMP|timestamp.*skew|window/i.test(msg)) {
|
|
140
|
+
return buildErrorResult('STALE_TIMESTAMP', msg, true, 'Request timestamp fell outside the allowed ±5 minute clock window. Retry with a fresh tool invocation.');
|
|
141
|
+
}
|
|
142
|
+
if (/IDENTITY_MISMATCH|SIGNER_MISMATCH/i.test(msg)) {
|
|
143
|
+
return buildErrorResult('IDENTITY_MISMATCH', msg, false, 'Omit agentId so the active signer DID is injected automatically, or pass the exact DID from rohan://identity.');
|
|
144
|
+
}
|
|
145
|
+
if (/INVALID_SIGNATURE|UNAUTHORIZED|AUTHENTICATION_FAILED|401/i.test(msg)) {
|
|
146
|
+
return buildErrorResult('INVALID_SIGNATURE', msg, false, 'Ed25519 signature verification failed on the relayer. Call rohan_get_agent_status to verify active DID, network alignment, and local keystore integrity.');
|
|
147
|
+
}
|
|
148
|
+
if (/QUEUE_CAPACITY|503|RELAYER_OVERLOADED/i.test(msg)) {
|
|
149
|
+
return buildErrorResult('RELAYER_BUSY', msg, true, 'Relayer settlement queue is temporarily full. Wait 5 seconds and retry.');
|
|
150
|
+
}
|
|
151
|
+
return buildErrorResult('EXECUTION_FAILED', msg, false, 'Inspect the error details and verify network connectivity or arguments before retrying.');
|
|
152
|
+
}
|
|
153
|
+
async function withTimeout(promise, timeoutMs, message) {
|
|
154
|
+
let timeout;
|
|
155
|
+
try {
|
|
156
|
+
return await Promise.race([
|
|
157
|
+
promise,
|
|
158
|
+
new Promise((_, reject) => {
|
|
159
|
+
timeout = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
160
|
+
}),
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
if (timeout)
|
|
165
|
+
clearTimeout(timeout);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
export function createRohanMcpServer(options) {
|
|
169
|
+
const { contractAddress, relayerUrl, network = 'preprod', rohanClient, configuredSigner, loadedIdentity, statusTimeoutMs = 8500, } = options;
|
|
170
|
+
const cleanRelayerOrigin = relayerUrl.replace(/\/api\/v1\/handshake(?:\/stream)?$/, '');
|
|
171
|
+
const getIdentitySnapshot = () => ({
|
|
172
|
+
agentDid: configuredSigner?.did ?? loadedIdentity?.did ?? null,
|
|
173
|
+
signingMode: configuredSigner ? 'ed25519' : 'unsigned',
|
|
174
|
+
identitySource: loadedIdentity?.source ?? (configuredSigner ? 'injected' : 'remote-gateway'),
|
|
175
|
+
keystorePath: loadedIdentity?.filePath ?? null,
|
|
176
|
+
network: `midnight-${network}`,
|
|
177
|
+
contractAddress,
|
|
178
|
+
relayerUrl: cleanRelayerOrigin,
|
|
179
|
+
});
|
|
180
|
+
const server = new Server({
|
|
181
|
+
name: 'rohan-protocol-mcp',
|
|
182
|
+
version: ROHAN_MCP_VERSION,
|
|
183
|
+
}, {
|
|
184
|
+
capabilities: {
|
|
185
|
+
tools: {},
|
|
186
|
+
resources: {},
|
|
187
|
+
},
|
|
188
|
+
instructions: ROHAN_MCP_INSTRUCTIONS,
|
|
189
|
+
});
|
|
190
|
+
// ── Resources ─────────────────────────────────────────────────────────────
|
|
191
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
192
|
+
return {
|
|
193
|
+
resources: [
|
|
194
|
+
{
|
|
195
|
+
uri: 'rohan://identity',
|
|
196
|
+
name: 'Rohan Sovereign Agent Identity',
|
|
197
|
+
description: 'Read-only metadata describing the active Ed25519 W3C did:key identity, signing mode, keystore path, and Midnight contract context.',
|
|
198
|
+
mimeType: 'application/json',
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
204
|
+
if (request.params.uri !== 'rohan://identity') {
|
|
205
|
+
throw new Error(`Resource not found: ${request.params.uri}`);
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
contents: [
|
|
209
|
+
{
|
|
210
|
+
uri: 'rohan://identity',
|
|
211
|
+
mimeType: 'application/json',
|
|
212
|
+
text: JSON.stringify(getIdentitySnapshot(), null, 2),
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
// ── Tools Discovery ───────────────────────────────────────────────────────
|
|
218
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
219
|
+
return {
|
|
220
|
+
tools: [
|
|
221
|
+
ROHAN_EXECUTE_TOOL_WITH_ANNOTATIONS,
|
|
222
|
+
ROHAN_LEDGER_STATE_TOOL_SCHEMA,
|
|
223
|
+
ROHAN_HISTORY_TOOL_SCHEMA,
|
|
224
|
+
ROHAN_VERIFY_TOOL_SCHEMA,
|
|
225
|
+
ROHAN_AGENT_STATUS_TOOL_SCHEMA,
|
|
226
|
+
],
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
// ── Tool Execution ────────────────────────────────────────────────────────
|
|
230
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
231
|
+
const toolName = request.params.name;
|
|
232
|
+
const rawArgs = request.params?.arguments === undefined ? {} : request.params.arguments;
|
|
233
|
+
if (!rawArgs || typeof rawArgs !== 'object' || Array.isArray(rawArgs)) {
|
|
234
|
+
return buildErrorResult('INVALID_ARGUMENTS', 'Expected a valid arguments object.', true, 'Pass a JSON object as tool arguments (or omit arguments for parameterless read tools).');
|
|
235
|
+
}
|
|
236
|
+
const args = rawArgs;
|
|
237
|
+
// ── Tool 1: rohan_execute_handshake (legacy alias: rohan_zk_handshake) ──
|
|
238
|
+
if (toolName === 'rohan_execute_handshake' || toolName === 'rohan_zk_handshake') {
|
|
239
|
+
const argumentsError = validateHandshakeArguments(args);
|
|
240
|
+
if (argumentsError) {
|
|
241
|
+
return buildErrorResult('INVALID_ARGUMENTS', argumentsError, true, 'Provide a non-empty actionSummary string and an object for confidentialPayload (if included).');
|
|
242
|
+
}
|
|
243
|
+
const identity = resolveHandshakeAgentId(args.agentId, configuredSigner);
|
|
244
|
+
if ('error' in identity) {
|
|
245
|
+
return buildErrorResult('IDENTITY_MISMATCH', identity.error, false, 'Omit agentId so the active signer DID is used automatically, or supply the exact DID from rohan://identity.');
|
|
246
|
+
}
|
|
247
|
+
const effectiveAgentId = identity.agentId;
|
|
248
|
+
const actionLabel = args.actionSummary;
|
|
249
|
+
const isValid = SemanticFirewall.validate({
|
|
250
|
+
agentId: effectiveAgentId,
|
|
251
|
+
action: 'rohan_execute_handshake',
|
|
252
|
+
payload: args,
|
|
253
|
+
});
|
|
254
|
+
if (!isValid) {
|
|
255
|
+
return buildErrorResult('FIREWALL_REJECTED', 'Security Violation: Intent rejected by Semantic Firewall (V-01)', false, 'Ensure actionSummary and confidentialPayload contain valid, non-malicious content under 8 KB.');
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
const finalIntent = sealActionIntent(actionLabel, args.confidentialPayload);
|
|
259
|
+
const receipt = await rohanClient.submitHandshake({
|
|
260
|
+
agentId: effectiveAgentId,
|
|
261
|
+
intent: finalIntent,
|
|
262
|
+
counterpartyId: args.counterpartyId,
|
|
263
|
+
});
|
|
264
|
+
// Deduplicate payloadDigest & auditBundle so we don't double-send them in the LLM context
|
|
265
|
+
const { auditBundle, payloadDigest, ...cleanReceipt } = receipt;
|
|
266
|
+
return buildSuccessResult({
|
|
267
|
+
status: 'success',
|
|
268
|
+
message: 'Zero-Knowledge Handshake successfully settled on Midnight Blockchain with Sovereign Identity (V-08).',
|
|
269
|
+
agentDid: effectiveAgentId,
|
|
270
|
+
...(payloadDigest ? { payloadDigest } : {}),
|
|
271
|
+
...(auditBundle ? { auditBundle } : {}),
|
|
272
|
+
receipt: cleanReceipt,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
return classifyRelayerError(err?.message || 'Handshake execution failed');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// ── Tool 2: rohan_get_ledger_state ──────────────────────────────────────
|
|
280
|
+
if (toolName === 'rohan_get_ledger_state') {
|
|
281
|
+
try {
|
|
282
|
+
const ledgerState = await rohanClient.getLedgerState();
|
|
283
|
+
const cacheAgeMs = Date.now() - (ledgerState.fetchedAt || Date.now());
|
|
284
|
+
return buildSuccessResult({
|
|
285
|
+
status: 'success',
|
|
286
|
+
contractAddress: ledgerState.contractAddress,
|
|
287
|
+
currentStateRoot: ledgerState.currentStateRoot,
|
|
288
|
+
blockHeight: ledgerState.blockHeight ?? null,
|
|
289
|
+
lastTxHash: ledgerState.lastTxHash ?? null,
|
|
290
|
+
network: ledgerState.network || `midnight-${network}`,
|
|
291
|
+
isMinedOnChain: ledgerState.isMinedOnChain ?? true,
|
|
292
|
+
cacheAgeMs: ledgerState.cacheAgeMs ?? cacheAgeMs,
|
|
293
|
+
cacheTtlMs: ledgerState.cacheTtlMs ?? 15000,
|
|
294
|
+
fetchedAt: ledgerState.fetchedAt,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
return buildErrorResult('RELAYER_UNREACHABLE', err?.message || 'Failed to fetch ledger state', true, 'Verify relayer connectivity or call rohan_get_agent_status to inspect relayer health.');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// ── Tool 3: rohan_get_transaction_history ───────────────────────────────
|
|
302
|
+
if (toolName === 'rohan_get_transaction_history') {
|
|
303
|
+
try {
|
|
304
|
+
const rawLimit = Number(args.limit) || 10;
|
|
305
|
+
const history = await rohanClient.getTransactionHistory(rawLimit);
|
|
306
|
+
return buildSuccessResult({ status: 'success', ...history });
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
return buildErrorResult('HISTORY_FETCH_FAILED', err?.message || 'Failed to fetch transaction history', true, 'Retry shortly or check relayer connectivity via rohan_get_agent_status.');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// ── Tool 4: rohan_verify_commitment (Digest &/or AuditBundle) ───────────
|
|
313
|
+
if (toolName === 'rohan_verify_commitment') {
|
|
314
|
+
const hasBundle = args.auditBundle !== undefined;
|
|
315
|
+
const hasDigest = args.expectedDigest !== undefined;
|
|
316
|
+
if (!hasBundle && !hasDigest) {
|
|
317
|
+
return buildErrorResult('INVALID_ARGUMENTS', 'Missing verification target: provide either auditBundle, or expectedDigest together with payload.', true, 'Pass { payload, expectedDigest } using the inner payloadDigest, or pass { auditBundle, payload } from rohan_execute_handshake.');
|
|
318
|
+
}
|
|
319
|
+
if (args.payload !== undefined) {
|
|
320
|
+
if (!args.payload || typeof args.payload !== 'object' || Array.isArray(args.payload)) {
|
|
321
|
+
return buildErrorResult('INVALID_PAYLOAD', 'Invalid argument: payload must be a non-null JSON object.', true, 'Pass a valid JSON object as payload.');
|
|
322
|
+
}
|
|
323
|
+
const payloadString = JSON.stringify(args.payload);
|
|
324
|
+
if (payloadString.length > 256 * 1024) {
|
|
325
|
+
return buildErrorResult('PAYLOAD_TOO_LARGE', 'Plaintext exceeds maximum allowed size of 256 KB.', false, 'Reduce payload size below 256 KB before verifying.');
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (hasBundle) {
|
|
329
|
+
if (!args.auditBundle || typeof args.auditBundle !== 'object' || Array.isArray(args.auditBundle)) {
|
|
330
|
+
return buildErrorResult('INVALID_AUDIT_BUNDLE', 'Invalid argument: auditBundle must be a non-null JSON object.', true, 'Pass the complete auditBundle object returned by rohan_execute_handshake.');
|
|
331
|
+
}
|
|
332
|
+
try {
|
|
333
|
+
const result = await verifyAuditBundle(args.auditBundle, args.payload);
|
|
334
|
+
return buildSuccessResult({
|
|
335
|
+
status: 'success',
|
|
336
|
+
mode: 'audit-bundle',
|
|
337
|
+
...result,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
catch (err) {
|
|
341
|
+
return buildErrorResult('VERIFICATION_ERROR', err?.message || 'Audit bundle verification failed', false, 'Ensure auditBundle conforms to rohan-audit-bundle/v1.');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (!args.payload) {
|
|
345
|
+
return buildErrorResult('MISSING_PAYLOAD', 'Invalid argument: payload is required when verifying against expectedDigest.', true, 'Pass the confidential plaintext object as payload alongside expectedDigest.');
|
|
346
|
+
}
|
|
347
|
+
if (typeof args.expectedDigest !== 'string') {
|
|
348
|
+
return buildErrorResult('INVALID_DIGEST', 'Invalid argument: expectedDigest must be a string.', true, 'Pass the 64-character hex SHA-256 payloadDigest (with optional sha256: or 0x prefix).');
|
|
349
|
+
}
|
|
350
|
+
const normalizedExpected = args.expectedDigest.replace(/^(?:sha256:|0x)/i, '').toLowerCase();
|
|
351
|
+
if (!/^[0-9a-f]{64}$/.test(normalizedExpected)) {
|
|
352
|
+
return buildErrorResult('INVALID_DIGEST', 'Invalid expectedDigest: must resolve to a 64-character hexadecimal SHA-256 hash.', true, 'Pass the inner payloadDigest (NOT the outer salted intentHash if malformed).');
|
|
353
|
+
}
|
|
354
|
+
try {
|
|
355
|
+
const canonicalPayload = canonicalizeJson(args.payload);
|
|
356
|
+
const computedDigest = crypto.createHash('sha256').update(canonicalPayload, 'utf8').digest('hex').toLowerCase();
|
|
357
|
+
const match = crypto.timingSafeEqual(Buffer.from(computedDigest, 'hex'), Buffer.from(normalizedExpected, 'hex'));
|
|
358
|
+
return buildSuccessResult({
|
|
359
|
+
status: 'success',
|
|
360
|
+
mode: 'digest',
|
|
361
|
+
valid: match,
|
|
362
|
+
match,
|
|
363
|
+
expectedDigest: normalizedExpected,
|
|
364
|
+
computedDigest,
|
|
365
|
+
algorithm: 'SHA-256 (RFC 8785 JCS)',
|
|
366
|
+
verifiedAt: Date.now(),
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
return buildErrorResult('VERIFICATION_ERROR', err?.message || 'Verification execution failed', false, 'Ensure payload is valid JSON under 32 nesting levels.');
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
// ── Tool 5: rohan_get_agent_status (Graceful Offline Degradation) ───────
|
|
374
|
+
if (toolName === 'rohan_get_agent_status') {
|
|
375
|
+
const base = getIdentitySnapshot();
|
|
376
|
+
try {
|
|
377
|
+
const state = await withTimeout(rohanClient.getLedgerState(), statusTimeoutMs, `Relayer status check timed out after ${statusTimeoutMs}ms`);
|
|
378
|
+
return buildSuccessResult({
|
|
379
|
+
status: 'success',
|
|
380
|
+
...base,
|
|
381
|
+
relayerHealthy: true,
|
|
382
|
+
currentBlockHeight: state.blockHeight ?? null,
|
|
383
|
+
currentStateRoot: state.currentStateRoot ?? null,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
catch (err) {
|
|
387
|
+
return buildSuccessResult({
|
|
388
|
+
status: 'degraded',
|
|
389
|
+
...base,
|
|
390
|
+
relayerHealthy: false,
|
|
391
|
+
currentBlockHeight: null,
|
|
392
|
+
currentStateRoot: null,
|
|
393
|
+
relayerError: err?.message || 'Relayer unreachable',
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return buildErrorResult('UNKNOWN_TOOL', `Unknown tool: ${toolName}`, false, 'Call tools/list to inspect the 5 supported Rohan Protocol tools.');
|
|
398
|
+
});
|
|
399
|
+
return server;
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=mcp-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-app.js","sourceRoot":"","sources":["../src/mcp-app.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAIlB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AAGjC,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAEzC,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;CAarC,CAAC,IAAI,EAAE,CAAC;AAET,+EAA+E;AAE/E,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,GAAG,2BAA2B;IAC9B,WAAW,EAAE;QACX,KAAK,EAAE,mCAAmC;QAC1C,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,KAAK;QACrB,a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
|
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[];
|
|
2
|
+
import { ROHAN_HANDSHAKE_TOOL_SCHEMA } from './identity/handshake.js';
|
|
3
|
+
import { createRohanMcpServer, ROHAN_MCP_INSTRUCTIONS, ROHAN_EXECUTE_TOOL_WITH_ANNOTATIONS, ROHAN_VERIFY_TOOL_SCHEMA, ROHAN_LEDGER_STATE_TOOL_SCHEMA, ROHAN_HISTORY_TOOL_SCHEMA, ROHAN_AGENT_STATUS_TOOL_SCHEMA } from './mcp-app.js';
|
|
4
|
+
export declare const ROHAN_EXECUTE_TOOL_SCHEMA: {
|
|
5
|
+
annotations: {
|
|
6
|
+
title: string;
|
|
7
|
+
readOnlyHint: boolean;
|
|
8
|
+
destructiveHint: boolean;
|
|
9
|
+
idempotentHint: boolean;
|
|
10
|
+
openWorldHint: boolean;
|
|
30
11
|
};
|
|
31
|
-
|
|
32
|
-
|
|
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;
|
|
12
|
+
name: "rohan_execute_handshake";
|
|
13
|
+
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.";
|
|
62
14
|
inputSchema: {
|
|
63
|
-
type:
|
|
64
|
-
properties: {
|
|
65
|
-
|
|
66
|
-
type: string;
|
|
67
|
-
|
|
15
|
+
readonly type: "object";
|
|
16
|
+
readonly properties: {
|
|
17
|
+
readonly actionSummary: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly minLength: 1;
|
|
20
|
+
readonly description: "Required public high-level action label.";
|
|
21
|
+
};
|
|
22
|
+
readonly agentId: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "Optional Sovereign Agent DID. Defaults to the local signer's DID and must match it when provided.";
|
|
25
|
+
};
|
|
26
|
+
readonly confidentialPayload: {
|
|
27
|
+
readonly type: "object";
|
|
28
|
+
readonly description: "Optional confidential parameters, canonicalized and hashed locally.";
|
|
29
|
+
};
|
|
30
|
+
readonly counterpartyId: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly description: "Optional counterparty agent identifier.";
|
|
33
|
+
};
|
|
34
|
+
readonly intent: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly deprecated: true;
|
|
37
|
+
readonly description: "Deprecated alias. actionSummary remains required.";
|
|
68
38
|
};
|
|
69
39
|
};
|
|
40
|
+
readonly required: readonly ["actionSummary"];
|
|
41
|
+
readonly additionalProperties: false;
|
|
70
42
|
};
|
|
71
43
|
};
|
|
44
|
+
export { ROHAN_HANDSHAKE_TOOL_SCHEMA, ROHAN_MCP_INSTRUCTIONS, ROHAN_EXECUTE_TOOL_WITH_ANNOTATIONS, ROHAN_VERIFY_TOOL_SCHEMA, ROHAN_LEDGER_STATE_TOOL_SCHEMA, ROHAN_HISTORY_TOOL_SCHEMA, ROHAN_AGENT_STATUS_TOOL_SCHEMA, createRohanMcpServer, };
|
|
72
45
|
//# 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":";AAOA,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EACL,oBAAoB,EAEpB,sBAAsB,EACtB,mCAAmC,EACnC,wBAAwB,EACxB,8BAA8B,EAC9B,yBAAyB,EACzB,8BAA8B,EAC/B,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAsC,CAAC;AAE7E,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,mCAAmC,EACnC,wBAAwB,EACxB,8BAA8B,EAC9B,yBAAyB,EACzB,8BAA8B,EAC9B,oBAAoB,GACrB,CAAC"}
|