UNPKG

@kya-os/mcp-i

Version:

COMING SOON:Production-ready MCP Identity with automatic registration, key rotation, and optimized performance

80 lines • 2.95 kB
/** * Vercel/Edge Runtime Adapter for MCP-I * * Provides special handling for serverless environments where: * - No file system access * - Environment variables for persistence * - Better developer console output */ import { getLogger } from './logger.js'; /** * Check for identity in environment variables */ export function loadIdentityFromEnv(prefix = 'MCP_IDENTITY_') { const logger = getLogger(); try { const did = process.env[`${prefix}DID`]; const publicKey = process.env[`${prefix}PUBLIC_KEY`]; const privateKey = process.env[`${prefix}PRIVATE_KEY`]; const agentId = process.env[`${prefix}AGENT_ID`]; const agentSlug = process.env[`${prefix}AGENT_SLUG`]; if (did && publicKey && privateKey) { logger.info('šŸ“¦ Loaded identity from environment variables'); return { did, publicKey, privateKey, agentId: agentId || 'unknown', agentSlug: agentSlug || 'unknown', registeredAt: new Date().toISOString(), directories: 'verified' }; } } catch (error) { logger.debug('No identity found in environment variables'); } return null; } /** * Generate environment variable instructions */ export function generateEnvInstructions(identity, prefix = 'MCP_IDENTITY_') { return ` # Add these to your Vercel environment variables: ${prefix}DID="${identity.did}" ${prefix}PUBLIC_KEY="${identity.publicKey}" ${prefix}PRIVATE_KEY="${identity.privateKey}" ${prefix}AGENT_ID="${identity.agentId}" ${prefix}AGENT_SLUG="${identity.agentSlug}" `; } /** * Show developer-friendly console output */ export function showVercelDeveloperInstructions(identity, claimUrl) { const logger = getLogger(); console.log('\n'); console.log('='.repeat(60)); console.log('šŸŽ‰ MCP-I IDENTITY CREATED SUCCESSFULLY! šŸŽ‰'); console.log('='.repeat(60)); console.log('\nšŸ“‹ Your Agent Details:\n'); console.log(` DID: ${identity.did}`); console.log(` Agent ID: ${identity.agentId}`); console.log(` Profile: https://knowthat.ai/agents/${identity.agentSlug}`); if (claimUrl) { console.log('\nšŸŽÆ IMPORTANT: Claim your agent to manage it:'); console.log(` ${claimUrl}`); console.log('\n This link lets you:'); console.log(' - Edit your agent details'); console.log(' - Add logos and descriptions'); console.log(' - Manage directory listings'); console.log(' - View analytics'); } console.log('\n⚔ For Vercel Deployment:'); console.log('\n1. Add these environment variables in Vercel Dashboard:'); console.log(generateEnvInstructions(identity)); console.log('2. Your identity will persist across deployments!'); console.log('\n' + '='.repeat(60) + '\n'); } //# sourceMappingURL=vercel-adapter.js.map