dev3000 0.0.75 → 0.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +89 -27
  2. package/dist/src/tui-interface-impl.tsx +80 -52
  3. package/dist/tui-interface-impl.d.ts.map +1 -1
  4. package/dist/tui-interface-impl.js +46 -12
  5. package/dist/tui-interface-impl.js.map +1 -1
  6. package/mcp-server/.next/BUILD_ID +1 -1
  7. package/mcp-server/.next/build-manifest.json +2 -2
  8. package/mcp-server/.next/fallback-build-manifest.json +2 -2
  9. package/mcp-server/.next/prerender-manifest.json +3 -3
  10. package/mcp-server/.next/server/app/_global-error.html +2 -2
  11. package/mcp-server/.next/server/app/_global-error.rsc +1 -1
  12. package/mcp-server/.next/server/app/_not-found.html +1 -1
  13. package/mcp-server/.next/server/app/_not-found.rsc +1 -1
  14. package/mcp-server/.next/server/app/index.html +1 -1
  15. package/mcp-server/.next/server/app/index.rsc +1 -1
  16. package/mcp-server/.next/server/app/mcp/route.js +2 -2
  17. package/mcp-server/.next/server/app/mcp/route.js.nft.json +1 -1
  18. package/mcp-server/.next/server/chunks/[root-of-the-server]__270b33b7._.js +20 -5
  19. package/mcp-server/.next/server/chunks/[root-of-the-server]__270b33b7._.js.map +1 -1
  20. package/mcp-server/.next/server/chunks/{[root-of-the-server]__6fa7ea53._.js → [root-of-the-server]__2942c072._.js} +2 -2
  21. package/mcp-server/.next/server/server-reference-manifest.js +1 -1
  22. package/mcp-server/.next/server/server-reference-manifest.json +1 -1
  23. package/mcp-server/app/mcp/tools.ts +740 -155
  24. package/package.json +1 -1
  25. package/src/tui-interface-impl.tsx +80 -52
  26. /package/mcp-server/.next/server/chunks/{[root-of-the-server]__6fa7ea53._.js.map → [root-of-the-server]__2942c072._.js.map} +0 -0
  27. /package/mcp-server/.next/static/{Uhi1zQoeqTo0Q0A7NvQ69 → NWQx_KX68gOo5fDkdXq6G}/_buildManifest.js +0 -0
  28. /package/mcp-server/.next/static/{Uhi1zQoeqTo0Q0A7NvQ69 → NWQx_KX68gOo5fDkdXq6G}/_clientMiddlewareManifest.json +0 -0
  29. /package/mcp-server/.next/static/{Uhi1zQoeqTo0Q0A7NvQ69 → NWQx_KX68gOo5fDkdXq6G}/_ssgManifest.js +0 -0
@@ -19,7 +19,10 @@ export const TOOL_DESCRIPTIONS = {
19
19
  "🌐 **INTELLIGENT BROWSER AUTOMATION** - Smart browser action routing that automatically delegates to chrome-devtools MCP when available for superior automation capabilities.\n\n🎯 **INTELLIGENT DELEGATION:**\n• Screenshots → chrome-devtools MCP (better quality, no conflicts)\n• Navigation → chrome-devtools MCP (more reliable page handling)\n• Clicks → chrome-devtools MCP (precise coordinate-based interaction)\n• JavaScript evaluation → chrome-devtools MCP (enhanced debugging)\n• Scrolling & typing → dev3000 fallback (specialized actions)\n\n⚡ **PROGRESSIVE ENHANCEMENT:**\n• Uses chrome-devtools MCP when available for best results\n• Falls back to dev3000's native implementation when chrome-devtools unavailable\n• Shares the same Chrome instance via CDP URL coordination\n• Eliminates browser conflicts between tools\n\n💡 **PERFECT FOR:** Browser automation that automatically chooses the best tool for each action, ensuring optimal results whether chrome-devtools MCP is available or not.",
20
20
 
21
21
  discover_available_mcps:
22
- "🔍 **PROACTIVE MCP DISCOVERY** - Automatically discover other MCPs running on the system using process detection and port pinging. No need to manually specify which MCPs are available!\n\n🎯 **DISCOVERY METHODS:**\n• Process Detection: Scans running processes for known MCP patterns\n• Port Pinging: Tests standard MCP ports with HTTP/WebSocket health checks\n• Cross-Platform: Works on macOS, Linux, and Windows\n\n⚡ **SMART DETECTION:**\n• Detects nextjs-dev, chrome-devtools, and other common MCPs\n• Fallback from process detection to port pinging\n• Logs all discovery attempts for transparency\n\n💡 **PERFECT FOR:** 'What MCPs are available?' or when you want dev3000 to automatically find and integrate with other debugging tools!"
22
+ "🔍 **PROACTIVE MCP DISCOVERY** - Automatically discover other MCPs running on the system using process detection and port pinging. No need to manually specify which MCPs are available!\n\n🎯 **DISCOVERY METHODS:**\n• Process Detection: Scans running processes for known MCP patterns\n• Port Pinging: Tests standard MCP ports with HTTP/WebSocket health checks\n• Cross-Platform: Works on macOS, Linux, and Windows\n\n⚡ **SMART DETECTION:**\n• Detects nextjs-dev, chrome-devtools, and other common MCPs\n• Fallback from process detection to port pinging\n• Logs all discovery attempts for transparency\n\n💡 **PERFECT FOR:** 'What MCPs are available?' or when you want dev3000 to automatically find and integrate with other debugging tools!",
23
+
24
+ get_mcp_capabilities:
25
+ "🔍 **MCP CAPABILITY INSPECTOR** - Discover and inspect the current capabilities of available MCPs (dev3000-chrome-devtools and dev3000-nextjs-dev). Shows dynamically discovered functions with descriptions and categories. Perfect for understanding what enhanced capabilities are available for augmented delegation.\n\n⚡ **DYNAMIC DISCOVERY:**\n• Introspects MCP logs and schemas to find available functions\n• Categorizes capabilities as 'advanced' vs 'basic'\n• Generates intelligent descriptions based on function names\n• Caches results for performance (5min TTL)\n\n🎯 **REAL-TIME UPDATES:**\n• Automatically adapts when MCPs add new capabilities\n• No manual maintenance required\n• Always shows current state of available tools\n\n💡 **PERFECT FOR:** Understanding what enhanced capabilities are currently available, debugging MCP integration issues, or planning augmented debugging workflows."
23
26
  }
24
27
 
25
28
  // Types
@@ -54,6 +57,10 @@ export interface ExecuteBrowserActionParams {
54
57
  params?: Record<string, unknown>
55
58
  }
56
59
 
60
+ export interface GetMcpCapabilitiesParams {
61
+ mcpName?: string // Optional - if not provided, shows all available MCPs
62
+ }
63
+
57
64
  // Structured data types for raw data output
