refactor(nesting): unify console MCP and API validation and commit policies

This commit is contained in:
aj
2026-09-29 11:15:05 -04:00
parent b3a4390169
commit 662bc133b1
13 changed files with 648 additions and 145 deletions
+7
View File
@@ -1,16 +1,23 @@
using System;
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OpenNest.Engine.Jobs;
using OpenNest.Mcp;
NestingEngineRegistry.LoadPlugins(Path.Combine(AppContext.BaseDirectory, "Engines"));
var builder = Host.CreateApplicationBuilder(args);
// stdout carries the JSON-RPC stream; console logs must go to stderr or they corrupt it.
builder.Logging.AddConsole(o => o.LogToStandardErrorThreshold = LogLevel.Trace);
using var toolGate = new SessionToolGate();
builder.Services.AddSingleton<NestSession>();
builder
.Services.AddMcpServer()
.WithRequestFilters(filters => filters.AddCallToolFilter(
next => (context, token) => toolGate.RunAsync(ct => next(context, ct), token)))
.WithStdioServerTransport()
.WithToolsFromAssembly(typeof(Program).Assembly);