@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
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import fs, { constants as fsConstants } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import { createPrivateKey, createPublicKey, randomBytes } from 'node:crypto';
|
|
5
|
+
import { createDidKey, generateEd25519KeyPair, InMemoryEd25519Signer, } from '@rohan-protocol/sdk';
|
|
6
|
+
const ED25519_PKCS8_PREFIX = new Uint8Array([
|
|
7
|
+
0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,
|
|
8
|
+
]);
|
|
9
|
+
const ED25519_SPKI_PREFIX = new Uint8Array([
|
|
10
|
+
0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00,
|
|
11
|
+
]);
|
|
12
|
+
const MAX_KEYSTORE_SIZE = 4096;
|
|
13
|
+
export class KeystoreResolutionError extends Error {
|
|
14
|
+
code;
|
|
15
|
+
constructor(message, options) {
|
|
16
|
+
super(message, { cause: options?.cause });
|
|
17
|
+
this.name = 'KeystoreResolutionError';
|
|
18
|
+
this.code = options?.code;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function isErrno(error, code) {
|
|
22
|
+
return typeof error === 'object' && error !== null && 'code' in error &&
|
|
23
|
+
error.code === code;
|
|
24
|
+
}
|
|
25
|
+
function currentUid() {
|
|
26
|
+
return typeof process.getuid === 'function' ? process.getuid() : undefined;
|
|
27
|
+
}
|
|
28
|
+
function ensurePrivateDirectory(directoryPath) {
|
|
29
|
+
try {
|
|
30
|
+
fs.mkdirSync(directoryPath, { recursive: true, mode: 0o700 });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new KeystoreResolutionError(`Could not create keystore directory "${directoryPath}".`, { cause: error });
|
|
34
|
+
}
|
|
35
|
+
let directoryStat;
|
|
36
|
+
try {
|
|
37
|
+
directoryStat = fs.lstatSync(directoryPath);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new KeystoreResolutionError(`Could not inspect keystore directory "${directoryPath}".`, { cause: error });
|
|
41
|
+
}
|
|
42
|
+
if (directoryStat.isSymbolicLink() || !directoryStat.isDirectory()) {
|
|
43
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore parent must be a real directory, not a symlink.');
|
|
44
|
+
}
|
|
45
|
+
const uid = currentUid();
|
|
46
|
+
if (uid !== undefined && directoryStat.uid !== uid) {
|
|
47
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore directory is not owned by the current user.');
|
|
48
|
+
}
|
|
49
|
+
if (process.platform !== 'win32') {
|
|
50
|
+
try {
|
|
51
|
+
fs.chmodSync(directoryPath, 0o700);
|
|
52
|
+
directoryStat = fs.lstatSync(directoryPath);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Could not secure keystore directory permissions.', { cause: error });
|
|
56
|
+
}
|
|
57
|
+
if ((directoryStat.mode & 0o777) !== 0o700) {
|
|
58
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore directory must have mode 0700.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function derivePublicKey(privateKey) {
|
|
63
|
+
if (privateKey.length !== 32) {
|
|
64
|
+
throw new KeystoreResolutionError('Ed25519 private seed must be exactly 32 bytes.');
|
|
65
|
+
}
|
|
66
|
+
const pkcs8 = new Uint8Array(ED25519_PKCS8_PREFIX.length + privateKey.length);
|
|
67
|
+
pkcs8.set(ED25519_PKCS8_PREFIX);
|
|
68
|
+
pkcs8.set(privateKey, ED25519_PKCS8_PREFIX.length);
|
|
69
|
+
try {
|
|
70
|
+
const privateKeyObject = createPrivateKey({
|
|
71
|
+
key: Buffer.from(pkcs8.buffer, pkcs8.byteOffset, pkcs8.byteLength),
|
|
72
|
+
format: 'der',
|
|
73
|
+
type: 'pkcs8',
|
|
74
|
+
});
|
|
75
|
+
const publicDer = createPublicKey(privateKeyObject).export({ format: 'der', type: 'spki' });
|
|
76
|
+
const publicBytes = Buffer.isBuffer(publicDer) ? publicDer : Buffer.from(publicDer);
|
|
77
|
+
if (publicBytes.length !== ED25519_SPKI_PREFIX.length + 32 ||
|
|
78
|
+
!ED25519_SPKI_PREFIX.every((byte, index) => publicBytes[index] === byte)) {
|
|
79
|
+
throw new KeystoreResolutionError('Derived Ed25519 public key has an invalid encoding.');
|
|
80
|
+
}
|
|
81
|
+
return new Uint8Array(publicBytes.subarray(ED25519_SPKI_PREFIX.length));
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
pkcs8.fill(0);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function createSigner(publicKey, privateKey) {
|
|
88
|
+
try {
|
|
89
|
+
return new InMemoryEd25519Signer(publicKey, privateKey);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
publicKey.fill(0);
|
|
93
|
+
privateKey.fill(0);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function readKeystoreContents(filePath) {
|
|
97
|
+
let pathStat;
|
|
98
|
+
try {
|
|
99
|
+
pathStat = fs.lstatSync(filePath);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (isErrno(error, 'ENOENT')) {
|
|
103
|
+
throw new KeystoreResolutionError(`Keystore file not found: ${filePath}`, { cause: error, code: 'ENOENT' });
|
|
104
|
+
}
|
|
105
|
+
throw new KeystoreResolutionError(`Could not inspect keystore file "${filePath}".`, { cause: error });
|
|
106
|
+
}
|
|
107
|
+
if (pathStat.isSymbolicLink()) {
|
|
108
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore file must not be a symbolic link.');
|
|
109
|
+
}
|
|
110
|
+
let fd;
|
|
111
|
+
try {
|
|
112
|
+
const noFollow = fsConstants.O_NOFOLLOW ?? 0;
|
|
113
|
+
fd = fs.openSync(filePath, fsConstants.O_RDONLY | noFollow);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (isErrno(error, 'ENOENT')) {
|
|
117
|
+
throw new KeystoreResolutionError(`Keystore file not found: ${filePath}`, { cause: error, code: 'ENOENT' });
|
|
118
|
+
}
|
|
119
|
+
if (isErrno(error, 'ELOOP')) {
|
|
120
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore file must not be a symbolic link.', { cause: error });
|
|
121
|
+
}
|
|
122
|
+
throw new KeystoreResolutionError(`Could not open keystore file "${filePath}".`, { cause: error });
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const stat = fs.fstatSync(fd);
|
|
126
|
+
const currentPathStat = fs.lstatSync(filePath);
|
|
127
|
+
if (currentPathStat.isSymbolicLink() ||
|
|
128
|
+
currentPathStat.dev !== stat.dev ||
|
|
129
|
+
currentPathStat.ino !== stat.ino ||
|
|
130
|
+
!stat.isFile() ||
|
|
131
|
+
stat.nlink !== 1) {
|
|
132
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore must be a regular file with one link.');
|
|
133
|
+
}
|
|
134
|
+
const uid = currentUid();
|
|
135
|
+
if (uid !== undefined && stat.uid !== uid) {
|
|
136
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore file is not owned by the current user.');
|
|
137
|
+
}
|
|
138
|
+
if (stat.size > MAX_KEYSTORE_SIZE) {
|
|
139
|
+
throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Keystore file exceeds the maximum supported size.');
|
|
140
|
+
}
|
|
141
|
+
if (process.platform !== 'win32') {
|
|
142
|
+
if ((stat.mode & 0o777) !== 0o600) {
|
|
143
|
+
try {
|
|
144
|
+
fs.fchmodSync(fd, 0o600);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Could not secure keystore permissions (expected 0600).', { cause: error });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const securedStat = fs.fstatSync(fd);
|
|
151
|
+
if ((securedStat.mode & 0o777) !== 0o600) {
|
|
152
|
+
throw new KeystoreResolutionError('SECURITY_VIOLATION: Keystore file must have mode 0600.');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return fs.readFileSync(fd, 'utf8');
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
fs.closeSync(fd);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export async function loadKeystoreFile(filePath) {
|
|
162
|
+
ensurePrivateDirectory(path.dirname(filePath));
|
|
163
|
+
const contents = readKeystoreContents(filePath);
|
|
164
|
+
let parsed;
|
|
165
|
+
try {
|
|
166
|
+
parsed = JSON.parse(contents);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Keystore JSON is invalid; refusing to replace the existing identity.', { cause: error });
|
|
170
|
+
}
|
|
171
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
172
|
+
throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Keystore must contain a JSON object.');
|
|
173
|
+
}
|
|
174
|
+
const data = parsed;
|
|
175
|
+
const keys = Object.keys(data).sort();
|
|
176
|
+
if (keys.length !== 3 ||
|
|
177
|
+
keys[0] !== 'createdAt' ||
|
|
178
|
+
keys[1] !== 'did' ||
|
|
179
|
+
keys[2] !== 'privateKeyHex' ||
|
|
180
|
+
typeof data.did !== 'string' ||
|
|
181
|
+
typeof data.privateKeyHex !== 'string' ||
|
|
182
|
+
!/^[0-9a-f]{64}$/.test(data.privateKeyHex) ||
|
|
183
|
+
!Number.isSafeInteger(data.createdAt) ||
|
|
184
|
+
data.createdAt <= 0) {
|
|
185
|
+
throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Keystore fields or values are invalid.');
|
|
186
|
+
}
|
|
187
|
+
const privateKey = new Uint8Array(Buffer.from(data.privateKeyHex, 'hex'));
|
|
188
|
+
let publicKey;
|
|
189
|
+
try {
|
|
190
|
+
publicKey = await derivePublicKey(privateKey);
|
|
191
|
+
const derivedDid = createDidKey(publicKey);
|
|
192
|
+
if (data.did !== derivedDid) {
|
|
193
|
+
throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Stored DID does not match the DID derived from the private seed.');
|
|
194
|
+
}
|
|
195
|
+
return createSigner(publicKey, privateKey);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
privateKey.fill(0);
|
|
199
|
+
publicKey?.fill(0);
|
|
200
|
+
if (error instanceof KeystoreResolutionError)
|
|
201
|
+
throw error;
|
|
202
|
+
throw new KeystoreResolutionError('CORRUPTED_KEYSTORE: Could not validate the stored identity.', { cause: error });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
export async function saveKeystoreFile(filePath, keystore) {
|
|
206
|
+
const directoryPath = path.dirname(filePath);
|
|
207
|
+
ensurePrivateDirectory(directoryPath);
|
|
208
|
+
if (!keystore ||
|
|
209
|
+
typeof keystore.did !== 'string' ||
|
|
210
|
+
typeof keystore.privateKeyHex !== 'string' ||
|
|
211
|
+
!/^[0-9a-f]{64}$/.test(keystore.privateKeyHex) ||
|
|
212
|
+
!Number.isSafeInteger(keystore.createdAt) ||
|
|
213
|
+
keystore.createdAt <= 0) {
|
|
214
|
+
throw new KeystoreResolutionError('Invalid keystore data.');
|
|
215
|
+
}
|
|
216
|
+
const privateKey = new Uint8Array(Buffer.from(keystore.privateKeyHex, 'hex'));
|
|
217
|
+
let publicKey;
|
|
218
|
+
try {
|
|
219
|
+
publicKey = await derivePublicKey(privateKey);
|
|
220
|
+
if (createDidKey(publicKey) !== keystore.did) {
|
|
221
|
+
throw new KeystoreResolutionError('Keystore DID does not match the DID derived from the private seed.');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
privateKey.fill(0);
|
|
226
|
+
publicKey?.fill(0);
|
|
227
|
+
}
|
|
228
|
+
const temporaryPath = `${filePath}.tmp-${process.pid}-${randomBytes(16).toString('hex')}`;
|
|
229
|
+
const serialized = `${JSON.stringify(keystore, null, 2)}\n`;
|
|
230
|
+
let fd;
|
|
231
|
+
let tempCreated = false;
|
|
232
|
+
try {
|
|
233
|
+
fd = fs.openSync(temporaryPath, 'wx', 0o600);
|
|
234
|
+
tempCreated = true;
|
|
235
|
+
if (process.platform !== 'win32') {
|
|
236
|
+
fs.fchmodSync(fd, 0o600);
|
|
237
|
+
}
|
|
238
|
+
fs.writeFileSync(fd, serialized, 'utf8');
|
|
239
|
+
fs.fsyncSync(fd);
|
|
240
|
+
fs.closeSync(fd);
|
|
241
|
+
fd = undefined;
|
|
242
|
+
fs.linkSync(temporaryPath, filePath);
|
|
243
|
+
fs.unlinkSync(temporaryPath);
|
|
244
|
+
tempCreated = false;
|
|
245
|
+
if (process.platform !== 'win32') {
|
|
246
|
+
const dirFd = fs.openSync(directoryPath, fsConstants.O_RDONLY);
|
|
247
|
+
try {
|
|
248
|
+
fs.fsyncSync(dirFd);
|
|
249
|
+
}
|
|
250
|
+
finally {
|
|
251
|
+
fs.closeSync(dirFd);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
if (fd !== undefined)
|
|
257
|
+
fs.closeSync(fd);
|
|
258
|
+
if (tempCreated) {
|
|
259
|
+
try {
|
|
260
|
+
fs.unlinkSync(temporaryPath);
|
|
261
|
+
}
|
|
262
|
+
catch (cleanupError) {
|
|
263
|
+
if (!isErrno(cleanupError, 'ENOENT')) {
|
|
264
|
+
throw new KeystoreResolutionError('Keystore write failed and temporary-file cleanup also failed.', { cause: cleanupError });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (isErrno(error, 'EEXIST')) {
|
|
269
|
+
throw new KeystoreResolutionError(`Keystore already exists: ${filePath}`, { cause: error, code: 'EEXIST' });
|
|
270
|
+
}
|
|
271
|
+
if (error instanceof KeystoreResolutionError)
|
|
272
|
+
throw error;
|
|
273
|
+
throw new KeystoreResolutionError(`Could not atomically save keystore "${filePath}".`, { cause: error });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
export async function createNewKeystoreFile(filePath) {
|
|
277
|
+
const keyPair = await generateEd25519KeyPair();
|
|
278
|
+
try {
|
|
279
|
+
const keystore = {
|
|
280
|
+
did: createDidKey(keyPair.publicKey),
|
|
281
|
+
privateKeyHex: Buffer.from(keyPair.privateKey).toString('hex'),
|
|
282
|
+
createdAt: Date.now(),
|
|
283
|
+
};
|
|
284
|
+
try {
|
|
285
|
+
await saveKeystoreFile(filePath, keystore);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
if (error instanceof KeystoreResolutionError && error.code === 'EEXIST') {
|
|
289
|
+
return await loadKeystoreFile(filePath);
|
|
290
|
+
}
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
return new InMemoryEd25519Signer(keyPair.publicKey, keyPair.privateKey);
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
keyPair.privateKey.fill(0);
|
|
297
|
+
keyPair.publicKey.fill(0);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
export async function resolveAgentIdentity(options = {}) {
|
|
301
|
+
const envHex = options.privateKeyHex ?? process.env.ROHAN_AGENT_PRIVATE_KEY;
|
|
302
|
+
if (envHex !== undefined && envHex.trim() !== '') {
|
|
303
|
+
const normalized = envHex.trim().replace(/^0x/i, '');
|
|
304
|
+
if (!/^[0-9a-f]{64}$/i.test(normalized)) {
|
|
305
|
+
throw new KeystoreResolutionError('ROHAN_AGENT_PRIVATE_KEY is set but is not a valid 32-byte hexadecimal seed.');
|
|
306
|
+
}
|
|
307
|
+
const privateKey = new Uint8Array(Buffer.from(normalized, 'hex'));
|
|
308
|
+
let publicKey;
|
|
309
|
+
try {
|
|
310
|
+
publicKey = await derivePublicKey(privateKey);
|
|
311
|
+
const signer = createSigner(publicKey, privateKey);
|
|
312
|
+
return { signer, did: signer.did, source: 'env' };
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
privateKey.fill(0);
|
|
316
|
+
publicKey?.fill(0);
|
|
317
|
+
if (error instanceof KeystoreResolutionError)
|
|
318
|
+
throw error;
|
|
319
|
+
throw new KeystoreResolutionError('Could not initialize signer from ROHAN_AGENT_PRIVATE_KEY.', { cause: error });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const filePath = options.filePath ?? path.join(os.homedir(), '.rohan', 'agent-identity.json');
|
|
323
|
+
ensurePrivateDirectory(path.dirname(filePath));
|
|
324
|
+
try {
|
|
325
|
+
const signer = await loadKeystoreFile(filePath);
|
|
326
|
+
return { signer, did: signer.did, source: 'filesystem', filePath };
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
if (!(error instanceof KeystoreResolutionError) || error.code !== 'ENOENT') {
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const signer = await createNewKeystoreFile(filePath);
|
|
334
|
+
return { signer, did: signer.did, source: 'auto-provisioned', filePath };
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=keystore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystore.js","sourceRoot":"","sources":["../../src/identity/keystore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,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;AACH,MAAM,mBAAmB,GAAG,IAAI,UAAU,CAAC;IACzC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE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EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACnH,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IAC9F,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAChD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,uBAAuB,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACrD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { RohanClient, type AgentSigner, type NetworkId } from '@rohan-protocol/sdk';
|
|
3
|
+
import type { LoadedAgentIdentity } from './identity/keystore.js';
|
|
4
|
+
export declare const ROHAN_MCP_VERSION = "0.8.2";
|
|
5
|
+
export declare const ROHAN_MCP_INSTRUCTIONS: string;
|
|
6
|
+
export declare const ROHAN_EXECUTE_TOOL_WITH_ANNOTATIONS: {
|
|
7
|
+
annotations: {
|
|
8
|
+
title: string;
|
|
9
|
+
readOnlyHint: boolean;
|
|
10
|
+
destructiveHint: boolean;
|
|
11
|
+
idempotentHint: boolean;
|
|
12
|
+
openWorldHint: boolean;
|
|
13
|
+
};
|
|
14
|
+
name: "rohan_execute_handshake";
|
|
15
|
+
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.";
|
|
16
|
+
inputSchema: {
|
|
17
|
+
readonly type: "object";
|
|
18
|
+
readonly properties: {
|
|
19
|
+
readonly actionSummary: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly minLength: 1;
|
|
22
|
+
readonly description: "Required public high-level action label.";
|
|
23
|
+
};
|
|
24
|
+
readonly agentId: {
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
readonly description: "Optional Sovereign Agent DID. Defaults to the local signer's DID and must match it when provided.";
|
|
27
|
+
};
|
|
28
|
+
readonly confidentialPayload: {
|
|
29
|
+
readonly type: "object";
|
|
30
|
+
readonly description: "Optional confidential parameters, canonicalized and hashed locally.";
|
|
31
|
+
};
|
|
32
|
+
readonly counterpartyId: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly description: "Optional counterparty agent identifier.";
|
|
35
|
+
};
|
|
36
|
+
readonly intent: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly deprecated: true;
|
|
39
|
+
readonly description: "Deprecated alias. actionSummary remains required.";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
readonly required: readonly ["actionSummary"];
|
|
43
|
+
readonly additionalProperties: false;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare const ROHAN_VERIFY_TOOL_SCHEMA: {
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: string;
|
|
51
|
+
properties: {
|
|
52
|
+
payload: {
|
|
53
|
+
type: string;
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
expectedDigest: {
|
|
57
|
+
type: string;
|
|
58
|
+
pattern: string;
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
61
|
+
auditBundle: {
|
|
62
|
+
type: string;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
required: never[];
|
|
67
|
+
};
|
|
68
|
+
annotations: {
|
|
69
|
+
title: string;
|
|
70
|
+
readOnlyHint: boolean;
|
|
71
|
+
destructiveHint: boolean;
|
|
72
|
+
idempotentHint: boolean;
|
|
73
|
+
openWorldHint: boolean;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export declare const ROHAN_LEDGER_STATE_TOOL_SCHEMA: {
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
inputSchema: {
|
|
80
|
+
type: string;
|
|
81
|
+
properties: {};
|
|
82
|
+
};
|
|
83
|
+
annotations: {
|
|
84
|
+
title: string;
|
|
85
|
+
readOnlyHint: boolean;
|
|
86
|
+
destructiveHint: boolean;
|
|
87
|
+
idempotentHint: boolean;
|
|
88
|
+
openWorldHint: boolean;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export declare const ROHAN_HISTORY_TOOL_SCHEMA: {
|
|
92
|
+
name: string;
|
|
93
|
+
description: string;
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: string;
|
|
96
|
+
properties: {
|
|
97
|
+
limit: {
|
|
98
|
+
type: string;
|
|
99
|
+
description: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
annotations: {
|
|
104
|
+
title: string;
|
|
105
|
+
readOnlyHint: boolean;
|
|
106
|
+
destructiveHint: boolean;
|
|
107
|
+
idempotentHint: boolean;
|
|
108
|
+
openWorldHint: boolean;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export declare const ROHAN_AGENT_STATUS_TOOL_SCHEMA: {
|
|
112
|
+
name: string;
|
|
113
|
+
description: string;
|
|
114
|
+
inputSchema: {
|
|
115
|
+
type: string;
|
|
116
|
+
properties: {};
|
|
117
|
+
};
|
|
118
|
+
annotations: {
|
|
119
|
+
title: string;
|
|
120
|
+
readOnlyHint: boolean;
|
|
121
|
+
destructiveHint: boolean;
|
|
122
|
+
idempotentHint: boolean;
|
|
123
|
+
openWorldHint: boolean;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export interface CreateRohanMcpServerOptions {
|
|
127
|
+
contractAddress: string;
|
|
128
|
+
relayerUrl: string;
|
|
129
|
+
network?: NetworkId;
|
|
130
|
+
rohanClient: RohanClient;
|
|
131
|
+
configuredSigner?: AgentSigner;
|
|
132
|
+
loadedIdentity?: Pick<LoadedAgentIdentity, 'did' | 'source' | 'filePath'>;
|
|
133
|
+
statusTimeoutMs?: number;
|
|
134
|
+
}
|
|
135
|
+
export declare function createRohanMcpServer(options: CreateRohanMcpServerOptions): Server;
|
|
136
|
+
//# sourceMappingURL=mcp-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-app.d.ts","sourceRoot":"","sources":["../src/mcp-app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAOnE,OAAO,EACL,WAAW,EAIX,KAAK,WAAW,EAChB,KAAK,SAAS,EAEf,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC,eAAO,MAAM,sBAAsB,QAa3B,CAAC;AAIT,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS/C,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BpC,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;CAe1C,CAAC;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;CAoBrC,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;CAe1C,CAAC;AAiGF,MAAM,WAAW,2BAA2B;IAC1C,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC/B,cAAc,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,KAAK,GAAG,QAAQ,GAAG,UAAU,CAAC,CAAC;IAC1E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,MAAM,CA2WjF"}
|