mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-19 16:17:40 -05:00
Releasing element-rack jobs from an agent meant hand-writing a console runner around SetReleaseSession, posting set JSON by hand (opaque "Invalid set JSON." and 428 without If-Match) and re-nesting by hand when the 60x120 default wasted sheets. The MCP server now does it through the desktop's own clients and release session: - search_drawings, get_drawing, search_sets, get_set - create_set, update_set, archive_set, restore_set (revision guard handled) - plan_release: material groups, refusals and mergeable drafts, read-only - make_nests: SetReleaseSession with headless ReleaseRenest, File > New nests from NewNestSource (server-allocated names), MaterialLedger when set up, optional merges into drafts - renest_nest: re-nest a Draft/Quote nest, saved with the expected-revision guard only when every part is placed - nest_summary, get_release, undo_release make_nests and renest_nest take candidate sheet sizes: each alone and all together as plate options are tried on copies, keeping the fewest unplaced, then fewest sheets, then least sheet area, because the engine's own stock choice minimizes area, not sheet count. Tests run the tools against the in-process server; docs in docs/mcp-nest-server-tools.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.1 KiB
C#
29 lines
1.1 KiB
C#
using System;
|
|
using System.IO;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using OpenNest.Engine.Jobs;
|
|
using OpenNest.Mcp;
|
|
using OpenNest.Mcp.Database;
|
|
|
|
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>();
|
|
// Database-mode tools read storage.json and the desktop settings once, at first use.
|
|
builder.Services.AddSingleton(_ => NestServerContext.Load());
|
|
builder
|
|
.Services.AddMcpServer()
|
|
.WithRequestFilters(filters => filters.AddCallToolFilter(
|
|
next => (context, token) => toolGate.RunAsync(ct => next(context, ct), token)))
|
|
.WithStdioServerTransport()
|
|
.WithToolsFromAssembly(typeof(Program).Assembly);
|
|
|
|
var app = builder.Build();
|
|
await app.RunAsync();
|