diff --git a/dotnet/src/dotnetcore/GxNetCoreStartup/RunUtils.cs b/dotnet/src/dotnetcore/GxNetCoreStartup/RunUtils.cs deleted file mode 100644 index 4907d0209..000000000 --- a/dotnet/src/dotnetcore/GxNetCoreStartup/RunUtils.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Diagnostics; -using System.Text; - -namespace GeneXus.Application -{ - - public static class GxRunner - { - public static void RunAsync( - string commandLine, - string workingDir, - string virtualPath, - string schema, - Action onExit = null) - { - var stdout = new StringBuilder(); - var stderr = new StringBuilder(); - - using var proc = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = commandLine, - WorkingDirectory = workingDir, - UseShellExecute = false, // required for redirection - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true, - RedirectStandardInput = false, // flip to true only if you need to write to stdin - StandardOutputEncoding = Encoding.UTF8, - StandardErrorEncoding = Encoding.UTF8 - }, - EnableRaisingEvents = true - }; - - proc.StartInfo.ArgumentList.Add(virtualPath); - proc.StartInfo.ArgumentList.Add(schema); - - proc.OutputDataReceived += (_, e) => - { - if (e.Data is null) return; - stdout.AppendLine(e.Data); - Console.WriteLine(e.Data); // forward to parent console (stdout) - }; - - proc.ErrorDataReceived += (_, e) => - { - if (e.Data is null) return; - stderr.AppendLine(e.Data); - Console.Error.WriteLine(e.Data); // forward to parent console (stderr) - }; - - proc.Exited += (sender, e) => - { - var p = (Process)sender!; - int exitCode = p.ExitCode; - p.Dispose(); - - Console.WriteLine($"[{DateTime.Now:T}] Process exited with code {exitCode}"); - - // Optional: call user-provided callback - onExit?.Invoke(exitCode); - }; - - if (!proc.Start()) - throw new InvalidOperationException("Failed to start process"); - Console.WriteLine($"[{DateTime.Now:T}] MCP Server Started."); - } - } - -} diff --git a/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs b/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs index 7e11e9e7b..985e20675 100644 --- a/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs +++ b/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs @@ -65,9 +65,6 @@ public static void Main(string[] args) LocatePhysicalLocalPath(); } - - MCPTools.ServerStart(Startup.VirtualPath, Startup.LocalPath, schema); - if (port == DEFAULT_PORT) { BuildWebHost(null).Run(); @@ -867,37 +864,6 @@ public void Apply(ApplicationModel application) } } - static class MCPTools - { - public static void ServerStart(string virtualPath, string workingDir, string schema) - { - IGXLogger log = GXLoggerFactory.GetLogger(typeof(CustomBadRequestObjectResult).FullName); - bool isMpcServer = false; - try - { - List L = Directory.GetFiles(Path.Combine(workingDir,"bin"), "*mcp_service.dll").ToList(); - isMpcServer = L.Count > 0; - if (isMpcServer) - { - GXLogging.Info(log, "Start MCP Server"); - - GxRunner.RunAsync("GxMcpStartup.exe", Path.Combine(workingDir,"bin"), virtualPath, schema, onExit: exitCode => - { - if (exitCode == 0) - Console.WriteLine("Process completed successfully."); - else - Console.Error.WriteLine($"Process failed (exit code {exitCode})"); - }); - } - } - catch (Exception ex) - { - GXLogging.Error(log, "Error starting MCP Server", ex); - } - } - } - - internal class HomeControllerConvention : IApplicationModelConvention { private static bool FindAndStoreDefaultFile()