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
133 lines • 6.2 kB
JavaScript
import { BaseToolHandler } from './base-handler.js';
import { NextJSCoreInfoHandler } from './nextjs/nextjs-core-info-handler.js';
import { NextJSAnalysisHandler } from './nextjs/nextjs-analysis-handler.js';
import { NextJSPerformanceHandler } from './nextjs/nextjs-performance-handler.js';
import { NextJSRuntimeHandler } from './nextjs/nextjs-runtime-handler.js';
import { NextJSMonitoringHandler } from './nextjs/nextjs-monitoring-handler.js';
import { NextJSCacheMonitoringHandler } from './nextjs/nextjs-cache-monitoring-handler.js';
import { NextJSSecurityHandler } from './nextjs/nextjs-security-handler.js';
import { NextJSEdgeRuntimeHandler } from './nextjs/nextjs-edge-runtime-handler.js';
import { NextJSFontHandler } from './nextjs/nextjs-font-handler.js';
import { NextJSPPRHMRHandler } from './nextjs/nextjs-ppr-hmr-handler.js';
import { NextJSRouteDebugHandler } from './nextjs/nextjs-route-debug-handler.js';
import { NextJSCachePerformanceHandler } from './nextjs/nextjs-cache-performance-handler.js';
/**
* Main handler for all Next.js-related debugging tools
* Delegates to specialized sub-handlers for different tool categories
*/
export class NextJSHandler extends BaseToolHandler {
localEngine;
nextjsEngine;
coreInfoHandler;
analysisHandler;
performanceHandler;
runtimeHandler;
monitoringHandler;
cacheMonitoringHandler;
securityHandler;
edgeRuntimeHandler;
fontHandler;
pprHMRHandler;
routeDebugHandler;
cachePerformanceHandler;
// Tools will be initialized in constructor after sub-handlers are created
tools = [];
constructor(localEngine, nextjsEngine) {
super();
this.localEngine = localEngine;
this.nextjsEngine = nextjsEngine;
// Initialize sub-handlers
this.coreInfoHandler = new NextJSCoreInfoHandler(nextjsEngine);
this.analysisHandler = new NextJSAnalysisHandler(nextjsEngine);
this.performanceHandler = new NextJSPerformanceHandler(nextjsEngine);
this.runtimeHandler = new NextJSRuntimeHandler(nextjsEngine);
this.monitoringHandler = new NextJSMonitoringHandler(nextjsEngine);
this.cacheMonitoringHandler = new NextJSCacheMonitoringHandler(nextjsEngine);
this.securityHandler = new NextJSSecurityHandler(nextjsEngine);
this.edgeRuntimeHandler = new NextJSEdgeRuntimeHandler(nextjsEngine);
this.fontHandler = new NextJSFontHandler(nextjsEngine);
this.pprHMRHandler = new NextJSPPRHMRHandler(nextjsEngine);
this.routeDebugHandler = new NextJSRouteDebugHandler(nextjsEngine);
this.cachePerformanceHandler = new NextJSCachePerformanceHandler(nextjsEngine);
// Now aggregate tools from all sub-handlers
this.tools = this.getSubHandlerTools();
}
getSubHandlerTools() {
// Get tools from all handlers (debug handler is deprecated)
const tools = [
...this.coreInfoHandler.tools,
...this.analysisHandler.tools,
...this.performanceHandler.tools,
...this.runtimeHandler.tools,
...this.cacheMonitoringHandler.tools,
...this.securityHandler.tools,
...this.edgeRuntimeHandler.tools,
...this.fontHandler.tools,
...this.pprHMRHandler.tools,
...this.routeDebugHandler.tools,
...this.cachePerformanceHandler.tools
];
return tools;
}
async handle(toolName, args, sessions) {
// Determine which sub-handler should handle this tool
const handler = this.getHandlerForTool(toolName);
if (!handler) {
throw new Error(`Unknown Next.js tool: ${toolName}`);
}
// Delegate to the appropriate sub-handler
return handler.handle(toolName, args, sessions);
}
getHandlerForTool(toolName) {
// Core Info tools (1-3: page_info, config, app_router_info)
if (this.coreInfoHandler.tools.some((t) => t.name === toolName)) {
return this.coreInfoHandler;
}
// Analysis tools (4-5: image_audit, detect_issues)
if (this.analysisHandler.tools.some((t) => t.name === toolName)) {
return this.analysisHandler;
}
// Performance tools (6-8: data_fetching, bundle_analyze, server_components)
if (this.performanceHandler.tools.some((t) => t.name === toolName)) {
return this.performanceHandler;
}
// Runtime tools (9-10: middleware_monitor, server_actions)
if (this.runtimeHandler.tools.some((t) => t.name === toolName)) {
return this.runtimeHandler;
}
// Cache monitoring tools (11-12: cache_inspector, isr_monitor)
if (this.cacheMonitoringHandler.tools.some((t) => t.name === toolName)) {
return this.cacheMonitoringHandler;
}
// Security tool (13: security_audit)
if (this.securityHandler.tools.some((t) => t.name === toolName)) {
return this.securityHandler;
}
// Edge runtime tool (14: edge_runtime)
if (this.edgeRuntimeHandler.tools.some((t) => t.name === toolName)) {
return this.edgeRuntimeHandler;
}
// Font analysis tool (15: font_analysis)
if (this.fontHandler.tools.some((t) => t.name === toolName)) {
return this.fontHandler;
}
// PPR & HMR tools (16-17: ppr_analysis, hmr_monitor)
if (this.pprHMRHandler.tools.some((t) => t.name === toolName)) {
return this.pprHMRHandler;
}
// Route debug tool (18: debug_route)
if (this.routeDebugHandler.tools.some((t) => t.name === toolName)) {
return this.routeDebugHandler;
}
// Cache & performance tools (19-20: clear_cache, perf_score)
if (this.cachePerformanceHandler.tools.some((t) => t.name === toolName)) {
return this.cachePerformanceHandler;
}
// Legacy monitoring handler (deprecated)
if (this.monitoringHandler.tools.some((t) => t.name === toolName)) {
return this.monitoringHandler;
}
return null;
}
}
//# sourceMappingURL=nextjs-handler.js.map