bootstrapConsole(); // Get container via reflection $reflection = new ReflectionClass($consoleApp); $containerProperty = $reflection->getProperty('container'); $containerProperty->setAccessible(true); $container = $containerProperty->getValue($consoleApp); if (! $container->has(DiscoveryRegistry::class)) { echo '❌ DiscoveryRegistry nicht im Container gefunden!' . PHP_EOL; exit(1); } $registry = $container->get(DiscoveryRegistry::class); // Check for ConsoleCommand attributes with different variations $possibleKeys = [ 'App\Framework\Console\ConsoleCommand', 'ConsoleCommand', 'App\\Framework\\Console\\ConsoleCommand', ]; echo "Available attribute classes:" . PHP_EOL; foreach ($registry->attributes->getAllTypes() as $attrClass) { echo " - $attrClass" . PHP_EOL; } echo PHP_EOL; $foundCommands = []; foreach ($possibleKeys as $key) { $commands = $registry->attributes->get($key) ?? []; if (! empty($commands)) { $foundCommands[$key] = $commands; echo "Found " . count($commands) . " commands with key '$key'" . PHP_EOL; } } // Check if MCP server command is found specifically $mcpServerFound = false; foreach ($foundCommands as $key => $commands) { foreach ($commands as $attr) { if ($attr instanceof App\Framework\Discovery\ValueObjects\DiscoveredAttribute) { if ($attr->className->getFullyQualified() === 'App\\Framework\\Mcp\\Console\\McpServerCommand') { $mcpServerFound = true; echo "✅ MCP Server command found!" . PHP_EOL; break 2; } } } } if (! $mcpServerFound) { echo "❌ MCP Server command NOT found!" . PHP_EOL; } if (empty($foundCommands)) { echo "❌ No console commands found with any key!" . PHP_EOL; // Try to find any attributes that might be console commands echo "Searching for any method-level attributes..." . PHP_EOL; foreach ($registry->attributes->getAllTypes() as $attrClass) { $attrs = $registry->attributes->get($attrClass); foreach ($attrs as $attr) { if ($attr instanceof App\Framework\Discovery\ValueObjects\DiscoveredAttribute && $attr->target === App\Framework\Discovery\ValueObjects\AttributeTarget::METHOD) { echo " Found method attribute: $attrClass on " . $attr->className->getFullyQualified() . "::" . ($attr->methodName?->toString() ?? 'unknown') . PHP_EOL; } } } } else { foreach ($foundCommands as $key => $commands) { echo PHP_EOL . "=== Commands found with key '$key' ===" . PHP_EOL; foreach ($commands as $i => $attr) { echo "Command #$i:" . PHP_EOL; if ($attr instanceof App\Framework\Discovery\ValueObjects\DiscoveredAttribute) { echo " Class: " . $attr->className->getFullyQualified() . PHP_EOL; echo " Method: " . ($attr->methodName?->toString() ?? 'null') . PHP_EOL; echo " Arguments: " . json_encode($attr->arguments) . PHP_EOL; echo " Additional Data: " . json_encode($attr->additionalData) . PHP_EOL; // Try to create the attribute instance $instance = $attr->createAttributeInstance(); if ($instance) { echo " Command Name: " . ($instance->name ?? 'N/A') . PHP_EOL; echo " Description: " . ($instance->description ?? 'N/A') . PHP_EOL; } } else { echo " Raw data: " . print_r($attr, true) . PHP_EOL; } echo PHP_EOL; } } } // Check if any commands are registered in the ConsoleApplication $commandsProperty = $reflection->getProperty('commands'); $commandsProperty->setAccessible(true); $registeredCommands = $commandsProperty->getValue($consoleApp); echo "Commands registered in ConsoleApplication: " . count($registeredCommands) . PHP_EOL; foreach ($registeredCommands as $name => $command) { echo " - $name: " . ($command['description'] ?? 'No description') . PHP_EOL; } } catch (Exception $e) { echo '❌ Error: ' . $e->getMessage() . PHP_EOL; echo 'Trace: ' . $e->getTraceAsString() . PHP_EOL; }