@kya-os/mcp-i
Version:
COMING SOON:Production-ready MCP Identity with automatic registration, key rotation, and optimized performance
293 lines • 7.55 kB
TypeScript
/**
* Type definitions for MCP-I challenge-response authentication
*/
export type RegistryName = string;
export type RegistryTier = 'verified';
export interface RegistryConfig {
include?: string[] | 'verified';
exclude?: string[];
}
export interface RegistryStatus {
name: string;
status: 'active' | 'pending' | 'failed';
registeredAt?: string;
type?: 'primary' | 'secondary';
error?: string;
}
export interface RegistryAdapter {
name: string;
type: 'primary' | 'secondary';
publish(data: any): Promise<any>;
verify?(did: string): Promise<boolean>;
}
export interface RegistryPublishData {
did: string;
name: string;
description?: string;
repository?: string;
publicKey: string;
metadata?: Record<string, any>;
}
export interface RegistryPublishResult {
success: boolean;
registryAgentId?: string;
profileUrl?: string;
error?: string;
claimUrl?: string;
claimToken?: string;
generatedKeys?: {
publicKey: string;
privateKey: string;
warning: string;
};
}
/**
* Directory configuration for agent listings
*/
export type DirectoryPreference = string[] | 'verified' | 'none';
/**
* Known directory names
*/
export type DirectoryName = 'smithery' | 'glama' | string;
/**
* Progress event for CLI integration
* @internal - For use by @kya-os/cli package only
* @private
*/
export interface MCPIdentityProgressEvent {
stage: 'checking_existing' | 'generating_keys' | 'registering' | 'saving' | 'complete';
progress: number;
message?: string;
data?: any;
}
/**
* Progress callback for CLI integration
* @internal - For use by @kya-os/cli package only
* @private
*/
export interface MCPIdentityProgressCallback {
(event: MCPIdentityProgressEvent): void;
}
export interface MCPIdentityOptions {
name?: string;
description?: string;
repository?: string;
apiEndpoint?: string;
persistencePath?: string;
storage?: 'file' | 'memory' | 'auto';
memoryKey?: string;
transport?: 'axios' | 'fetch' | 'auto';
/**
* Processing mode for registry operations
* - 'sync': Request immediate processing (better UX, may not always be honored)
* - 'async': Accept async processing with polling
* - 'auto': Let the SDK decide based on platform capabilities
* @default 'auto'
*/
processingMode?: 'sync' | 'async' | 'auto';
/**
* Registry endpoint preference
* - 'cli': Use the fast CLI endpoint (100-200ms, no polling)
* - 'auto-register': Use the traditional async endpoint (5-10s with polling)
* - 'auto': Automatically select based on context (CLI mode, platform, etc.)
* @default 'auto'
*/
registryEndpoint?: 'cli' | 'auto-register' | 'auto';
timestampTolerance?: number;
enableNonceTracking?: boolean;
encryptionPassword?: string;
/**
* Directory preferences for agent listings
* - string[]: List specific directories like ["smithery", "glama"]
* - 'verified': List on all verified directories (default)
* - 'none': Don't list on any directories (registry only)
*
* The actual directory submission is handled by knowthat.ai
*/
directories?: DirectoryPreference;
/**
* Development vs Production mode
* - 'development': Creates draft DID that expires after 30 days
* - 'production': Creates permanent DID (requires proof of usage)
* @default 'production'
*/
mode?: 'development' | 'production';
logger?: Logger;
logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
/**
* Progress callback for CLI integration
* @internal - For use by @kya-os/cli package only
* @private
*/
onProgress?: MCPIdentityProgressCallback;
registrationPollInterval?: number;
registrationMaxPollingTime?: number;
registrationPollBackoff?: boolean;
}
/**
* MCP Server middleware types
*/
export interface MCPServer {
setRequestHandler(method: string, handler: Function): void;
connect(transport: any): Promise<void>;
serverInfo?: {
capabilities?: Record<string, any>;
};
}
export interface MCPMiddleware {
(server: MCPServer, identity: any): void;
}
export interface MCPRequest<T = any> {
method: string;
params?: T;
}
export interface MCPResponse<T = any> {
content?: T;
error?: {
code: number;
message: string;
};
}
/**
* Logger interface
*/
export interface Logger {
debug(message: string, ...args: any[]): void;
info(message: string, ...args: any[]): void;
warn(message: string, ...args: any[]): void;
error(message: string, ...args: any[]): void;
}
export interface AutoRegisterResponse {
success: boolean;
did: string;
agent: {
id: string;
slug: string;
name: string;
url: string;
};
keys: {
publicKey: string;
privateKey?: string;
};
}
/**
* Async registration response from v2.0 API
*/
export interface AsyncRegistrationResponse {
success: boolean;
jobId: string;
status: string;
message: string;
estimatedTime: string;
}
/**
* Registration status response from polling endpoint
*/
export interface RegistrationStatusResponse {
jobId: string;
status: 'pending' | 'processing' | 'completed' | 'failed';
result?: AutoRegisterResponse;
error?: {
message: string;
code?: string;
};
progress?: number;
estimatedTimeRemaining?: number;
}
/**
* CLI register endpoint request
*/
export interface CLIRegisterRequest {
name: string;
description?: string;
repository?: string;
publicKey?: string;
}
/**
* CLI register endpoint response
*/
export interface CLIRegisterResponse {
success: boolean;
did: string;
agent: {
id: string;
slug: string;
name: string;
url: string;
};
claimUrl: string;
claimToken: string;
keys?: {
publicKey: string;
privateKey: string;
warning: string;
};
responseTime: number;
}
export interface PersistedIdentity {
did: string;
publicKey: string;
privateKey: string;
agentId: string;
agentSlug: string;
registeredAt: string;
/** Directory preferences submitted to knowthat.ai */
directories?: DirectoryPreference;
}
/**
* Registration data sent to knowthat.ai
*/
export interface RegistrationData {
name: string;
description?: string;
repository?: string;
publicKey?: string;
directories?: DirectoryPreference;
metadata?: Record<string, any>;
}
/**
* MCP-I Challenge structure
*/
export interface Challenge {
nonce: string;
timestamp: number;
verifier_did?: string;
scope?: string[];
}
/**
* MCP-I Challenge Response structure
*/
export interface ChallengeResponse {
did: string;
signature: string;
timestamp: number;
nonce: string;
publicKey?: string;
}
/**
* MCP-I Capabilities advertisement
*/
export interface MCPICapabilities {
version: string;
did: string;
publicKey: string;
conformanceLevel: number;
handshakeSupported: boolean;
handshakeEndpoint?: string;
verificationEndpoint?: string;
registry?: string;
}
/**
* Response with MCP-I identity attached
*/
export interface SignedResponse<T = any> {
[key: string]: any;
_mcp_identity: {
did: string;
signature: string;
timestamp: string;
conformanceLevel?: number;
};
}
//# sourceMappingURL=types.d.ts.map