@kya-os/mcp-i 0.1.0-alpha.2.8 → 0.1.0-alpha.2.9
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.d.ts +1 -0
- package/dist/index.js +31 -13
- package/dist/nextjs.d.ts +10 -0
- package/dist/nextjs.js +82 -0
- package/dist/vercel-adapter.d.ts +8 -0
- package/dist/vercel-adapter.js +67 -0
- package/package.json +11 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MCPIdentityOptions, Challenge, ChallengeResponse, MCPICapabilities, SignedResponse, MCPMiddleware, DirectoryPreference } from './types';
|
|
2
2
|
import { KeyRotationResult, KeyHealth } from './rotation';
|
|
3
3
|
export * from './types';
|
|
4
|
+
export * from './vercel-adapter';
|
|
4
5
|
export { RegistryFactory, REGISTRY_TIERS, resolveRegistries } from './registry';
|
|
5
6
|
export { LoggerFactory, ConsoleLogger, SilentLogger } from './logger';
|
|
6
7
|
export { StorageFactory, MemoryStorage, FileStorage } from './storage';
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,9 @@ const storage_1 = require("./storage");
|
|
|
44
44
|
const transport_1 = require("./transport");
|
|
45
45
|
const logger_1 = require("./logger");
|
|
46
46
|
const rotation_1 = require("./rotation");
|
|
47
|
+
const vercel_adapter_1 = require("./vercel-adapter");
|
|
47
48
|
__exportStar(require("./types"), exports);
|
|
49
|
+
__exportStar(require("./vercel-adapter"), exports);
|
|
48
50
|
var registry_1 = require("./registry");
|
|
49
51
|
Object.defineProperty(exports, "RegistryFactory", { enumerable: true, get: function () { return registry_1.RegistryFactory; } });
|
|
50
52
|
Object.defineProperty(exports, "REGISTRY_TIERS", { enumerable: true, get: function () { return registry_1.REGISTRY_TIERS; } });
|
|
@@ -110,13 +112,24 @@ class MCPIdentity {
|
|
|
110
112
|
if (globalIdentity) {
|
|
111
113
|
return globalIdentity;
|
|
112
114
|
}
|
|
115
|
+
const isVercel = process.env.VERCEL || process.env.VERCEL_ENV;
|
|
116
|
+
const isServerless = isVercel || process.env.AWS_LAMBDA_FUNCTION_NAME || process.env.FUNCTIONS_WORKER_RUNTIME;
|
|
117
|
+
let identity = null;
|
|
118
|
+
if (isServerless || options?.storage === 'memory') {
|
|
119
|
+
identity = (0, vercel_adapter_1.loadIdentityFromEnv)();
|
|
120
|
+
if (identity) {
|
|
121
|
+
logger.info('✅ Loaded existing identity from environment variables');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
113
124
|
const storage = storage_1.StorageFactory.create({
|
|
114
125
|
storage: options?.storage,
|
|
115
126
|
customPath: options?.persistencePath,
|
|
116
127
|
memoryKey: options?.memoryKey,
|
|
117
128
|
encryptionPassword: options?.encryptionPassword
|
|
118
129
|
});
|
|
119
|
-
|
|
130
|
+
if (!identity) {
|
|
131
|
+
identity = await storage.load();
|
|
132
|
+
}
|
|
120
133
|
if (identity) {
|
|
121
134
|
logger.info('Loaded existing identity:', identity.did);
|
|
122
135
|
globalIdentity = new MCPIdentity(identity, options);
|
|
@@ -136,7 +149,7 @@ class MCPIdentity {
|
|
|
136
149
|
repository: options?.repository,
|
|
137
150
|
publicKey: keyPair.publicKey,
|
|
138
151
|
directories: options?.directories,
|
|
139
|
-
isDraft: options?.mode
|
|
152
|
+
isDraft: options?.mode !== 'production'
|
|
140
153
|
};
|
|
141
154
|
logger.debug('Registration data:', {
|
|
142
155
|
name: registrationData.name,
|
|
@@ -190,17 +203,22 @@ class MCPIdentity {
|
|
|
190
203
|
directories: options?.directories || 'verified'
|
|
191
204
|
};
|
|
192
205
|
await storage.save(identity);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
logger.info(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
if (isServerless) {
|
|
207
|
+
(0, vercel_adapter_1.showVercelDeveloperInstructions)(identity, response.agent.claimUrl);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
logger.info('✅ Success! Your agent has been registered.');
|
|
211
|
+
logger.info(`DID: ${response.did}`);
|
|
212
|
+
logger.info(`Profile: ${response.agent.url}`);
|
|
213
|
+
if (response.agent.claimUrl) {
|
|
214
|
+
logger.info(`Claim your agent: ${response.agent.claimUrl}`);
|
|
215
|
+
}
|
|
216
|
+
if (options?.directories && options.directories !== 'none') {
|
|
217
|
+
const dirMessage = options.directories === 'verified'
|
|
218
|
+
? 'Your agent will be submitted to all verified directories'
|
|
219
|
+
: `Your agent will be submitted to: ${options.directories.join(', ')}`;
|
|
220
|
+
logger.info(dirMessage);
|
|
221
|
+
}
|
|
204
222
|
}
|
|
205
223
|
globalIdentity = new MCPIdentity(identity, options);
|
|
206
224
|
return globalIdentity;
|
package/dist/nextjs.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MCPIdentity } from './index';
|
|
2
|
+
import { MCPIdentityOptions } from './types';
|
|
3
|
+
export interface NextJSMCPOptions extends Omit<MCPIdentityOptions, 'transport' | 'storage'> {
|
|
4
|
+
storage?: 'memory';
|
|
5
|
+
transport?: 'fetch';
|
|
6
|
+
showSetupInstructions?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function enableMCPIdentityForNextJS(options?: NextJSMCPOptions): Promise<MCPIdentity>;
|
|
9
|
+
export { enableMCPIdentity, MCPIdentity } from './index';
|
|
10
|
+
export * from './types';
|
package/dist/nextjs.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.MCPIdentity = exports.enableMCPIdentity = void 0;
|
|
18
|
+
exports.enableMCPIdentityForNextJS = enableMCPIdentityForNextJS;
|
|
19
|
+
const index_1 = require("./index");
|
|
20
|
+
async function enableMCPIdentityForNextJS(options = {}) {
|
|
21
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
22
|
+
const isVercel = process.env.VERCEL || process.env.VERCEL_ENV;
|
|
23
|
+
try {
|
|
24
|
+
console.log(`\n🚀 Initializing MCP-I for Next.js...`);
|
|
25
|
+
const identity = await (0, index_1.enableMCPIdentity)({
|
|
26
|
+
...options,
|
|
27
|
+
transport: 'fetch',
|
|
28
|
+
storage: 'memory',
|
|
29
|
+
logLevel: options.logLevel || (isProduction ? 'error' : 'info'),
|
|
30
|
+
mode: isProduction ? 'production' : 'development',
|
|
31
|
+
});
|
|
32
|
+
if (!isProduction && options.showSetupInstructions !== false) {
|
|
33
|
+
console.log('\n✅ MCP-I Ready for Next.js!');
|
|
34
|
+
console.log(`\n📋 Quick Info:`);
|
|
35
|
+
console.log(` Environment: ${isVercel ? 'Vercel' : 'Local'}`);
|
|
36
|
+
console.log(` DID: ${identity.did}`);
|
|
37
|
+
if (isVercel && !process.env.MCP_IDENTITY_DID) {
|
|
38
|
+
console.log('\n⚠️ Remember to set environment variables in Vercel Dashboard!');
|
|
39
|
+
console.log(' See console output above for the exact variables to add.');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return identity;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('\n❌ MCP-I Initialization Failed\n');
|
|
46
|
+
if (error?.message?.includes('429')) {
|
|
47
|
+
console.error('📛 Rate Limit Hit');
|
|
48
|
+
console.error(' You\'ve made too many registration attempts.');
|
|
49
|
+
console.error(' Wait a few minutes and try again.');
|
|
50
|
+
console.error('\n💡 Tip: In development, you can use environment variables to persist identity:');
|
|
51
|
+
console.error(' 1. Copy the MCP_IDENTITY_* variables from a successful run');
|
|
52
|
+
console.error(' 2. Add them to your .env.local file');
|
|
53
|
+
}
|
|
54
|
+
else if (error?.message?.includes('500') || error?.message?.includes('fetch failed')) {
|
|
55
|
+
console.error('📛 Server Connection Error');
|
|
56
|
+
console.error(' Cannot connect to knowthat.ai registry.');
|
|
57
|
+
console.error('\n💡 Possible causes:');
|
|
58
|
+
console.error(' - Registry is temporarily down');
|
|
59
|
+
console.error(' - Network connectivity issues');
|
|
60
|
+
console.error(' - Firewall blocking outbound connections');
|
|
61
|
+
console.error('\n💡 Workaround for development:');
|
|
62
|
+
console.error(' Add to your route: mode: "development" to allow offline mode');
|
|
63
|
+
}
|
|
64
|
+
else if (error?.message?.includes('MODULE_NOT_FOUND')) {
|
|
65
|
+
console.error('📛 Missing Dependencies');
|
|
66
|
+
console.error(' Make sure all dependencies are installed:');
|
|
67
|
+
console.error(' npm install @kya-os/mcp-i');
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.error('📛 Unexpected Error:', error?.message || error);
|
|
71
|
+
}
|
|
72
|
+
if (!isProduction) {
|
|
73
|
+
console.error('\n🔍 Full Error Details:');
|
|
74
|
+
console.error(error);
|
|
75
|
+
}
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var index_2 = require("./index");
|
|
80
|
+
Object.defineProperty(exports, "enableMCPIdentity", { enumerable: true, get: function () { return index_2.enableMCPIdentity; } });
|
|
81
|
+
Object.defineProperty(exports, "MCPIdentity", { enumerable: true, get: function () { return index_2.MCPIdentity; } });
|
|
82
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MCPIdentityOptions, PersistedIdentity } from './types';
|
|
2
|
+
export interface VercelMCPIdentityOptions extends MCPIdentityOptions {
|
|
3
|
+
envPrefix?: string;
|
|
4
|
+
showClaimInstructions?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function loadIdentityFromEnv(prefix?: string): PersistedIdentity | null;
|
|
7
|
+
export declare function generateEnvInstructions(identity: PersistedIdentity, prefix?: string): string;
|
|
8
|
+
export declare function showVercelDeveloperInstructions(identity: PersistedIdentity, claimUrl?: string): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadIdentityFromEnv = loadIdentityFromEnv;
|
|
4
|
+
exports.generateEnvInstructions = generateEnvInstructions;
|
|
5
|
+
exports.showVercelDeveloperInstructions = showVercelDeveloperInstructions;
|
|
6
|
+
const logger_1 = require("./logger");
|
|
7
|
+
function loadIdentityFromEnv(prefix = 'MCP_IDENTITY_') {
|
|
8
|
+
const logger = (0, logger_1.getLogger)();
|
|
9
|
+
try {
|
|
10
|
+
const did = process.env[`${prefix}DID`];
|
|
11
|
+
const publicKey = process.env[`${prefix}PUBLIC_KEY`];
|
|
12
|
+
const privateKey = process.env[`${prefix}PRIVATE_KEY`];
|
|
13
|
+
const agentId = process.env[`${prefix}AGENT_ID`];
|
|
14
|
+
const agentSlug = process.env[`${prefix}AGENT_SLUG`];
|
|
15
|
+
if (did && publicKey && privateKey) {
|
|
16
|
+
logger.info('📦 Loaded identity from environment variables');
|
|
17
|
+
return {
|
|
18
|
+
did,
|
|
19
|
+
publicKey,
|
|
20
|
+
privateKey,
|
|
21
|
+
agentId: agentId || 'unknown',
|
|
22
|
+
agentSlug: agentSlug || 'unknown',
|
|
23
|
+
registeredAt: new Date().toISOString(),
|
|
24
|
+
directories: 'verified'
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
logger.debug('No identity found in environment variables');
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function generateEnvInstructions(identity, prefix = 'MCP_IDENTITY_') {
|
|
34
|
+
return `
|
|
35
|
+
# Add these to your Vercel environment variables:
|
|
36
|
+
${prefix}DID="${identity.did}"
|
|
37
|
+
${prefix}PUBLIC_KEY="${identity.publicKey}"
|
|
38
|
+
${prefix}PRIVATE_KEY="${identity.privateKey}"
|
|
39
|
+
${prefix}AGENT_ID="${identity.agentId}"
|
|
40
|
+
${prefix}AGENT_SLUG="${identity.agentSlug}"
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
function showVercelDeveloperInstructions(identity, claimUrl) {
|
|
44
|
+
const logger = (0, logger_1.getLogger)();
|
|
45
|
+
console.log('\n');
|
|
46
|
+
console.log('='.repeat(60));
|
|
47
|
+
console.log('🎉 MCP-I IDENTITY CREATED SUCCESSFULLY! 🎉');
|
|
48
|
+
console.log('='.repeat(60));
|
|
49
|
+
console.log('\n📋 Your Agent Details:\n');
|
|
50
|
+
console.log(` DID: ${identity.did}`);
|
|
51
|
+
console.log(` Agent ID: ${identity.agentId}`);
|
|
52
|
+
console.log(` Profile: https://knowthat.ai/agents/${identity.agentSlug}`);
|
|
53
|
+
if (claimUrl) {
|
|
54
|
+
console.log('\n🎯 IMPORTANT: Claim your agent to manage it:');
|
|
55
|
+
console.log(` ${claimUrl}`);
|
|
56
|
+
console.log('\n This link lets you:');
|
|
57
|
+
console.log(' - Edit your agent details');
|
|
58
|
+
console.log(' - Add logos and descriptions');
|
|
59
|
+
console.log(' - Manage directory listings');
|
|
60
|
+
console.log(' - View analytics');
|
|
61
|
+
}
|
|
62
|
+
console.log('\n⚡ For Vercel Deployment:');
|
|
63
|
+
console.log('\n1. Add these environment variables in Vercel Dashboard:');
|
|
64
|
+
console.log(generateEnvInstructions(identity));
|
|
65
|
+
console.log('2. Your identity will persist across deployments!');
|
|
66
|
+
console.log('\n' + '='.repeat(60) + '\n');
|
|
67
|
+
}
|
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.9",
|
|
4
4
|
"description": "COMING SOON: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",
|
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
"types": "./dist/registry/index.d.ts",
|
|
20
20
|
"import": "./dist/registry/index.js",
|
|
21
21
|
"require": "./dist/registry/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./nextjs": {
|
|
24
|
+
"types": "./dist/nextjs.d.ts",
|
|
25
|
+
"import": "./dist/nextjs.js",
|
|
26
|
+
"require": "./dist/nextjs.js"
|
|
27
|
+
},
|
|
28
|
+
"./vercel": {
|
|
29
|
+
"types": "./dist/vercel-adapter.d.ts",
|
|
30
|
+
"import": "./dist/vercel-adapter.js",
|
|
31
|
+
"require": "./dist/vercel-adapter.js"
|
|
22
32
|
}
|
|
23
33
|
},
|
|
24
34
|
"files": [
|