@kya-os/mcp-i
Version:
The TypeScript MCP framework with identity features built-in
148 lines (147 loc) • 3.65 kB
TypeScript
/**
* Well-Known Endpoints for XMCP-I Runtime
*
* Handles /.well-known/did.json and /.well-known/agent.json endpoints
* according to requirements 7.1, 7.2, 7.3, 7.4, 7.5.
*/
import { AgentIdentity } from "./identity";
/**
* DID Document structure (W3C DID Core specification)
*/
export interface DIDDocument {
"@context": string[];
id: string;
verificationMethod: VerificationMethod[];
authentication: string[];
assertionMethod: string[];
keyAgreement?: string[];
capabilityInvocation?: string[];
capabilityDelegation?: string[];
service?: ServiceEndpoint[];
}
/**
* Verification Method for DID Document
*/
export interface VerificationMethod {
id: string;
type: string;
controller: string;
publicKeyMultibase?: string;
publicKeyJwk?: any;
}
/**
* Service Endpoint for DID Document
*/
export interface ServiceEndpoint {
id: string;
type: string;
serviceEndpoint: string;
}
/**
* Agent Document structure (XMCP-I specific)
*/
export interface AgentDocument {
id: string;
capabilities: {
"mcp-i": ["handshake", "signing", "verification"];
};
registry?: {
kta?: string;
mcp?: string;
};
metadata?: {
name?: string;
description?: string;
version?: string;
};
}
/**
* Well-known endpoint configuration
*/
export interface WellKnownConfig {
environment: "development" | "production";
baseUrl?: string;
agentMetadata?: {
name?: string;
description?: string;
version?: string;
};
registryUrls?: {
kta?: string;
mcp?: string;
};
}
/**
* Well-known endpoints manager
*/
export declare class WellKnownManager {
private identity;
private config;
constructor(identity: AgentIdentity, config: WellKnownConfig);
/**
* Generate DID document for /.well-known/did.json
* Requirements: 7.1, 7.5
*/
generateDIDDocument(): DIDDocument;
/**
* Generate agent document for /.well-known/agent.json
* Requirements: 7.2, 7.3
*/
generateAgentDocument(): AgentDocument;
/**
* Get HTTP headers for DID document
* Requirements: 7.4, 7.5
*/
getDIDDocumentHeaders(): Record<string, string>;
/**
* Get HTTP headers for agent document
* Requirements: 7.2, 7.5
*/
getAgentDocumentHeaders(): Record<string, string>;
/**
* Encode public key as multibase (base58btc with 'z' prefix for Ed25519)
*/
private encodePublicKeyMultibase;
/**
* Update configuration
*/
updateConfig(config: Partial<WellKnownConfig>): void;
/**
* Get current configuration
*/
getConfig(): WellKnownConfig;
}
/**
* Express/HTTP handler for well-known endpoints
*/
export interface WellKnownHandler {
handleDIDDocument(): {
status: number;
headers: Record<string, string>;
body: string;
};
handleAgentDocument(): {
status: number;
headers: Record<string, string>;
body: string;
};
}
/**
* Create well-known endpoint handler
*/
export declare function createWellKnownHandler(identity: AgentIdentity, config: WellKnownConfig): WellKnownHandler;
/**
* Utility functions
*/
/**
* Validate DID document structure
*/
export declare function validateDIDDocument(doc: any): doc is DIDDocument;
/**
* Validate agent document structure
*/
export declare function validateAgentDocument(doc: any): doc is AgentDocument;
/**
* Extract DID from URL path (for did:web resolution)
*/
export declare function extractDIDFromPath(path: string, baseUrl: string): string | null;