/** * Agentic QE v3 - MCP Tool Base Class * * Base infrastructure for MCP tools implementing ADR-010. * All domain tools extend this base class. */ import { DomainName } from '../../shared/types'; import { ToolResult, ToolResultMetadata } from '../types'; /** * JSON Schema property definition for tool parameters */ export interface MCPSchemaProperty { type: 'string' | 'number' | 'boolean' | 'object' | 'array'; description: string; enum?: string[]; default?: unknown; items?: MCPSchemaProperty; properties?: Record; required?: string[]; minimum?: number; maximum?: number; minLength?: number; maxLength?: number; } /** * Complete JSON Schema for MCP tool */ export interface MCPToolSchema { type: 'object'; properties: Record; required?: string[]; additionalProperties?: boolean; } /** * Tool configuration for registration */ export interface MCPToolConfig { name: string; description: string; domain: DomainName; schema: MCPToolSchema; streaming?: boolean; timeout?: number; } /** * Streaming callback for long-running operations */ export type StreamCallback = (chunk: unknown) => void; /** * Tool execution context */ export interface MCPToolContext { requestId: string; startTime: number; streaming?: boolean; onStream?: StreamCallback; abortSignal?: AbortSignal; /** Explicit demo mode - when true, returns sample data without calling real services */ demoMode?: boolean; } /** * Data source tracking for audit/transparency */ export type DataSource = 'real' | 'demo' | 'fallback'; /** * Logger interface for tool operations */ export interface ToolLogger { info(message: string, data?: Record): void; warn(message: string, data?: Record): void; error(message: string, data?: Record): void; } /** * Default console logger */ export declare const defaultToolLogger: ToolLogger; /** * Abstract base class for all MCP tools * * @template TParams - Tool parameter type * @template TResult - Tool result type */ export declare abstract class MCPToolBase = Record, TResult = unknown> { /** * Tool configuration */ abstract readonly config: MCPToolConfig; /** * Logger for tool operations */ protected logger: ToolLogger; /** * Track data source for current execution */ protected currentDataSource: DataSource; /** * Set logger for this tool */ setLogger(logger: ToolLogger): void; /** * Mark result as coming from demo/sample data * MUST be called when returning sample data for transparency */ protected markAsDemoData(context: MCPToolContext, reason: string): void; /** * Mark result as coming from real service data */ protected markAsRealData(): void; /** * Check if demo mode is explicitly requested */ protected isDemoMode(context: MCPToolContext): boolean; /** * Execute the tool with parameters * * @param params - Tool parameters * @param context - Execution context * @returns Tool result */ abstract execute(params: TParams, context: MCPToolContext): Promise>; /** * Validate parameters against schema * * @param params - Parameters to validate * @returns Validation result */ validate(params: unknown): { valid: boolean; errors: string[]; }; /** * Validate a single value against its schema */ private validateType; /** * Invoke the tool (validate and execute) * * @param params - Tool parameters * @param options - Execution options * @returns Tool result with metadata */ invoke(params: TParams, options?: { streaming?: boolean; onStream?: StreamCallback; abortSignal?: AbortSignal; /** Explicit demo mode - returns sample data without calling real services */ demoMode?: boolean; }): Promise>; /** * Create result metadata */ protected createMetadata(startTime: number, requestId: string): ToolResultMetadata; /** * Helper to emit streaming data */ protected emitStream(context: MCPToolContext, data: unknown): void; /** * Helper to check if operation was aborted */ protected isAborted(context: MCPToolContext): boolean; /** * Get tool name for registration */ get name(): string; /** * Get tool description */ get description(): string; /** * Get domain this tool belongs to */ get domain(): DomainName; /** * Get JSON schema for the tool */ getSchema(): MCPToolSchema; /** * Get tool timeout */ get timeout(): number; /** * Check if tool supports streaming */ get supportsStreaming(): boolean; } //# sourceMappingURL=base.d.ts.map