58
65
  export interface ErrorWithInteractions {
59
66
  timestamp: string
@@ -531,7 +538,7 @@ export async function fixMyApp({
531
538
  if (integrateNextjs) {
532
539
  results.push("")
533
540
  results.push("⚛️ **Next.js Integration Active:**")
534
- const nextjsSuggestions = generateNextjsSuggestions(allErrors.join(" "))
541
+ const nextjsSuggestions = await generateNextjsSuggestions(allErrors.join(" "))
535
542
  nextjsSuggestions.forEach((suggestion) => {
536
543
  const params = suggestion.params
537
544
  ? `(${Object.entries(suggestion.params)
@@ -552,7 +559,7 @@ export async function fixMyApp({
552
559
  if (integrateChromeDevtools) {
553
560
  results.push("")
554
561
  results.push("🌐 **Chrome DevTools Integration Active:**")
555
- const chromeSuggestions = generateChromeDevtoolsSuggestions(allErrors.join(" "))
562
+ const chromeSuggestions = await generateChromeDevtoolsSuggestions(allErrors.join(" "))
556
563
  chromeSuggestions.forEach((suggestion) => {
557
564
  const params = suggestion.params
558
565
  ? `(${Object.entries(suggestion.params)
@@ -729,11 +736,11 @@ const value = data?.property?.nestedProperty`,
729
736
  const suggestedIntegrations: StructuredAnalysisResult["suggestedIntegrations"] = {}
730
737
 
731
738
  if (integrateNextjs) {
732
- suggestedIntegrations.nextjs = generateNextjsSuggestions(allErrors.join(" "))
739
+ suggestedIntegrations.nextjs = await generateNextjsSuggestions(allErrors.join(" "))
733
740
  }
734
741
 
735
742
  if (integrateChromeDevtools) {
736
- suggestedIntegrations.chrome = generateChromeDevtoolsSuggestions(allErrors.join(" "))
743
+ suggestedIntegrations.chrome = await generateChromeDevtoolsSuggestions(allErrors.join(" "))
737
744
  }
738
745
 
739
746
  // Create workflow plan if integrations are available
@@ -834,13 +841,37 @@ const value = data?.property?.nestedProperty`,
834
841
  }
835
842
  }
836
843
 
837
- // Add nextjs-dev delegation recommendation if available
838
- if (canDelegateNextjs) {
844
+ // Add augmented analysis suggestions when specialized MCPs are available
845
+ const canDelegateChrome = await canDelegateToChromeDevtools("profile_performance")
846
+
847
+ if (canDelegateNextjs || canDelegateChrome) {
839
848
  results.push("")
840
- results.push("🔗 **ENHANCED NEXT.JS ANALYSIS AVAILABLE**")
849
+ results.push("🔗 **AUGMENTED ANALYSIS AVAILABLE**")
841
850
  results.push("")
842
- const delegationResponse = await delegateToNextjs()
843
- results.push(delegationResponse.content[0].text)
851
+ results.push("dev3000 provided the core log analysis above. For deeper insights, consider also gathering:")
852
+ results.push("")
853
+
854
+ if (canDelegateNextjs) {
855
+ results.push("**Next.js Framework Analysis:**")
856
+ const dynamicNextjsSuggestions = await generateNextjsSuggestions(allErrors.join(" "))
857
+ dynamicNextjsSuggestions.slice(0, 3).forEach((suggestion) => {
858
+ results.push(`• \`dev3000-nextjs-dev:${suggestion.function}()\` - ${suggestion.reason}`)
859
+ })
860
+ results.push("")
861
+ }
862
+
863
+ if (canDelegateChrome) {
864
+ results.push("**Browser-Side Analysis:**")
865
+ const dynamicChromeSuggestions = await generateChromeDevtoolsSuggestions(allErrors.join(" "))
866
+ dynamicChromeSuggestions.slice(0, 3).forEach((suggestion) => {
867
+ results.push(`• \`dev3000-chrome-devtools:${suggestion.function}()\` - ${suggestion.reason}`)
868
+ })
869
+ results.push("")
870
+ }
871
+
872
+ results.push(
873
+ "💡 **Best approach:** Use dev3000's log analysis as your foundation, then gather specific additional data as needed for a complete picture."
874
+ )
844
875
  }
845
876
 
846
877
  return {
@@ -858,73 +889,377 @@ const value = data?.property?.nestedProperty`,
858
889
  }
859
890
  }
860
891
 
861
- // Capability mapping between dev3000 and chrome-devtools MCP
862
- const CHROME_DEVTOOLS_CAPABILITY_MAP: Record<
863
- string,
864
- { function: string; paramMap?: (params: Record<string, unknown>) => Record<string, unknown> }
865
- > = {
866
- screenshot: {
867
- function: "take_screenshot",
868
- paramMap: () => ({}) // chrome-devtools doesn't need params for screenshots
869
- },
870
- navigate: {
871
- function: "navigate_page",
872
- paramMap: (params) => ({ url: params.url })
873
- },
874
- click: {
875
- function: "click",
876
- paramMap: (params) => ({ x: params.x, y: params.y })
877
- },
878
- evaluate: {
879
- function: "execute_script", // Assuming chrome-devtools has this
880
- paramMap: (params) => ({ script: params.expression })
892
+ // Dynamic MCP capability discovery and filtering
893
+ interface McpCapability {
894
+ function: string
895
+ description?: string
896
+ parameters?: Record<string, unknown>
897
+ category: "advanced" | "basic"
898
+ reason: string
899
+ }
900
+
901
+ interface McpSchemaCache {
902
+ timestamp: number
903
+ capabilities: McpCapability[]
904
+ }
905
+
906
+ // Cache for discovered MCP capabilities (5 minute TTL)
907
+ const MCP_CAPABILITY_CACHE = new Map<string, McpSchemaCache>()
908
+ const CAPABILITY_CACHE_TTL = 5 * 60 * 1000 // 5 minutes
909
+
910
+ // Keywords that indicate advanced capabilities (vs basic automation)
911
+ const ADVANCED_CAPABILITY_KEYWORDS = {
912
+ chrome: [
913
+ "inspect",
914
+ "debug",
915
+ "profile",
916
+ "performance",
917
+ "console",
918
+ "devtools",
919
+ "breakpoint",
920
+ "intercept",
921
+ "storage",
922
+ "memory",
923
+ "trace"
924
+ ],
925
+ nextjs: ["build", "hydration", "ssr", "routing", "analyze", "debug", "render", "middleware", "optimization"]
926
+ }
927
+
928
+ // Basic capabilities that dev3000 handles well (should not suggest these)
929
+ const DEV3000_BASIC_CAPABILITIES = [
930
+ "screenshot",
931
+ "navigate",
932
+ "click",
933
+ "type",
934
+ "scroll",
935
+ "evaluate",
936
+ "simple_script",
937
+ "get_logs",
938
+ "basic_build_status",
939
+ "simple_error_check"
940
+ ]
941
+
942
+ /**
943
+ * Dynamically discover MCP capabilities by introspecting their schemas
944
+ */
945
+ async function discoverMcpCapabilities(mcpName: string): Promise<McpCapability[]> {
946
+ const cacheKey = mcpName
947
+ const cached = MCP_CAPABILITY_CACHE.get(cacheKey)
948
+
949
+ // Return cached capabilities if still fresh
950
+ if (cached && Date.now() - cached.timestamp < CAPABILITY_CACHE_TTL) {
951
+ logToDevFile(
952
+ `Capability Discovery: Using cached capabilities for ${mcpName} (${cached.capabilities.length} functions)`
953
+ )
954
+ return cached.capabilities
955
+ }
956
+
957
+ logToDevFile(`Capability Discovery: Fetching fresh capabilities for ${mcpName}`)
958
+
959
+ try {
960
+ // Method 1: Try to get MCP schema via tools/list request (MCP protocol standard)
961
+ const capabilities = await introspectMcpTools(mcpName)
962
+
963
+ if (capabilities.length > 0) {
964
+ // Cache the results
965
+ MCP_CAPABILITY_CACHE.set(cacheKey, {
966
+ timestamp: Date.now(),
967
+ capabilities
968
+ })
969
+
970
+ logToDevFile(`Capability Discovery: Successfully discovered ${capabilities.length} capabilities for ${mcpName}`)
971
+ return capabilities
972
+ }
973
+
974
+ // Method 2: Fallback to checking available function names from logs/errors
975
+ const fallbackCapabilities = await inferCapabilitiesFromLogs(mcpName)
976
+
977
+ // Cache even fallback results to avoid repeated failures
978
+ MCP_CAPABILITY_CACHE.set(cacheKey, {
979
+ timestamp: Date.now(),
980
+ capabilities: fallbackCapabilities
981
+ })
982
+
983
+ logToDevFile(
984
+ `Capability Discovery: Using fallback inference for ${mcpName} (${fallbackCapabilities.length} functions)`
985
+ )
986
+ return fallbackCapabilities
987
+ } catch (error) {
988
+ logToDevFile(`Capability Discovery: Failed to discover capabilities for ${mcpName} - ${error}`)
989
+ return []
881
990
  }
882
- // scroll and type don't have direct chrome-devtools equivalents, fall back to dev3000
883
991
  }
884
992
 
885
- // Capability mapping for nextjs-dev MCP delegation
886
- const NEXTJS_DEV_CAPABILITY_MAP: Record<string, { function: string; reason: string }> = {
887
- get_build_status: {
888
- function: "get_build_status",
889
- reason: "Get comprehensive Next.js build information and status"
890
- },
891
- get_server_logs: {
892
- function: "get_server_logs",
893
- reason: "Access Next.js server-side logs and runtime information"
894
- },
895
- analyze_performance: {
896
- function: "analyze_performance",
897
- reason: "Get Next.js-specific performance metrics and optimization suggestions"
898
- },
899
- check_routes: {
900
- function: "check_routes",
901
- reason: "Validate Next.js routing configuration and detect issues"
993
+ /**
994
+ * Introspect MCP tools using the standard tools/list request
995
+ */
996
+ async function introspectMcpTools(mcpName: string): Promise<McpCapability[]> {
997
+ // For stdio MCPs, we can try to discover their capabilities by checking Claude's cache directory
998
+ // which often contains MCP schema information or error logs that reveal function names
999
+
1000
+ try {
1001
+ const cacheDir = `/Users/${process.env.USER}/Library/Caches/claude-cli-nodejs`
1002
+ const { readdirSync, existsSync, readFileSync } = await import("fs")
1003
+
1004
+ if (!existsSync(cacheDir)) return []
1005
+
1006
+ const cacheDirs = readdirSync(cacheDir)
1007
+ const projectDir = cacheDirs.find((dir) => dir.includes(process.cwd().replace(/\//g, "-")))
1008
+
1009
+ if (!projectDir) return []
1010
+
1011
+ const mcpLogDir = `${cacheDir}/${projectDir}/mcp-logs-${mcpName}`
1012
+ if (!existsSync(mcpLogDir)) return []
1013
+
1014
+ // Look for schema information in MCP logs
1015
+ const logFiles = readdirSync(mcpLogDir)
1016
+ const capabilities: McpCapability[] = []
1017
+
1018
+ for (const logFile of logFiles.slice(-5)) {
1019
+ // Check recent logs only
1020
+ try {
1021
+ const logPath = `${mcpLogDir}/${logFile}`
1022
+ const logContent = readFileSync(logPath, "utf8")
1023
+
1024
+ // Parse log content for function definitions, tool lists, or schema information
1025
+ const discoveredFunctions = extractFunctionsFromLog(logContent, mcpName)
1026
+ capabilities.push(...discoveredFunctions)
1027
+ } catch (_error) {
1028
+ // Skip files that can't be read
1029
+ }
1030
+ }
1031
+
1032
+ return deduplicateCapabilities(capabilities)
1033
+ } catch (error) {
1034
+ logToDevFile(`MCP Introspection: Failed to introspect ${mcpName} - ${error}`)
1035
+ return []
902
1036
  }
903
1037
  }
904
1038
 
905
1039
  /**
906
- * Check if chrome-devtools MCP is available and can handle the requested action
1040
+ * Extract function names and descriptions from MCP log content
907
1041
  */
908
- async function canDelegateToChromeDevtools(action: string): Promise<boolean> {
909
- // First check if the action is mappable to chrome-devtools
910
- if (!CHROME_DEVTOOLS_CAPABILITY_MAP[action]) {
911
- return false
1042
+ function extractFunctionsFromLog(logContent: string, mcpName: string): McpCapability[] {
1043
+ const capabilities: McpCapability[] = []
1044
+ const mcpType: "chrome" | "nextjs" = mcpName.includes("chrome")
1045
+ ? "chrome"
1046
+ : mcpName.includes("nextjs")
1047
+ ? "nextjs"
1048
+ : "chrome" // default to chrome if unknown
1049
+ const advancedKeywords = ADVANCED_CAPABILITY_KEYWORDS[mcpType]
1050
+
1051
+ // Look for function definitions in various formats
1052
+ const patterns = [
1053
+ // JSON-RPC method calls: {"method": "tools/list", "result": {"tools": [{"name": "function_name", "description": "..."}]}}
1054
+ /"name":\s*"([^"]+)"/g,
1055
+ // Function call patterns: functionName(params)
1056
+ /(\w+)\s*\([^)]*\)/g,
1057
+ // Tool definition patterns: tool: function_name
1058
+ /tool:\s*(\w+)/g,
1059
+ // Error messages that reveal function names: "Unknown function: function_name"
1060
+ /unknown function[:\s]+(\w+)/gi,
1061
+ // Function export patterns: exports.function_name
1062
+ /exports\.(\w+)/g
1063
+ ]
1064
+
1065
+ for (const pattern of patterns) {
1066
+ let match: RegExpExecArray | null = pattern.exec(logContent)
1067
+ while (match !== null) {
1068
+ const functionName = match[1]
1069
+
1070
+ // Skip if this is a basic capability that dev3000 handles
1071
+ if (DEV3000_BASIC_CAPABILITIES.some((basic) => functionName.toLowerCase().includes(basic))) {
1072
+ match = pattern.exec(logContent)
1073
+ continue
1074
+ }
1075
+
1076
+ // Determine if this is an advanced capability
1077
+ const isAdvanced = advancedKeywords.some((keyword) => functionName.toLowerCase().includes(keyword))
1078
+
1079
+ // Generate reason based on function name and MCP type
1080
+ const reason = generateCapabilityReason(functionName, mcpType, isAdvanced)
1081
+
1082
+ capabilities.push({
1083
+ function: functionName,
1084
+ description: undefined, // Will be filled from actual description if available
1085
+ category: isAdvanced ? "advanced" : "basic",
1086
+ reason
1087
+ })
1088
+
1089
+ match = pattern.exec(logContent)
1090
+ }
1091
+ }
1092
+
1093
+ return capabilities
1094
+ }
1095
+
1096
+ /**
1097
+ * Generate intelligent reason text for a discovered capability
1098
+ */
1099
+ function generateCapabilityReason(functionName: string, mcpType: string, isAdvanced: boolean): string {
1100
+ const name = functionName.toLowerCase()
1101
+
1102
+ // Chrome DevTools specific reasons
1103
+ if (mcpType === "chrome") {
1104
+ if (name.includes("inspect")) return "Deep DOM inspection with DevTools-level detail"
1105
+ if (name.includes("console")) return "Direct browser console access and manipulation"
1106
+ if (name.includes("debug") || name.includes("breakpoint"))
1107
+ return "JavaScript debugging with breakpoints and call stack"
1108
+ if (name.includes("profile") || name.includes("performance")) return "Advanced performance profiling and analysis"
1109
+ if (name.includes("network") || name.includes("request")) return "Network request interception and analysis"
1110
+ if (name.includes("storage")) return "Browser storage manipulation (cookies, localStorage, etc.)"
1111
+ if (name.includes("trace") || name.includes("memory")) return "Memory usage and execution tracing"
1112
+ }
1113
+
1114
+ // Next.js specific reasons
1115
+ if (mcpType === "nextjs") {
1116
+ if (name.includes("build")) return "Advanced Next.js build system analysis"
1117
+ if (name.includes("hydration")) return "Client-server hydration debugging and analysis"
1118
+ if (name.includes("ssr") || name.includes("render")) return "Server-side rendering debugging"
1119
+ if (name.includes("route") || name.includes("routing")) return "Next.js routing system inspection and debugging"
1120
+ if (name.includes("middleware")) return "Next.js middleware analysis and debugging"
1121
+ if (name.includes("optimization") || name.includes("performance"))
1122
+ return "Next.js-specific performance optimization"
1123
+ }
1124
+
1125
+ // Generic advanced vs basic
1126
+ if (isAdvanced) {
1127
+ return `Advanced ${mcpType} capability beyond dev3000's basic automation`
1128
+ }
1129
+
1130
+ return `${mcpType} capability for specialized analysis`
1131
+ }
1132
+
1133
+ /**
1134
+ * Infer capabilities from error patterns and log analysis when direct introspection fails
1135
+ */
1136
+ async function inferCapabilitiesFromLogs(mcpName: string): Promise<McpCapability[]> {
1137
+ // This is a fallback when we can't directly introspect the MCP
1138
+ // We'll return commonly expected capabilities based on the MCP type
1139
+
1140
+ const mcpType = mcpName.includes("chrome") ? "chrome" : mcpName.includes("nextjs") ? "nextjs" : "unknown"
1141
+ const capabilities: McpCapability[] = []
1142
+
1143
+ if (mcpType === "chrome") {
1144
+ // Common chrome-devtools capabilities that are likely to exist
1145
+ const commonChromeFunctions = [
1146
+ "inspect_element",
1147
+ "access_console",
1148
+ "start_performance_profile",
1149
+ "intercept_requests",
1150
+ "set_breakpoint",
1151
+ "take_screenshot",
1152
+ "get_dom_snapshot",
1153
+ "modify_storage",
1154
+ "execute_script"
1155
+ ]
1156
+
1157
+ for (const func of commonChromeFunctions) {
1158
+ capabilities.push({
1159
+ function: func,
1160
+ category: DEV3000_BASIC_CAPABILITIES.includes(func) ? "basic" : "advanced",
1161
+ reason: generateCapabilityReason(func, mcpType, true)
1162
+ })
1163
+ }
1164
+ }
1165
+
1166
+ if (mcpType === "nextjs") {
1167
+ // Common nextjs-dev capabilities that are likely to exist
1168
+ const commonNextjsFunctions = [
1169
+ "analyze_build_process",
1170
+ "debug_server_rendering",
1171
+ "debug_hydration",
1172
+ "inspect_routing",
1173
+ "analyze_next_performance",
1174
+ "get_build_info",
1175
+ "check_build_status",
1176
+ "get_server_logs"
1177
+ ]
1178
+
1179
+ for (const func of commonNextjsFunctions) {
1180
+ capabilities.push({
1181
+ function: func,
1182
+ category: DEV3000_BASIC_CAPABILITIES.includes(func) ? "basic" : "advanced",
1183
+ reason: generateCapabilityReason(func, mcpType, true)
1184
+ })
1185
+ }
1186
+ }
1187
+
1188
+ logToDevFile(`Capability Inference: Generated ${capabilities.length} inferred capabilities for ${mcpName}`)
1189
+ return capabilities
1190
+ }
1191
+
1192
+ /**
1193
+ * Remove duplicate capabilities while preserving the most detailed ones
1194
+ */
1195
+ function deduplicateCapabilities(capabilities: McpCapability[]): McpCapability[] {
1196
+ const seen = new Map<string, McpCapability>()
1197
+
1198
+ for (const capability of capabilities) {
1199
+ const existing = seen.get(capability.function)
1200
+
1201
+ // Keep the one with more information (description, better reason, etc.)
1202
+ if (
1203
+ !existing ||
1204
+ (capability.description && !existing.description) ||
1205
+ capability.reason.length > existing.reason.length
1206
+ ) {
1207
+ seen.set(capability.function, capability)
1208
+ }
912
1209
  }
913
1210
 
914
- // dev3000 cannot reliably detect its own configured MCPs in Claude Code
915
- // Return false to disable auto-delegation - users can manually use the MCPs
916
- logToDevFile(`Chrome DevTools delegation disabled - cannot verify dev3000-chrome-devtools MCP configuration`)
917
- return false
1211
+ return Array.from(seen.values())
1212
+ }
1213
+
1214
+ /**
1215
+ * Check if chrome-devtools MCP is available and get its capabilities
1216
+ */
1217
+ async function canDelegateToChromeDevtools(action?: string): Promise<boolean> {
1218
+ try {
1219
+ // Check if MCP is available
1220
+ const availableMcps = await discoverAvailableMcps()
1221
+ if (!availableMcps.includes("dev3000-chrome-devtools")) {
1222
+ return false
1223
+ }
1224
+
1225
+ // If no specific action, just return availability
1226
+ if (!action) return true
1227
+
1228
+ // Get dynamic capabilities
1229
+ const capabilities = await discoverMcpCapabilities("dev3000-chrome-devtools")
1230
+
1231
+ // Check if the MCP has relevant capabilities for the action
1232
+ const hasRelevantCapability = capabilities.some(
1233
+ (cap) => cap.function.toLowerCase().includes(action.toLowerCase()) || cap.category === "advanced" // Any advanced capability indicates delegation worthiness
1234
+ )
1235
+
1236
+ return hasRelevantCapability
1237
+ } catch (error) {
1238
+ logToDevFile(`Chrome DevTools delegation check failed: ${error}`)
1239
+ return false
1240
+ }
918
1241
  }
919
1242
 
920
1243
  /**
921
- * Check if nextjs-dev MCP is available
1244
+ * Check if nextjs-dev MCP is available and get its capabilities
922
1245
  */
923
1246
  async function canDelegateToNextjs(): Promise<boolean> {
924
- // dev3000 cannot reliably detect its own configured MCPs in Claude Code
925
- // Return false to disable auto-delegation - users can manually use the MCPs
926
- logToDevFile(`NextJS delegation disabled - cannot verify dev3000-nextjs-dev MCP configuration`)
927
- return false
1247
+ try {
1248
+ // Check if MCP is available
1249
+ const availableMcps = await discoverAvailableMcps()
1250
+ if (!availableMcps.includes("dev3000-nextjs-dev")) {
1251
+ return false
1252
+ }
1253
+
1254
+ // Get dynamic capabilities to verify it has useful functions
1255
+ const capabilities = await discoverMcpCapabilities("dev3000-nextjs-dev")
1256
+
1257
+ // Return true if we found any advanced Next.js capabilities
1258
+ return capabilities.some((cap) => cap.category === "advanced")
1259
+ } catch (error) {
1260
+ logToDevFile(`NextJS delegation check failed: ${error}`)
1261
+ return false
1262
+ }
928
1263
  }
929
1264
 
930
1265
  /**
@@ -934,32 +1269,39 @@ async function delegateToChromeDevtools(
934
1269
  action: string,
935
1270
  params: Record<string, unknown>
936
1271
  ): Promise<{ content: Array<{ type: "text"; text: string }> }> {
937
- const mapping = CHROME_DEVTOOLS_CAPABILITY_MAP[action]
938
- if (!mapping) {
1272
+ // Get dynamic capabilities from chrome-devtools MCP
1273
+ const capabilities = await discoverMcpCapabilities("dev3000-chrome-devtools")
1274
+
1275
+ // Find a relevant capability for this action
1276
+ const relevantCap = capabilities.find(
1277
+ (cap) =>
1278
+ cap.function.toLowerCase().includes(action.toLowerCase()) ||
1279
+ cap.description?.toLowerCase().includes(action.toLowerCase())
1280
+ )
1281
+
1282
+ if (!relevantCap) {
939
1283
  throw new Error(`Action ${action} cannot be delegated to chrome-devtools`)
940
1284
  }
941
1285
 
942
- // Transform parameters if needed
943
- const chromeParams = mapping.paramMap ? mapping.paramMap(params) : params
944
-
945
1286
  return {
946
1287
  content: [
947
1288
  {
948
1289
  type: "text",
949
- text: `🔗 **USE DEV3000-CHROME-DEVTOOLS MCP**
1290
+ text: `🔗 **ADVANCED BROWSER DEBUGGING AVAILABLE**
950
1291
 
951
- If you have chrome-devtools MCP configured, please use the \`dev3000-chrome-devtools\` MCP directly:
1292
+ For advanced debugging capabilities, use the \`dev3000-chrome-devtools\` MCP:
952
1293
 
953
1294
  \`\`\`
954
- dev3000-chrome-devtools:${mapping.function}(${JSON.stringify(chromeParams, null, 2)})
1295
+ dev3000-chrome-devtools:${relevantCap.function}(${JSON.stringify(params, null, 2)})
955
1296
  \`\`\`
956
1297
 
957
- 💡 **If the MCP is not available:**
958
- • Make sure chrome-devtools MCP is configured in your Claude Code client
959
- • Claude Code should auto-configure it as \`dev3000-chrome-devtools\`
960
- • Alternatively, dev3000 will fallback to its basic browser automation
1298
+ 🎯 **Why use chrome-devtools for this:** ${relevantCap.reason}
961
1299
 
962
- **Note:** dev3000 detected chrome-devtools activity but cannot verify MCP configuration`
1300
+ 💡 **When to use each tool:**
1301
+ • **dev3000**: Basic browser automation (screenshots, navigation, clicks, simple scripts)
1302
+ • **dev3000-chrome-devtools**: Advanced debugging (DOM inspection, breakpoints, performance profiling, network interception)
1303
+
1304
+ ⚡ **Both tools share the same Chrome instance** - no conflicts or duplicate browsers`
963
1305
  }
964
1306
  ]
965
1307
  }
@@ -968,28 +1310,30 @@ dev3000-chrome-devtools:${mapping.function}(${JSON.stringify(chromeParams, null,
968
1310
  /**
969
1311
  * Delegate to nextjs-dev MCP with suggested functions
970
1312
  */
971
- async function delegateToNextjs(): Promise<{ content: Array<{ type: "text"; text: string }> }> {
972
- const availableFunctions = Object.entries(NEXTJS_DEV_CAPABILITY_MAP)
973
- .map(([_key, { function: func, reason }]) => `• \`dev3000-nextjs-dev:${func}()\` - ${reason}`)
1313
+ async function _delegateToNextjs(): Promise<{ content: Array<{ type: "text"; text: string }> }> {
1314
+ // Get dynamic capabilities from nextjs-dev MCP
1315
+ const capabilities = await discoverMcpCapabilities("dev3000-nextjs-dev")
1316
+
1317
+ const availableFunctions = capabilities
1318
+ .map((cap) => `• \`dev3000-nextjs-dev:${cap.function}()\` - ${cap.reason}`)
974
1319
  .join("\n")
975
1320
 
976
1321
  return {
977
1322
  content: [
978
1323
  {
979
1324
  type: "text",
980
- text: `🔗 **USE DEV3000-NEXTJS-DEV MCP**
1325
+ text: `🔗 **ADVANCED NEXT.JS ANALYSIS AVAILABLE**
981
1326
 
982
- Please use the \`dev3000-nextjs-dev\` MCP directly for Next.js-specific analysis:
1327
+ For Next.js-specific advanced analysis, use the \`dev3000-nextjs-dev\` MCP:
983
1328
 
984
- **Available Functions:**
1329
+ **Available Advanced Functions:**
985
1330
  ${availableFunctions}
986
1331
 
987
- 💡 **Why this approach:**
988
- nextjs-dev is a stdio MCP server that Claude calls directly
989
- Provides Next.js-specific build, server, and performance insights
990
- • Direct MCP calls give better framework-specific context
1332
+ 💡 **When to use each tool:**
1333
+ **dev3000**: General log analysis, basic error detection, simple build monitoring
1334
+ **dev3000-nextjs-dev**: Advanced Next.js debugging (SSR issues, hydration problems, build system analysis, routing inspection)
991
1335
 
992
- ⚡ **Auto-configured as:** \`dev3000-nextjs-dev\` in your MCP client`
1336
+ ⚡ **Best of both worlds:** Use dev3000 for general monitoring and nextjs-dev for framework-specific deep dives`
993
1337
  }
994
1338
  ]
995
1339
  }
@@ -1244,11 +1588,46 @@ export async function executeBrowserAction({
1244
1588
  ws.on("error", reject)
1245
1589
  })
1246
1590
 
1591
+ // Build success message with augmented suggestions
1592
+ let successMessage = `Browser action '${action}' executed successfully. Result: ${JSON.stringify(result, null, 2)}`
1593
+
1594
+ // Add augmented suggestions for enhanced capabilities
1595
+ const canDelegateChrome = await canDelegateToChromeDevtools("inspect_element")
1596
+ if (canDelegateChrome) {
1597
+ successMessage += "\n\n🔗 **ENHANCED BROWSER ANALYSIS AVAILABLE**"
1598
+ successMessage +=
1599
+ "\n\ndev3000 completed the basic browser action above. For deeper browser insights, consider also:"
1600
+
1601
+ // Generate dynamic suggestions based on the action and available capabilities
1602
+ const dynamicSuggestions = await generateChromeDevtoolsSuggestions(action)
1603
+ const actionRelevantSuggestions = dynamicSuggestions.filter((suggestion) => {
1604
+ const funcName = suggestion.function.toLowerCase()
1605
+ const actionName = action.toLowerCase()
1606
+
1607
+ // Match suggestions to specific actions
1608
+ if (actionName === "screenshot" && (funcName.includes("inspect") || funcName.includes("performance")))
1609
+ return true
1610
+ if (actionName === "evaluate" && (funcName.includes("console") || funcName.includes("inspect"))) return true
1611
+ if (actionName === "navigate" && (funcName.includes("network") || funcName.includes("performance"))) return true
1612
+ if (actionName === "click" && (funcName.includes("console") || funcName.includes("inspect"))) return true
1613
+
1614
+ // Include high-priority suggestions regardless
1615
+ return suggestion.priority === "high"
1616
+ })
1617
+
1618
+ actionRelevantSuggestions.slice(0, 2).forEach((suggestion) => {
1619
+ successMessage += `\n• \`dev3000-chrome-devtools:${suggestion.function}()\` - ${suggestion.reason}`
1620
+ })
1621
+
1622
+ successMessage +=
1623
+ "\n\n💡 **Augmented approach:** Use dev3000 for basic automation, chrome-devtools for detailed analysis and debugging."
1624
+ }
1625
+
1247
1626
  return {
1248
1627
  content: [
1249
1628
  {
1250
1629
  type: "text",
1251
- text: `Browser action '${action}' executed successfully. Result: ${JSON.stringify(result, null, 2)}`
1630
+ text: successMessage
1252
1631
  }
1253
1632
  ]
1254
1633
  }
@@ -1402,9 +1781,47 @@ export async function discoverAvailableMcps(projectName?: string): Promise<strin
1402
1781
  discoveredMcps.add(mcp)
1403
1782
  }
1404
1783
 
1405
- // Method 2: Port pinging (only if process detection found nothing)
1784
+ // Method 2: Check for dev3000-configured MCPs by testing their functionality
1785
+ try {
1786
+ // Test if dev3000-chrome-devtools MCP is working by checking Claude logs
1787
+ const cacheDir = `/Users/${process.env.USER}/Library/Caches/claude-cli-nodejs`
1788
+ const { readdirSync, existsSync } = await import("fs")
1789
+
1790
+ if (existsSync(cacheDir)) {
1791
+ const cacheDirs = readdirSync(cacheDir)
1792
+ const projectDir = cacheDirs.find((dir) => dir.includes(process.cwd().replace(/\//g, "-")))
1793
+
1794
+ if (projectDir) {
1795
+ const projectCacheDir = `${cacheDir}/${projectDir}`
1796
+
1797
+ // Check for chrome-devtools MCP logs
1798
+ const chromeDevtoolsLogDir = `${projectCacheDir}/mcp-logs-dev3000-chrome-devtools`
1799
+ if (existsSync(chromeDevtoolsLogDir)) {
1800
+ const chromeDevtoolsLogs = readdirSync(chromeDevtoolsLogDir)
1801
+ if (chromeDevtoolsLogs.length > 0) {
1802
+ discoveredMcps.add("dev3000-chrome-devtools")
1803
+ logToDevFile("MCP Discovery: Found dev3000-chrome-devtools via Claude cache logs", projectName)
1804
+ }
1805
+ }
1806
+
1807
+ // Check for nextjs-dev MCP logs
1808
+ const nextjsDevLogDir = `${projectCacheDir}/mcp-logs-dev3000-nextjs-dev`
1809
+ if (existsSync(nextjsDevLogDir)) {
1810
+ const nextjsDevLogs = readdirSync(nextjsDevLogDir)
1811
+ if (nextjsDevLogs.length > 0) {
1812
+ discoveredMcps.add("dev3000-nextjs-dev")
1813
+ logToDevFile("MCP Discovery: Found dev3000-nextjs-dev via Claude cache logs", projectName)
1814
+ }
1815
+ }
1816
+ }
1817
+ }
1818
+ } catch (_error) {
1819
+ logToDevFile("MCP Discovery: Claude cache check failed, falling back to port detection", projectName)
1820
+ }
1821
+
1822
+ // Method 3: Port pinging (fallback)
1406
1823
  if (discoveredMcps.size === 0) {
1407
- logToDevFile("MCP Discovery: No MCPs found via process detection, trying port pinging", projectName)
1824
+ logToDevFile("MCP Discovery: No MCPs found via process or cache detection, trying port pinging", projectName)
1408
1825
  const portDetected = await pingMcpPorts()
1409
1826
  for (const mcp of portDetected) {
1410
1827
  discoveredMcps.add(mcp)
@@ -1422,6 +1839,140 @@ export async function discoverAvailableMcps(projectName?: string): Promise<strin
1422
1839
  return finalMcps
1423
1840
  }
1424
1841
 
1842
+ /**
1843
+ * Get and display MCP capabilities for debugging and inspection
1844
+ */
1845
+ export async function getMcpCapabilities({
1846
+ mcpName
1847
+ }: GetMcpCapabilitiesParams = {}): Promise<{ content: Array<{ type: "text"; text: string }> }> {
1848
+ const results: string[] = []
1849
+
1850
+ results.push("🔍 **MCP CAPABILITY INSPECTOR**")
1851
+ results.push("")
1852
+
1853
+ try {
1854
+ // Discover available MCPs if no specific one requested
1855
+ const availableMcps = await discoverAvailableMcps()
1856
+
1857
+ if (availableMcps.length === 0) {
1858
+ results.push("❌ **NO MCPs DETECTED**")
1859
+ results.push("No dev3000-chrome-devtools or dev3000-nextjs-dev MCPs found.")
1860
+ results.push("")
1861
+ results.push("💡 **To enable enhanced capabilities:**")
1862
+ results.push("• Ensure Chrome DevTools MCP is configured: `dev3000-chrome-devtools`")
1863
+ results.push("• Ensure Next.js Dev MCP is configured: `dev3000-nextjs-dev`")
1864
+ results.push("• Check that Claude Code has MCPs properly configured")
1865
+
1866
+ return {
1867
+ content: [{ type: "text", text: results.join("\n") }]
1868
+ }
1869
+ }
1870
+
1871
+ results.push(`✅ **DISCOVERED MCPs:** ${availableMcps.join(", ")}`)
1872
+ results.push("")
1873
+
1874
+ // Filter to specific MCP if requested
1875
+ const mcpsToInspect = mcpName ? availableMcps.filter((name) => name.includes(mcpName)) : availableMcps
1876
+
1877
+ if (mcpsToInspect.length === 0 && mcpName) {
1878
+ results.push(`❌ **MCP NOT FOUND:** ${mcpName}`)
1879
+ results.push(`Available MCPs: ${availableMcps.join(", ")}`)
1880
+
1881
+ return {
1882
+ content: [{ type: "text", text: results.join("\n") }]
1883
+ }
1884
+ }
1885
+
1886
+ // Inspect capabilities for each MCP
1887
+ for (const mcp of mcpsToInspect) {
1888
+ results.push(`📋 **${mcp.toUpperCase()} CAPABILITIES:**`)
1889
+ results.push("")
1890
+
1891
+ const capabilities = await discoverMcpCapabilities(mcp)
1892
+
1893
+ if (capabilities.length === 0) {
1894
+ results.push(" ❌ No capabilities discovered")
1895
+ results.push(" 💡 This might indicate the MCP is not properly configured or accessible")
1896
+ results.push("")
1897
+ continue
1898
+ }
1899
+
1900
+ // Group by category
1901
+ const advanced = capabilities.filter((cap) => cap.category === "advanced")
1902
+ const basic = capabilities.filter((cap) => cap.category === "basic")
1903
+
1904
+ results.push(` 🚀 **ADVANCED CAPABILITIES** (${advanced.length} functions):`)
1905
+ if (advanced.length > 0) {
1906
+ advanced.forEach((cap) => {
1907
+ results.push(` • \`${cap.function}()\` - ${cap.reason}`)
1908
+ })
1909
+ } else {
1910
+ results.push(" No advanced capabilities discovered")
1911
+ }
1912
+ results.push("")
1913
+
1914
+ results.push(` ⚙️ **BASIC CAPABILITIES** (${basic.length} functions):`)
1915
+ if (basic.length > 0) {
1916
+ basic.forEach((cap) => {
1917
+ results.push(` • \`${cap.function}()\` - ${cap.reason}`)
1918
+ })
1919
+ } else {
1920
+ results.push(" No basic capabilities discovered")
1921
+ }
1922
+ results.push("")
1923
+
1924
+ // Cache info
1925
+ const cached = MCP_CAPABILITY_CACHE.get(mcp)
1926
+ if (cached) {
1927
+ const age = Date.now() - cached.timestamp
1928
+ const ageMinutes = Math.floor(age / 60000)
1929
+ results.push(` 📝 **CACHE INFO:** Discovered ${ageMinutes} minutes ago`)
1930
+ if (age > CAPABILITY_CACHE_TTL * 0.8) {
1931
+ results.push(" ⚠️ Cache will refresh soon on next use")
1932
+ }
1933
+ }
1934
+ results.push("")
1935
+ }
1936
+
1937
+ // Summary
1938
+ const totalCapabilities = mcpsToInspect.reduce(async (accPromise, mcp) => {
1939
+ const acc = await accPromise
1940
+ const caps = await discoverMcpCapabilities(mcp)
1941
+ return acc + caps.length
1942
+ }, Promise.resolve(0))
1943
+
1944
+ results.push("🎯 **AUGMENTED DELEGATION STATUS:**")
1945
+ results.push(`• Total discovered capabilities: ${await totalCapabilities}`)
1946
+ results.push(
1947
+ `• MCPs with advanced capabilities: ${
1948
+ mcpsToInspect.filter(async (mcp) => {
1949
+ const caps = await discoverMcpCapabilities(mcp)
1950
+ return caps.some((cap) => cap.category === "advanced")
1951
+ }).length
1952
+ }`
1953
+ )
1954
+ results.push("• Dynamic discovery: ✅ Active (updates automatically)")
1955
+ results.push("• Cache TTL: 5 minutes")
1956
+ results.push("")
1957
+ results.push("💡 **These capabilities are automatically suggested in dev3000's enhanced responses!**")
1958
+
1959
+ return {
1960
+ content: [{ type: "text", text: results.join("\n") }]
1961
+ }
1962
+ } catch (error) {
1963
+ results.push(`❌ **ERROR INSPECTING CAPABILITIES:** ${error instanceof Error ? error.message : String(error)}`)
1964
+ results.push("")
1965
+ results.push("💡 **Troubleshooting:**")
1966
+ results.push("• Check that MCPs are properly configured in Claude Code")
1967
+ results.push("• Verify dev3000 can access Claude cache directories")
1968
+ results.push("• Try running `discover_available_mcps()` first")
1969
+
1970
+ return {
1971
+ content: [{ type: "text", text: results.join("\n") }]
1972
+ }
1973
+ }
1974
+ }
1975
+
1425
1976
  /**
1426
1977
  * Log MCP-related events to the project-specific D3K log file (NOT main project log)
1427
1978
  * This prevents Claude from seeing dev3000's orchestration logs as application errors
@@ -1524,85 +2075,119 @@ export function calculateEstimatedTime(errorCount: number, hasIntegrations: bool
1524
2075
  }
1525
2076
 
1526
2077
  /**
1527
- * Generate Next.js specific MCP function suggestions
2078
+ * Generate dynamic Next.js specific MCP function suggestions based on discovered capabilities
1528
2079
  */
1529
- export function generateNextjsSuggestions(errorContext?: string): McpFunctionSuggestion[] {
1530
- const suggestions: McpFunctionSuggestion[] = [
1531
- {
1532
- function: "check_errors",
1533
- reason: "Analyze Next.js build and runtime errors with framework-specific context",
1534
- priority: "high"
1535
- },
1536
- {
1537
- function: "get_logs",
1538
- params: { type: "error", limit: 20 },
1539
- reason: "Retrieve detailed Next.js server logs to correlate with dev3000 findings",
1540
- priority: "high"
1541
- }
1542
- ]
2080
+ export async function generateNextjsSuggestions(errorContext?: string): Promise<McpFunctionSuggestion[]> {
2081
+ try {
2082
+ // Get dynamic capabilities from the MCP
2083
+ const capabilities = await discoverMcpCapabilities("dev3000-nextjs-dev")
2084
+
2085
+ // Filter for advanced capabilities and create suggestions
2086
+ const suggestions: McpFunctionSuggestion[] = capabilities
2087
+ .filter((cap) => cap.category === "advanced")
2088
+ .slice(0, 8) // Limit to most relevant suggestions
2089
+ .map((cap) => ({
2090
+ function: cap.function,
2091
+ reason: cap.reason,
2092
+ priority: determinePriority(cap.function, errorContext) as "high" | "medium" | "low"
2093
+ }))
2094
+
2095
+ logToDevFile(
2096
+ `Dynamic Suggestions: Generated ${suggestions.length} Next.js suggestions from ${capabilities.length} discovered capabilities`
2097
+ )
1543
2098
 
1544
- // Add context-specific suggestions
1545
- if (errorContext?.includes("hydration")) {
1546
- suggestions.push({
1547
- function: "check_hydration_errors",
1548
- reason: "Specific hydration mismatch analysis detected in error context",
1549
- priority: "high"
1550
- })
1551
- }
2099
+ return suggestions
2100
+ } catch (error) {
2101
+ logToDevFile(`Dynamic Suggestions: Failed to generate Next.js suggestions - ${error}`)
1552
2102
 
1553
- if (errorContext?.includes("build") || errorContext?.includes("compile")) {
1554
- suggestions.push({
1555
- function: "get_build_info",
1556
- reason: "Build-related errors detected, get detailed compilation information",
1557
- priority: "high"
1558
- })
2103
+ // Fallback to basic suggestions if discovery fails
2104
+ return [
2105
+ {
2106
+ function: "analyze_build_process",
2107
+ reason: "Advanced Next.js build system analysis",
2108
+ priority: "high"
2109
+ },
2110
+ {
2111
+ function: "debug_server_rendering",
2112
+ reason: "Server-side rendering debugging",
2113
+ priority: "high"
2114
+ }
2115
+ ]
1559
2116
  }
2117
+ }
1560
2118
 
1561
- return suggestions
2119
+ /**
2120
+ * Generate dynamic Chrome DevTools specific MCP function suggestions based on discovered capabilities
2121
+ */
2122
+ export async function generateChromeDevtoolsSuggestions(errorContext?: string): Promise<McpFunctionSuggestion[]> {
2123
+ try {
2124
+ // Get dynamic capabilities from the MCP
2125
+ const capabilities = await discoverMcpCapabilities("dev3000-chrome-devtools")
2126
+
2127
+ // Filter for advanced capabilities and create suggestions
2128
+ const suggestions: McpFunctionSuggestion[] = capabilities
2129
+ .filter((cap) => cap.category === "advanced")
2130
+ .slice(0, 8) // Limit to most relevant suggestions
2131
+ .map((cap) => ({
2132
+ function: cap.function,
2133
+ reason: cap.reason,
2134
+ priority: determinePriority(cap.function, errorContext) as "high" | "medium" | "low"
2135
+ }))
2136
+
2137
+ logToDevFile(
2138
+ `Dynamic Suggestions: Generated ${suggestions.length} Chrome DevTools suggestions from ${capabilities.length} discovered capabilities`
2139
+ )
2140
+
2141
+ return suggestions
2142
+ } catch (error) {
2143
+ logToDevFile(`Dynamic Suggestions: Failed to generate Chrome DevTools suggestions - ${error}`)
2144
+
2145
+ // Fallback to basic suggestions if discovery fails
2146
+ return [
2147
+ {
2148
+ function: "inspect_element",
2149
+ reason: "Deep DOM inspection with DevTools-level detail",
2150
+ priority: "high"
2151
+ },
2152
+ {
2153
+ function: "access_console",
2154
+ reason: "Direct browser console access and manipulation",
2155
+ priority: "high"
2156
+ }
2157
+ ]
2158
+ }
1562
2159
  }
1563
2160
 
1564
2161
  /**
1565
- * Generate Chrome DevTools specific MCP function suggestions
2162
+ * Determine priority of a capability based on error context and function relevance
1566
2163
  */
1567
- export function generateChromeDevtoolsSuggestions(errorContext?: string): McpFunctionSuggestion[] {
1568
- const suggestions: McpFunctionSuggestion[] = [
1569
- {
1570
- function: "list_console_messages",
1571
- params: { type: "error", limit: 20 },
1572
- reason: "Get detailed browser console errors to correlate with dev3000 interaction data",
1573
- priority: "high"
1574
- },
1575
- {
1576
- function: "list_network_requests",
1577
- params: { failed: true },
1578
- reason: "Analyze failed network requests that may be causing application errors",
1579
- priority: "medium"
1580
- },
1581
- {
1582
- function: "take_screenshot",
1583
- reason: "Capture current browser state for visual debugging",
1584
- priority: "low"
1585
- }
2164
+ function determinePriority(functionName: string, errorContext?: string): "high" | "medium" | "low" {
2165
+ const name = functionName.toLowerCase()
2166
+ const context = errorContext?.toLowerCase() || ""
2167
+
2168
+ // High priority matches - function directly relates to error context
2169
+ const highPriorityPatterns = [
2170
+ { pattern: /hydration/, keywords: ["hydration", "ssr", "render"] },
2171
+ { pattern: /build|compile/, keywords: ["build", "compile", "analyze"] },
2172
+ { pattern: /network|fetch|api/, keywords: ["network", "request", "intercept", "performance"] },
2173
+ { pattern: /console|error/, keywords: ["console", "error", "debug"] },
2174
+ { pattern: /click|interaction/, keywords: ["dom", "element", "inspect"] }
1586
2175
  ]
1587
2176
 
1588
- // Add context-specific suggestions
1589
- if (errorContext?.includes("network") || errorContext?.includes("fetch") || errorContext?.includes("api")) {
1590
- suggestions.push({
1591
- function: "get_performance_metrics",
1592
- reason: "Network-related errors detected, analyze performance and timing",
1593
- priority: "high"
1594
- })
2177
+ for (const { pattern, keywords } of highPriorityPatterns) {
2178
+ if (pattern.test(context) && keywords.some((keyword) => name.includes(keyword))) {
2179
+ return "high"
2180
+ }
1595
2181
  }
1596
2182
 
1597
- if (errorContext?.includes("click") || errorContext?.includes("interaction")) {
1598
- suggestions.push({
1599
- function: "get_dom_snapshot",
1600
- reason: "Interaction errors detected, capture DOM state for element analysis",
1601
- priority: "medium"
1602
- })
2183
+ // Medium priority - advanced debugging capabilities
2184
+ const mediumPriorityKeywords = ["debug", "profile", "analyze", "trace", "inspect"]
2185
+ if (mediumPriorityKeywords.some((keyword) => name.includes(keyword))) {
2186
+ return "medium"
1603
2187
  }
1604
2188
 
1605
- return suggestions
2189
+ // Low priority - basic or less critical functions
2190
+ return "low"
1606
2191
  }
1607
2192
 
1608
2193
  /**
@@ -1642,8 +2227,8 @@ export async function createIntegratedWorkflow({
1642
2227
  results.push("")
1643
2228
 
1644
2229
  // Generate MCP-specific suggestions
1645
- const nextjsSuggestions = integrateNextjs ? generateNextjsSuggestions(errorContext) : []
1646
- const chromeSuggestions = integrateChromeDevtools ? generateChromeDevtoolsSuggestions(errorContext) : []
2230
+ const nextjsSuggestions = integrateNextjs ? await generateNextjsSuggestions(errorContext) : []
2231
+ const chromeSuggestions = integrateChromeDevtools ? await generateChromeDevtoolsSuggestions(errorContext) : []
1647
2232
 
1648
2233
  if (!integrateNextjs && !integrateChromeDevtools) {
1649
2234
  results.push("⚠️ **NO INTEGRATIONS DETECTED**")