20 lines
888 B
C#
20 lines
888 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using PLCSharp.Mcp;
|
|
|
|
bool allowWrite = args.Length == 3 && args[2] == "--allow-write";
|
|
if ((args.Length != 2 && !allowWrite) || args[0] != "--project" || !File.Exists(Path.Combine(args[1], "project.json")))
|
|
{
|
|
Console.Error.WriteLine("Usage: PLCSharp.Mcp --project <project directory> [--allow-write]");
|
|
return 2;
|
|
}
|
|
var builder = Host.CreateApplicationBuilder();
|
|
builder.Logging.ClearProviders();
|
|
builder.Logging.AddConsole(options => options.LogToStandardErrorThreshold = LogLevel.Trace);
|
|
builder.Services.AddSingleton(new ProjectGateway(Path.GetFullPath(args[1]), allowWrite));
|
|
builder.Logging.SetMinimumLevel(LogLevel.Warning);
|
|
builder.Services.AddMcpServer().WithStdioServerTransport().WithTools<ProjectTools>();
|
|
await builder.Build().RunAsync();
|
|
return 0;
|