feat: CI/CD pipeline setup complete - Ansible playbooks updated, secrets configured, workflow ready
This commit is contained in:
@@ -21,23 +21,38 @@ final readonly class McpServerCommand
|
||||
#[ConsoleCommand(name: 'mcp:server', description: 'Start MCP (Model Context Protocol) server for STDIO communication')]
|
||||
public function execute(ConsoleInput $input, ConsoleOutput $output): ExitCode
|
||||
{
|
||||
// Disable all output buffering and debug output for clean JSON-RPC
|
||||
\App\Framework\OutputBuffer\OutputBuffer::cleanAll();
|
||||
// CRITICAL: Disable ALL output before container initialization
|
||||
// This prevents Discovery debug output and ANSI codes
|
||||
|
||||
// Disable terminal control sequences
|
||||
// 1. Clean all output buffers
|
||||
while (ob_get_level() > 0) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
// 2. Disable terminal control sequences
|
||||
putenv('TERM=dumb');
|
||||
putenv('NO_COLOR=1');
|
||||
|
||||
// Redirect all further output to STDERR except our JSON responses
|
||||
ini_set('log_errors', '1');
|
||||
ini_set('error_log', 'php://stderr');
|
||||
// 3. Suppress ALL stdout/stderr except our JSON-RPC
|
||||
$GLOBALS['MCP_SERVER_MODE'] = true; // Signal to framework
|
||||
|
||||
// Log to STDERR so it doesn't interfere with JSON-RPC on STDOUT
|
||||
error_log('Starting MCP Server...');
|
||||
// 4. Redirect errors to null during initialization
|
||||
$oldErrorLog = ini_get('error_log');
|
||||
ini_set('error_log', '/dev/null');
|
||||
ini_set('display_errors', '0');
|
||||
ini_set('display_startup_errors', '0');
|
||||
|
||||
// 5. Start fresh output buffer for clean JSON-RPC
|
||||
ob_start();
|
||||
|
||||
try {
|
||||
$mcpServer = $this->container->get(McpServer::class);
|
||||
|
||||
error_log('MCP Server ready. Listening for JSON-RPC requests on STDIN.');
|
||||
// Discard any buffered output from initialization
|
||||
ob_end_clean();
|
||||
|
||||
// Re-enable error logging to stderr for runtime errors
|
||||
ini_set('error_log', 'php://stderr');
|
||||
|
||||
// Read from STDIN and process requests
|
||||
while (($line = fgets(STDIN)) !== false) {
|
||||
|
||||
Reference in New Issue
Block a user