/** * Tool Annotation Pattern Configuration * * Configurable pattern system for inferring expected tool behavior from names. * Supports JSON configuration files for customization. * * Pattern data is now externalized to JSON files for easier maintenance. * @see patterns/annotation-patterns.json * * @since v1.43.0 (Issue #200 - V2 Refactoring) - Patterns moved to JSON */ import type { Logger } from "../lib/logger.js"; /** * Pattern configuration for tool behavior inference. * Each category contains string patterns that are converted to RegExp at runtime. * Patterns should end with underscore or hyphen (e.g., "get_", "delete-") */ export interface AnnotationPatternConfig { /** Patterns indicating read-only operations (e.g., "get_", "list_", "fetch_") */ readOnly: string[]; /** Patterns indicating destructive operations (e.g., "delete_", "remove_", "destroy_") */ destructive: string[]; /** Patterns indicating write operations that are not destructive (e.g., "create_", "add_") */ write: string[]; /** Patterns that are semantically ambiguous - behavior varies by implementation */ ambiguous: string[]; } /** * Compiled patterns ready for matching. * String patterns are converted to RegExp objects. */ export interface CompiledPatterns { readOnly: RegExp[]; destructive: RegExp[]; write: RegExp[]; ambiguous: RegExp[]; } /** * Result of pattern matching with confidence scoring. */ export interface PatternMatchResult { category: "readOnly" | "destructive" | "write" | "ambiguous" | "unknown"; pattern: string | null; confidence: "high" | "medium" | "low"; isAmbiguous: boolean; } /** * Default annotation patterns. * These patterns have been validated against real-world MCP servers. * * Pattern data is loaded from patterns/annotation-patterns.json * @see patterns/annotation-patterns.json for the actual pattern values */ export declare const DEFAULT_ANNOTATION_PATTERNS: AnnotationPatternConfig; /** * Compile string patterns into RegExp objects for efficient matching. */ export declare function compilePatterns(config: AnnotationPatternConfig): CompiledPatterns; /** * Load pattern configuration from a JSON file. * Partial configs are merged with defaults. * * @param configPath - Path to JSON configuration file * @param logger - Optional logger for diagnostic output * @returns Merged configuration with defaults */ export declare function loadPatternConfig(configPath?: string, logger?: Logger): AnnotationPatternConfig; /** * Match a tool name against compiled patterns and return the result. * * @param toolName - The tool name to match * @param patterns - Compiled pattern sets * @returns Match result with category, confidence, and ambiguity flag */ export declare function matchToolPattern(toolName: string, patterns: CompiledPatterns): PatternMatchResult; /** * Get compiled default patterns (cached for performance). */ export declare function getDefaultCompiledPatterns(): CompiledPatterns; /** * Persistence model for MCP servers. * Determines whether write operations persist immediately or are deferred until explicit save. */ export type PersistenceModel = "immediate" | "deferred" | "unknown"; /** * Result of persistence model detection for a server. */ export interface ServerPersistenceContext { model: PersistenceModel; hasSaveOperations: boolean; hasWriteOperations: boolean; indicators: string[]; confidence: "high" | "medium" | "low"; } /** * Patterns indicating explicit save/persist operations. * If a server has these, write operations are likely in-memory until save. */ export declare const SAVE_OPERATION_PATTERNS: RegExp[]; /** * Patterns indicating write operations (create, add, update, etc.). */ export declare const WRITE_OPERATION_PATTERNS: RegExp[]; /** * Keywords in tool descriptions that indicate immediate persistence to storage. * These suggest the operation writes directly to database/file/API. */ export declare const IMMEDIATE_PERSISTENCE_INDICATORS: RegExp[]; /** * Keywords in tool descriptions that indicate deferred/in-memory operations. * These suggest the operation modifies state that isn't persisted until explicit save. */ export declare const DEFERRED_PERSISTENCE_INDICATORS: RegExp[]; /** * Detect the persistence model of an MCP server by analyzing its tool set. * * Logic: * - If server has write ops (create_, add_) but NO save ops (save_, persist_) → immediate * - If server has write ops AND save ops → deferred (in-memory until save) * - Otherwise → unknown * * @param toolNames - Array of tool names from the server * @returns ServerPersistenceContext with model and indicators */ export declare function detectPersistenceModel(toolNames: string[]): ServerPersistenceContext; /** * Check if a tool description indicates immediate persistence. * * @param description - Tool description to analyze * @returns Object with detection result and matched indicators */ export declare function checkDescriptionForImmediatePersistence(description: string): { indicatesImmediate: boolean; indicatesDeferred: boolean; matchedPatterns: string[]; }; //# sourceMappingURL=annotationPatterns.d.ts.map