@kya-os/mcp-i
Version:
COMING SOON:Production-ready MCP Identity with automatic registration, key rotation, and optimized performance
84 lines (83 loc) ⢠4.23 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MCPIdentity = exports.enableMCPIdentity = void 0;
exports.enableMCPIdentityForNextJS = enableMCPIdentityForNextJS;
const index_1 = require("./index");
async function enableMCPIdentityForNextJS(options = {}) {
const isProduction = process.env.NODE_ENV === "production";
const isVercel = process.env.VERCEL || process.env.VERCEL_ENV;
try {
console.log(`\nš Initializing MCP-I for Next.js...`);
const identity = await (0, index_1.enableMCPIdentity)({
...options,
transport: "fetch",
storage: "memory",
logLevel: options.logLevel || (isProduction ? "error" : "info"),
mode: isProduction ? "production" : "development",
});
if (!isProduction && options.showSetupInstructions !== false) {
console.log("\nā
MCP-I Ready for Next.js!");
console.log(`\nš Quick Info:`);
console.log(` Environment: ${isVercel ? "Vercel" : "Local"}`);
console.log(` DID: ${identity.did}`);
if (isVercel && !process.env.MCP_IDENTITY_AGENT_DID) {
console.log("\nā ļø Remember to set environment variables in Vercel Dashboard!");
console.log(" See console output above for the exact variables to add.");
}
}
return identity;
}
catch (error) {
console.error("\nā MCP-I Initialization Failed\n");
if (error?.message?.includes("429")) {
console.error("š Rate Limit Hit");
console.error(" You've made too many registration attempts.");
console.error(" Wait a few minutes and try again.");
console.error("\nš” Tip: In development, you can use environment variables to persist identity:");
console.error(" 1. Copy the MCP_IDENTITY_* variables from a successful run");
console.error(" 2. Add them to your .env.local file");
}
else if (error?.message?.includes("500") ||
error?.message?.includes("fetch failed")) {
console.error("š Server Connection Error");
console.error(" Cannot connect to knowthat.ai registry.");
console.error("\nš” Possible causes:");
console.error(" - Registry is temporarily down");
console.error(" - Network connectivity issues");
console.error(" - Firewall blocking outbound connections");
console.error("\nš” Workaround for development:");
console.error(' Add to your route: mode: "development" to allow offline mode');
}
else if (error?.message?.includes("MODULE_NOT_FOUND")) {
console.error("š Missing Dependencies");
console.error(" Make sure all dependencies are installed:");
console.error(" npm install @kya-os/mcp-i");
}
else {
console.error("š Unexpected Error:", error?.message || error);
}
if (!isProduction) {
console.error("\nš Full Error Details:");
console.error(error);
}
throw error;
}
}
var index_2 = require("./index");
Object.defineProperty(exports, "enableMCPIdentity", { enumerable: true, get: function () { return index_2.enableMCPIdentity; } });
Object.defineProperty(exports, "MCPIdentity", { enumerable: true, get: function () { return index_2.MCPIdentity; } });
__exportStar(require("./types"), exports);