UNPKG

@kya-os/mcp-i

Version:

The TypeScript MCP framework with identity features built-in

121 lines (120 loc) 3.77 kB
/** * Tool Protection Configuration and Resolution System (Phase 1.5) * * Enables zero-code tool protection by configuring which tools require delegation * through configuration rather than manual code wrapping. * * Configuration Resolution Priority (highest to lowest): * 1. Inline config (passed to runtime) - for testing and overrides * 2. Local file (tool-protections.json) - for development * 3. AgentShield API - for production (NOT IMPLEMENTED YET) */ /** * Protection configuration for a single tool */ export interface ToolProtectionConfig { /** Whether this tool requires delegation authorization */ requiresDelegation: boolean; /** Required scopes for this tool (Phase 1: simple string array) */ requiredScopes?: string[]; /** Optional risk level indicator (for AgentShield UI) */ riskLevel?: 'low' | 'medium' | 'high' | 'critical'; /** Optional custom authorization URL for this specific tool */ authorizationUrl?: string; } /** * Map of tool names to their protection configurations */ export type ToolProtectionMap = Record<string, ToolProtectionConfig>; /** * Tool protection configuration source */ export interface ToolProtectionConfigSource { /** Source name for debugging */ name: string; /** Priority level (higher = higher priority) */ priority: number; /** Load the configuration */ load(): Promise<ToolProtectionMap | null>; } /** * Inline configuration source (highest priority) */ export declare class InlineToolProtectionSource implements ToolProtectionConfigSource { private config; name: string; priority: number; constructor(config: ToolProtectionMap); load(): Promise<ToolProtectionMap | null>; } /** * Local file configuration source */ export declare class FileToolProtectionSource implements ToolProtectionConfigSource { private filePath; name: string; priority: number; constructor(filePath: string); load(): Promise<ToolProtectionMap | null>; } /** * AgentShield API configuration source (lowest priority) * NOTE: This is a placeholder for future implementation */ export declare class AgentShieldToolProtectionSource implements ToolProtectionConfigSource { private apiUrl; private agentDid; private apiKey?; name: string; priority: number; constructor(apiUrl: string, agentDid: string, apiKey?: string | undefined); load(): Promise<ToolProtectionMap | null>; } /** * Tool protection resolver - merges configs from multiple sources */ export declare class ToolProtectionResolver { private sources; private mergedConfig; private debug; constructor(options?: { debug?: boolean; }); /** * Add a configuration source */ addSource(source: ToolProtectionConfigSource): void; /** * Load and merge all configurations */ resolve(): Promise<ToolProtectionMap>; /** * Get protection config for a specific tool */ getToolProtection(toolName: string): ToolProtectionConfig | null; /** * Check if a tool requires delegation */ requiresDelegation(toolName: string): boolean; /** * Get required scopes for a tool */ getRequiredScopes(toolName: string): string[]; } /** * Create default tool protection resolver */ export declare function createToolProtectionResolver(options: { /** Inline configuration (highest priority) */ inline?: ToolProtectionMap; /** Local file path (default: tool-protections.json) */ localFile?: string | false; /** AgentShield API configuration */ agentShield?: { apiUrl: string; agentDid: string; apiKey?: string; }; /** Enable debug logging */ debug?: boolean; }): ToolProtectionResolver;