@kya-os/mcp-i 0.1.0-alpha.2.5 → 0.1.0-alpha.2.6
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/dist/index.js +73 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -128,20 +128,58 @@ class MCPIdentity {
|
|
|
128
128
|
});
|
|
129
129
|
const apiEndpoint = options?.apiEndpoint || 'https://knowthat.ai';
|
|
130
130
|
logger.info('Registering with knowthat.ai...');
|
|
131
|
+
logger.info('Generating cryptographic keys...');
|
|
132
|
+
const keyPair = await crypto.generateKeyPair();
|
|
131
133
|
const registrationData = {
|
|
132
134
|
name: options?.name || process.env.MCP_SERVER_NAME || 'Unnamed MCP Server',
|
|
133
135
|
description: options?.description,
|
|
134
136
|
repository: options?.repository,
|
|
137
|
+
publicKey: keyPair.publicKey,
|
|
135
138
|
directories: options?.directories,
|
|
136
139
|
isDraft: options?.mode === 'development'
|
|
137
140
|
};
|
|
138
|
-
logger.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
directories:
|
|
141
|
+
logger.debug('Registration data:', {
|
|
142
|
+
name: registrationData.name,
|
|
143
|
+
hasDescription: !!registrationData.description,
|
|
144
|
+
hasRepository: !!registrationData.repository,
|
|
145
|
+
hasPublicKey: !!registrationData.publicKey,
|
|
146
|
+
directories: registrationData.directories,
|
|
147
|
+
isDraft: registrationData.isDraft
|
|
144
148
|
});
|
|
149
|
+
let response;
|
|
150
|
+
try {
|
|
151
|
+
response = await autoRegister(transport, {
|
|
152
|
+
...registrationData,
|
|
153
|
+
apiEndpoint,
|
|
154
|
+
directories: options?.directories
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch (registrationError) {
|
|
158
|
+
logger.error('Failed to register with knowthat.ai:', registrationError.message);
|
|
159
|
+
if (options?.mode === 'development' || process.env.NODE_ENV === 'development') {
|
|
160
|
+
logger.warn('Running in offline development mode with temporary identity');
|
|
161
|
+
const tempSlug = `temp-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
162
|
+
response = {
|
|
163
|
+
did: `did:web:localhost:agents:${tempSlug}`,
|
|
164
|
+
agent: {
|
|
165
|
+
id: tempSlug,
|
|
166
|
+
slug: tempSlug,
|
|
167
|
+
name: registrationData.name,
|
|
168
|
+
url: `http://localhost:3000/agents/${tempSlug}`,
|
|
169
|
+
claimUrl: `http://localhost:3000/agents/claim?did=${tempSlug}`
|
|
170
|
+
},
|
|
171
|
+
keys: {
|
|
172
|
+
publicKey: keyPair.publicKey,
|
|
173
|
+
privateKey: keyPair.privateKey
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
logger.warn('⚠️ Using temporary development identity. This will not persist across restarts.');
|
|
177
|
+
logger.warn('⚠️ To use a permanent identity, ensure you can connect to knowthat.ai');
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
throw registrationError;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
145
183
|
identity = {
|
|
146
184
|
did: response.did,
|
|
147
185
|
publicKey: keyPair.publicKey,
|
|
@@ -429,34 +467,58 @@ function patchMCPServer(identity) {
|
|
|
429
467
|
}
|
|
430
468
|
}
|
|
431
469
|
async function autoRegister(transport, options) {
|
|
470
|
+
const logger = (0, logger_1.getLogger)();
|
|
432
471
|
try {
|
|
433
|
-
const
|
|
472
|
+
const requestBody = {
|
|
434
473
|
metadata: {
|
|
435
474
|
name: options.name,
|
|
436
475
|
description: options.description,
|
|
437
476
|
repository: options.repository,
|
|
477
|
+
publicKey: options.publicKey,
|
|
438
478
|
version: '1.0.0',
|
|
439
479
|
isDraft: options.isDraft,
|
|
440
480
|
directories: options.directories || 'verified'
|
|
441
481
|
},
|
|
442
482
|
clientInfo: {
|
|
443
|
-
sdkVersion: '0.
|
|
483
|
+
sdkVersion: '0.1.0-alpha.2.5',
|
|
444
484
|
language: 'typescript',
|
|
445
|
-
platform: 'node'
|
|
485
|
+
platform: typeof process !== 'undefined' ? 'node' : 'browser'
|
|
446
486
|
}
|
|
447
|
-
}
|
|
487
|
+
};
|
|
488
|
+
logger.debug('Sending registration request to:', `${options.apiEndpoint}/api/agents/auto-register`);
|
|
489
|
+
const response = await transport.post(`${options.apiEndpoint}/api/agents/auto-register`, requestBody, {
|
|
448
490
|
timeout: 30000,
|
|
449
491
|
headers: {
|
|
450
492
|
'Content-Type': 'application/json',
|
|
451
|
-
'User-Agent': '@kya-os/mcp-i/0.
|
|
493
|
+
'User-Agent': '@kya-os/mcp-i/0.1.0-alpha.2.5'
|
|
452
494
|
}
|
|
453
495
|
});
|
|
496
|
+
logger.debug('Registration response received:', {
|
|
497
|
+
status: response.status,
|
|
498
|
+
hasData: !!response.data,
|
|
499
|
+
hasDid: !!response.data?.did,
|
|
500
|
+
hasAgent: !!response.data?.agent
|
|
501
|
+
});
|
|
454
502
|
return response.data;
|
|
455
503
|
}
|
|
456
504
|
catch (error) {
|
|
505
|
+
logger.error('Registration failed:', {
|
|
506
|
+
message: error.message,
|
|
507
|
+
status: error.status,
|
|
508
|
+
response: error.response
|
|
509
|
+
});
|
|
457
510
|
if (error.message?.includes('429')) {
|
|
458
511
|
throw new Error('Rate limit exceeded. Please try again later.');
|
|
459
512
|
}
|
|
513
|
+
if (error.message?.includes('500')) {
|
|
514
|
+
throw new Error('Server error during registration. This might be a temporary issue.\n' +
|
|
515
|
+
'Please try again in a few moments, or register manually at https://knowthat.ai/submit-agent');
|
|
516
|
+
}
|
|
517
|
+
if (error.message?.includes('400')) {
|
|
518
|
+
throw new Error('Invalid registration data. Please ensure all required fields are provided:\n' +
|
|
519
|
+
'- name: A unique name for your agent\n' +
|
|
520
|
+
'- publicKey: Generated automatically (check if generation succeeded)');
|
|
521
|
+
}
|
|
460
522
|
throw new Error(error.message || 'Failed to auto-register agent');
|
|
461
523
|
}
|
|
462
524
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/mcp-i",
|
|
3
|
-
"version": "0.1.0-alpha.2.
|
|
3
|
+
"version": "0.1.0-alpha.2.6",
|
|
4
4
|
"description": "Production-ready MCP Identity with automatic registration, key rotation, and optimized performance",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|