@kya-os/mcp-i
Version:
COMING SOON:Production-ready MCP Identity with automatic registration, key rotation, and optimized performance
89 lines • 2.56 kB
JavaScript
/**
* Registry management for MCP-I identity
*
* Currently supports KnowThat.ai as the primary registry.
* Additional registries will be added as directories adopt MCP-I.
*/
import { KnowThatRegistry } from "./knowthat.js";
/**
* Registry tier definitions
*
* As more directories adopt MCP-I, they will be added to appropriate tiers.
* Directory maintainers can contact us to discuss integration.
*/
export const REGISTRY_TIERS = {
verified: ["knowthat"], // Primary registry for MCP-I
};
/**
* Registry factory
*
* Manages registry adapters dynamically. New registries can be added
* without modifying core code.
*/
export class RegistryFactory {
static adapters = new Map([
["knowthat", () => new KnowThatRegistry()],
["knowthat.ai", () => new KnowThatRegistry()], // Support both names
// Future registries will be added here as they adopt MCP-I
]);
/**
* Get a registry adapter by name
*/
static getAdapter(name) {
const factory = this.adapters.get(name);
return factory ? factory() : null;
}
/**
* Get all adapters for a tier
*/
static getAdaptersByTier(tier) {
const registries = REGISTRY_TIERS[tier] || [];
return registries
.map((name) => this.getAdapter(name))
.filter((adapter) => adapter !== null);
}
/**
* Register a custom adapter
*/
static registerAdapter(name, factory) {
this.adapters.set(name, factory);
}
}
/**
* Resolve registries from options
*/
export function resolveRegistries(registries) {
// Default to 'verified' tier
if (!registries) {
return REGISTRY_TIERS.verified;
}
// Array of specific registries
if (Array.isArray(registries)) {
return registries;
}
// Tier name
if (typeof registries === "string") {
return REGISTRY_TIERS[registries] || [];
}
// Config object with include/exclude
const config = registries;
let included = [];
if (config.include) {
if (Array.isArray(config.include)) {
included = config.include;
}
else {
included = REGISTRY_TIERS[config.include] || [];
}
}
else {
// Default to 'verified' if no include specified
included = REGISTRY_TIERS.verified;
}
// Apply exclusions
if (config.exclude && config.exclude.length > 0) {
return included.filter((name) => !config.exclude.includes(name));
}
return included;
}
//# sourceMappingURL=index.js.map