UNPKG

@kya-os/mcp-i

Version:

The TypeScript MCP framework with identity features built-in

95 lines (94 loc) 2.66 kB
/** * Global Tool Protection Registry * * Provides a global registry for tool protection configuration that can be * accessed from compiled bundle code where the MCPIRuntime instance is not directly available. * * This is used by the compiler-generated tool handlers to check if a tool requires delegation * BEFORE executing the handler function. */ import type { ToolProtectionConfig } from './tool-protection'; import type { SessionContext } from '@kya-os/contracts/handshake'; /** * Global registry for tool protection configuration */ declare class ToolProtectionRegistry { private config; private delegationVerifier; private authConfig; private debug; private currentSession; /** * Register tool protection configuration */ register(toolName: string, config: ToolProtectionConfig): void; /** * Bulk register multiple tool protections */ registerAll(configs: Record<string, ToolProtectionConfig>): void; /** * Get tool protection configuration */ get(toolName: string): ToolProtectionConfig | null; /** * Check if a tool requires delegation */ requiresDelegation(toolName: string): boolean; /** * Get required scopes for a tool */ getRequiredScopes(toolName: string): string[]; /** * Set delegation verifier (for runtime verification) */ setDelegationVerifier(verifier: any): void; /** * Set auth config (for authorization handshake) */ setAuthConfig(config: any): void; /** * Get delegation verifier */ getDelegationVerifier(): any; /** * Get auth config */ getAuthConfig(): any; /** * Enable debug logging */ setDebug(enabled: boolean): void; /** * Set current session for tool execution context */ setCurrentSession(session: SessionContext | null): void; /** * Get current session (for extracting client DID during tool execution) */ getCurrentSession(): SessionContext | null; /** * Get current agent DID from session */ getCurrentAgentDid(): string | null; /** * Clear all registrations */ clear(): void; /** * Get all registered tool names */ getProtectedTools(): string[]; } /** * Global singleton instance */ export declare const toolProtectionRegistry: ToolProtectionRegistry; /** * Helper to check if a tool is protected */ export declare function isToolProtected(toolName: string): boolean; /** * Helper to get tool protection config */ export declare function getToolProtection(toolName: string): ToolProtectionConfig | null; export {};