ai-debug-local-mcp
Version:
🎯 ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh
75 lines • 2.73 kB
TypeScript
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import { ResourceManager } from '../utils/resource-manager.js';
import { SessionResourceManager } from '../utils/session-resource-manager.js';
/**
* Base interface for all tool handlers
*/
export interface ToolHandler {
/**
* Array of tools this handler provides
*/
tools: Tool[];
/**
* Handle a tool request
* @param toolName The name of the tool to execute
* @param args The arguments passed to the tool
* @param sessions Active debugging sessions
* @returns Promise with the tool result
*/
handle(toolName: string, args: any, sessions: Map<string, any>): Promise<any>;
/**
* Optional initialization method
*/
initialize?(): Promise<void>;
}
export interface BaseHandlerOptions {
resourceManager?: ResourceManager;
sessionResourceManager?: SessionResourceManager;
}
/**
* Base class with common functionality for tool handlers
*/
export declare abstract class BaseToolHandler implements ToolHandler {
abstract tools: Tool[];
abstract handle(toolName: string, args: any, sessions: Map<string, any>): Promise<any>;
/**
* Helper to get a session or throw if not found
*/
protected getSession(sessionId: string, sessions: Map<string, any>): any;
/**
* Format content for tool response
*/
protected formatResponse(content: string, mimeType?: string): any;
/**
* Helper to validate required args
*/
protected validateArgs(args: any, requiredFields: string[]): void;
}
/**
* Base handler with resource management capabilities
*/
export declare abstract class BaseHandler extends BaseToolHandler {
protected readonly resourceManager: ResourceManager;
protected readonly sessionResourceManager: SessionResourceManager;
protected readonly handlerName: string;
tools: Tool[];
handle(toolName: string, args: any, sessions: Map<string, any>): Promise<any>;
constructor(options?: BaseHandlerOptions);
/**
* Track a resource for automatic cleanup
*/
protected trackResource(resourceType: 'page' | 'browser' | 'context', sessionId: string, resource: any): void;
/**
* Get session with resource tracking - replaces the problematic sessions.get() pattern
*/
protected getSessionWithTracking(sessionId: string, sessions: Map<string, any>): any;
/**
* Cleanup resources for this handler
*/
protected cleanup(sessionId?: string): Promise<void>;
/**
* Get resource cleanup timeout based on resource type
*/
protected getCleanupTimeout(resourceType: 'page' | 'browser' | 'context'): number;
}
//# sourceMappingURL=base-handler-migrated.d.ts.map